[BUG]: Upsert that sets a uid array consisting of a large (>~600) number of elements fails if the predicate was star deleted in the same mutation
What version of Dgraph are you using?
v21.03.2 (also fails in v21.12)
Tell us a little more about your go-environment?
go version go1.19 darwin/arm64
Have you tried reproducing the issue with the latest release?
Yes
What is the hardware spec (RAM, CPU, OS)?
Mac Mini (M1, 2020) 16GB RAM, Docker Desktop 4.3.0 (71786), Engine: 20.10.11, Compose: 1.29.2
What steps will reproduce the bug?
When a DQL upsert mutation clears a list of uids in the mutate block with a star delete and then resets uids into that predicate, an inconsistent number of those uids are assigned, IF the number of uids is more than ~600. The issue only occurs when the set is actually cleared (the update path, not the insert path)
Originally reported on the forum here.
Further refined to its simplest form here https://github.com/matthewmcneely/dgraph-v21.03-sandbox/tree/upsert-issue-minimal-reproducable-state
Expected behavior and actual result.
No response
Additional information
No response
Additional observation: if the mutation is applied twice in the upsert, the counts are correct.
upsert {
query{
target as var(func:eq(nid, "XXX")) {
uid
}
books as var(func:type(Book), first: 1000, offset: 100) {
uid
}
}
mutation {
delete {
uid(target) <collection.books> * .
}
set {
uid(target) <nid> "XXX" .
uid(target) <dgraph.type> "BookCollection" .
uid(target) <collection.books> uid(books) .
}
}
mutation {
set {
uid(target) <nid> "XXX" .
uid(target) <dgraph.type> "BookCollection" .
uid(target) <collection.books> uid(books) .
}
}
}
Additional observation: An analysis of the pb.Mutations object in ApplyMutations shows that the correct number of uids are in the protobuf edges slice, before its sent to MutateOverNetwork.
Additional observation: A query for all entries in the collections.books edge shows that indeed only X number of entries are returned, equal to the count(collection.books). Just verifying it wasn't a problem with the @count directive.