Skip to content

Conversation

@DemetrisChr
Copy link
Contributor

Motivation

Instead of using the CAS from the existing staged mutation, we should use the CAS from the transaction_get_result that was given to the replace operation. The original behavior of using the CAS from the staged mutation is considered a spec bug.

A benefit of this approach is that post-ExtReplaceBodyWithXattr, the transaction_get_result, if fetched via a txn get operation, will come from a server read, which will include an up-to-date CAS. This means that the transaction will not fail if the document was “illegally” inserted outside the transaction after the transaction had created the staged insert.

The user will either have done a transactional get after the transactional insert to get the transaction_get_result passed to the replace, or have given the transaction_get_result that was returned by the txn insert. This means that the CAS in the transaction_get_result will be the one we have in the staged mutation or newer, so there’s no need to use the one from the staged mutation.

Change

  • When doing a txn replace for a document that already is a staged insert, create a staged insert with the CAS from the transaction_get_result passed to the replace operation instead of using the CAS from the existing staged mutation.

Result

  • Tests pass

@DemetrisChr DemetrisChr merged commit 86549bc into couchbase:main May 12, 2025
24 of 27 checks passed
@DemetrisChr DemetrisChr deleted the CXXCBC-683-txn-insertuse-result-cas branch May 12, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants