Concurrent updates exception

Hi @graham.pople , @vsr1
suppose document is "{

when i write update myucket set“Bangalore” where“Delhi”
will updates on hotel1 and concurrent updates like this on hotel2
will result in concurrent update exception
or its equivalent to subdoc APIs

Getting this error:
[{“msg”:“DML Error, possible causes include CAS mismatch or concurrent modificationFailed to perform update - cause: MCResponse status=KEY_EEXISTS, opcode=SET, opaque=0, msg: Data exists for key”,“code”:12009}

N1QL update is full document update. Concurrent update of same document can result in cas mismatch and you need to retry again.

Hi @vsr1
yes it makes sense, if i start using sub doc API for update. It will eliminate this issue right.
But i am windering is it possible to make conditional update
like update only when “”=“Delhi”

use subdoc get with cas. If it is “Delhi” do subdoc update else ignore. The check must be done in client.

DocumentFragment result = bucket.mutateIn(id)
.upsert(subDocId, object)
what will be cas here

You should check API’s i am not expert in SDKs. or post in SDK section

Multi document updates checkout JAVA SDK transactions

Okay, Thanks @vsr1 . Will check document