What happens if two UPDATEs happen simultaneously on the same document


#1

Hi,

I’m just wondering about what happens if there are two simultaneous UPDATE N1QL requests made to the same document at the same time.

e.g. You’re changing a total and adding something to the document

Does it work a bit like a GET-change-CAS operation, and if the document has been changed since getting the document, does it re-run the UPDATE request, does it return an error, or something else?

Thanks.


#2

YES. N1QL UPDATE uses CAS.


#3

@vsr1 thanks

And would it then re-run the query until there was no CAS conflict? I assume it does, I just want to be 100% sure.

Thanks.


#4

When mismatch it returns error and application needs to handle retry logic


#5

OK, thanks for that.