Are you using mutate with commitNow=true ?
I tried to reproduce this on v20.03.4, the behaviour I observed is that if mutate is done with commitNow=true , the query always returned the updated value while when commitNow option is not set, it always returned the old value.
Ideally, a query should be run only after a mutation is commited, so that the updated value gets written to disk.
I have not use commitNow=true
In my function I need to update(mutate) and the query in the same transaction, like my pseudo code
startTransaction
set {
<0x1> <ww/attr/level> 200 .
}
getUserNode(func: uid(0x1)) {
uid
level: <ww/attr/level>
}
echo user level (In most cases it will output 200 but sometimes it will output 100)
commit
This problem may be related to the amount of data, we have 700 thousand node.
Is there any compulsion to mutate and query in the same transaction ?
Adding commitNow=true with mutate should solve the issue and the query will then output 200 always.
Let us know if you still face the problem after adding commitNow=true.
Its not really a delay, you simply wont see 200 in your query result unless you commit the mutation before subsequently querying it. Its a different paradigm to e.g. RDBMS, as I understand until you commit your transaction is just a list of commands pending to be run, it wont be reflected in a graph query.
If query is done before committing the mutate transaction, it will show the old value.
Can you share your code snippet and the way the code is run so that we can reproduce it ? In case there is inconsistency with the value in query result, this should be reported as a bug.