What happens if two UPDATEs happen simultaneously on the same document

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.

YES. N1QL UPDATE uses CAS.

@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.

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

OK, thanks for that.