This issue breaks backward compatibility for eventing. And also shows different behaviour in 7.0.0 with different bucket binding insert(which uses normal lcb_store insert) and source bucket binding insert(which uses lcb_subdoc insert).
@Ankit Prabhu until we get this sorted out, as a workaround (since this is marked as critical) you can map the LCB_ERR_CAS_MISMATCH to LCB_ERR_DOCUMENT_EXISTS for yourself, since a cas mismatch is only relevant on replace - so even once this is fixed up the workaround should not cause problems (since then it just should not show up anymore).
Ankit Prabhu March 11, 2021 at 10:39 AM
For insert if document is already present libcouchbase 2.x gives LCB_KEY_EEXISTS for both subdoc and store operations.
In 3.1.0 lcb_store gives "LCB_ERR_DOCUMENT_EXISTS" which is expected if document already present in the bucket/collection for insert operation. But lcb_subdoc gives "LCB_ERR_CAS_MISMATCH" for insert operation.
Michael Nitschinger March 11, 2021 at 10:32 AM
@Ankit Prabhu which error were you getting previously with LCB 2 in this situation?
Ankit Prabhu March 11, 2021 at 10:30 AM
lcb_cmdsubdoc_store_semantics(cmd, op_type);
We set the op_type based on customer function. For couchbase.insert function and if its on source bucket, op_type is set to LCB_SUBDOC_STORE_INSERT
Libcouchbase returns Cas mismatch error for insert done through subdoc operations(lcb_subdoc).
https://github.com/couchbase/libcouchbase/blob/ed8b57e731e04e2749393c8bed8f9eb88d5d663d/src/handler.cc#L264
Here libcouchbase checks for opcode as CMD_ADD(0x02) but subdoc operation set opcode to MULTI_MUTATE(0xd1) and insert/replace/upsert is set as command flags.
https://github.com/couchbase/libcouchbase/blob/ed8b57e731e04e2749393c8bed8f9eb88d5d663d/src/operations/subdoc.cc#L871
This issue breaks backward compatibility for eventing. And also shows different behaviour in 7.0.0 with different bucket binding insert(which uses normal lcb_store insert) and source bucket binding insert(which uses lcb_subdoc insert).