Hi guys! We’re using Couchbase Community Edition 4.5. Here is the problem we’ve stuck at…
We have a document that, among other keys, contains a key that holds an array of JSON objects. Each object in the array has a boolean key. Example:
The problem is when multiple clients try to change some of the array elements (not the same index) to true.
Many of the changes are “getting lost”. All the changes must be made…
We are using N1QL, we have searched numerous solutions, but nothing seems to work right… We have read about CAS etc, but it’s confusing!!
Could anyone help a bit?
April 2, 2018, 2:01pm
If you are using N1QL UPDATE statement, you should have got error when CAS value mismatch and you need to retry.
General info on
I get the error, I setup a loop and try 10 times…
The problem is that the query needs some time to complete, so when there are lots of requests, inevitably some of them get rejected and the user has lost quite some time waiting! :
Also, see this:
In Couchbase, we use the optimistic locking when updating a document. We don’t hold a lock and instead use CAS to check we’re writing back to the same version we read. This will cause conflicts and you need a way to back off and retry.