Unable to get document lock


We have CouchBase document use to store vehicle location data (lat, lang) and vehicle availability status (Bussy, Idle, etc). The location data is received every 15 seconds. Sometimes we cant change vehicle status using the getAndLock() method and it gives a Temporary lock failure exception.

Our current approach is to retry (3 times) to get the document lock and try to update.

Is there any other way to provide priority to the vehicle status update thread other than the vehicle location update thread?


Hi Prasad,

In the connection/environment you can set the retry algorithm or write a custom (at least in the newer Java SDK)

I am curious if you are storing an array of status & location information in thetarge doc - the details of your implementation design my have a dramatic impact.

You might want to consider Eventing (high performance infrastructure less compute) , I could provide guidance on this this if you answer the above and supply a sample data record. Your use case reminds me a bit of the logic shown in the Eventing Scriptlet example Function: Advanced Keep the Last N User Items | Couchbase Docs


Hi Prasad,

Have you considered optimistic locking with CAS instead of getAndLock()?