[SERVER-42750] OperationContext::inMultiDocumentTransaction() doesn't return true when applying operations for prepared transaction during recovery Created: 09/Aug/19  Updated: 29/Oct/23  Resolved: 16/Sep/19

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 4.2.1, 4.3.1

Type: Bug Priority: Major - P3
Reporter: William Schultz (Inactive) Assignee: Siyuan Zhou
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
related to SERVER-40466 Unify checks for inMultiDocumentTrans... Closed
is related to SERVER-42755 recover_prepared_txn_with_multikey_wr... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.2
Sprint: Repl 2019-09-09, Repl 2019-09-23
Participants:
Linked BF Score: 12

 Description   

When we reconstruct prepared transactions during replication recovery, we do not explicitly call OperationContext::setInMultiDocumentTransaction(), which means that OperationContext::inMultiDocumentTransaction() will return false. This has implications for multikey writes that are done inside a prepared transaction that is being reconstructed. When we set an index to be multikey, we expect this check to tell us whether we are inside a transaction and, as a result, need to do the multikey write in a side transaction. If we do not do the write in a side transaction, the multikey write can generate prepare conflicts on the catalog object, which is undesired. The simplest way to address this may be to just call OperationContext::setInMultiDocumentTransaction() explicitly before applying a prepared transaction during recovery.



 Comments   
Comment by Githook User [ 24/Sep/19 ]

Author:

{'name': 'Samyukta Lanka', 'username': 'lankas', 'email': 'samy.lanka@mongodb.com'}

Message: SERVER-40466 Unify checks for being in a multi-document transaction

(cherry picked from commit 77967c90b1a521108c052af235ce7de9742aa95e)

SERVER-42755 recover_prepared_txn_with_multikey_write.js should verify absence of prepare conflicts on catalog after restart.

(cherry picked from commit eaf81228328738b685532c7eb10f833362434061)

SERVER-42750 Set opCtx->inMultiDocumentTransaction() in transaction recovery.

(cherry picked from commit 16c17677704a4f979381d593106a0c356088fd30)
Branch: v4.2
https://github.com/mongodb/mongo/commit/1781933c126d2aff697cdb42a8f84b8212db23ad

Comment by Githook User [ 13/Sep/19 ]

Author:

{'name': 'Siyuan Zhou', 'username': 'visualzhou', 'email': 'siyuan.zhou@mongodb.com'}

Message: SERVER-42750 Set opCtx->inMultiDocumentTransaction() in transaction recovery.
Branch: master
https://github.com/mongodb/mongo/commit/16c17677704a4f979381d593106a0c356088fd30

Comment by William Schultz (Inactive) [ 13/Aug/19 ]

If SERVER-40466 is backported to 4.2, we will need to implement this fix on that branch as well.

Comment by William Schultz (Inactive) [ 13/Aug/19 ]

As part of this ticket, we need to resolve this TODO to re-enable a test that depends on this fix.

Generated at Thu Feb 08 05:01:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.