Concurrent Updates - DML Error

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.

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

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

Thanks for the quick reply.

Hi @manik
Is there any alternative to solve this with version 4.5+

Concurrent update on single document must retry. If you want you can checkout 6.5 JAVA SDK transactions https://blog.couchbase.com/couchbase-brings-distributed-multi-document-acid-transactions-to-nosql/