CXXCBC-683: Txn replace - Use CAS from given TransactionsGetResult when document is a staged insert #763
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Instead of using the CAS from the existing staged mutation, we should use the CAS from the
transaction_get_resultthat 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_resultpassed to the replace, or have given thetransaction_get_resultthat was returned by the txn insert. This means that the CAS in thetransaction_get_resultwill 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
transaction_get_resultpassed to thereplaceoperation instead of using the CAS from the existing staged mutation.Result