Concurrent Updates - DML Error

#1

Hey all,

When trying to update the same document concurrently with N1QL I get the following error:

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

This happens on both Couchbase Server 4.0 Enterprise and Couchbase Server 4.1 Enterprise.

What would you suggest I do to avoid this?

Thanks in advance,
Itamar.

DML Error during update query n1ql
#2

This can happen when multiple clients try to update the value of the same document. An update operation on the query engine involves a read followed by a write. If another client thread happens to race and modify the value of the document in between the read - write cycle of the first operation then it would fail with this error.

Your only option is to retry the operation.

Cheers,
Manik

#3

OK, I’ll make sure I handle this error with a retry.

Thanks for the quick reply.