1

I am trying to handle some couchbase exceptions in my application. The upsert method can throw a TemporaryFailureException indicating temporary failures on server end. Can there be a case where the CAS value of the document would have been updated? In case this exception occurs, I am retrying for a fixed number of times with exponential backOff. If the CAS value was updated, then while retrying next time I need to make sure next time that I pass the updated CAS value otherwise i will get a CASMismatchException.

So is there a guarantee that CAS value will not have been updated in case of failures on server end?

1 Answers1

0

The CAS represents the "version" of the document and it is used when you need optimistic locking (Two applications trying to change the same document at the same time).

TemporaryFailureException is thrown when the server has more complex issues (Disk failure, lack of memory, etc). If your cluster is properly configured, your server will automatically be failed over and another node will take its place. So, retrying the operation with some kind of backOff mechanism to wait until a server is promoted is a valid strategy.

Worth to highlight that you can call the method "readFromReplica" if you need to read a document in the meantime. Couchbase SDK also has a circuit breaker internally.

deniswsrosa
  • 2,421
  • 1
  • 17
  • 25