In the MYSQL database there is a query like SELECT FOR UPDATE is it possible to somehow implement this design based on a couchbase database transactions?
Otherwise, I need to block reading the record until another transaction on the same record is commited
No, FOR UPDATE is a cursor which Couchbase doesn’t currently support (MB-17008, MB-50978).
You’re after pessimistic locking which isn’t supported directly in SQL++. You could use SQL++ to retrieve a document key then the relevant SDK provided APIs to lock documents. See:
https://docs.couchbase.com/c-sdk/current/howtos/concurrent-document-mutations.html
https://docs.couchbase.com/c-sdk/current/howtos/concurrent-document-mutations.html#pessimistic-locking
See also:
https://www.couchbase.com/blog/optimistic-or-pessimistic-locking-which-one-should-you-pick/
for a discussion about locking strategies.
HTH.
1 Like
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.