[SERVER-52884] Remove race in reconstruct_prepared_transactions_initial_sync.js Created: 16/Nov/20  Updated: 29/Oct/23  Resolved: 23/Nov/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.9.0, 4.2.13, 4.4.5

Type: Bug Priority: Major - P3
Reporter: George Wangensteen Assignee: George Wangensteen
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.4, v4.2
Sprint: Repl 2020-11-30
Participants:
Linked BF Score: 17

 Description   

In reconstruct_prepared_transactions_initial_sync.js, there is a race between the primary receiving the "commit transaction" instruction from the test for transaction four, and the primary receiving a heartbeat response or replSetUpdatePosition from the secondary notifying it that the secondary has applied the "prepare" instruction for that same transaction.

Currently, we "prepare" transaction four on the primary while the secondary is in initial sync. We then call "awaitSecondaryNodes" to ensure that the secondary has finished initial sync (and therefore applied the "prepare" oplog entry for transaction four) before committing the transaction. However, "awaitSecondaryNodes" does not guarantee that the primary has heard from the secondary that it has applied the "prepare" for the transaction, which would allow it to advance the majority commit point to or past the "prepare" entry. Thus, if the commit transaction request is received by the primary before the primary receives such an update from the secondary, then the majority commit point will still be behind the "prepare" entry for the transaction and we will hit this uassert.

We should add something like ReplSetTest.awaitLastOpCommitted before committing the transaction to ensure not only that the secondary has finished initial sync + applied the prepare op locally, but also that the primary is aware of this fact and can therefore advance the majority commit point.



 Comments   
Comment by Githook User [ 18/Feb/21 ]

Author:

{'name': 'George Wangensteen', 'email': 'george.wangensteen@mongodb.com', 'username': 'gewa24'}

Message: SERVER-52884 Remove race in reconstruct_prepared_transactions_initial_sync.js
Branch: v4.2
https://github.com/mongodb/mongo/commit/da451e4ac49dfac6a435f4e8906fb02a21418555

Comment by Githook User [ 17/Feb/21 ]

Author:

{'name': 'George Wangensteen', 'email': 'george.wangensteen@mongodb.com', 'username': 'gewa24'}

Message: SERVER-52884 Remove race in reconstruct_prepared_transactions_initial_sync.js
Branch: v4.4
https://github.com/mongodb/mongo/commit/73f48c8115a5792a20d85f343207772bd6d316da

Comment by Githook User [ 23/Nov/20 ]

Author:

{'name': 'George Wangensteen', 'email': 'george.wangensteen@mongodb.com'}

Message: SERVER-52884 Remove race in reconstruct_prepared_transactions_initial_sync.js
Branch: master
https://github.com/mongodb/mongo/commit/829617a5c30b6aa20f36950a165ea35e2c17dc2d

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