[SERVER-51807] Speculative majority reads unsafely start storage transactions without holding a global lock Created: 22/Oct/20  Updated: 29/Oct/23  Resolved: 12/Nov/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Louis Williams Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Apply this patch:

diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
index 3e531b3717..2418731111 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
@@ -565,6 +565,7 @@ void WiredTigerRecoveryUnit::_txnOpen() {
     invariant(!_isCommittingOrAborting(),
               str::stream() << "commit or rollback handler reopened transaction: "
                             << toString(_getState()));
+    invariant(cc().getOperationContext()->lockState()->isLocked());
     _ensureSession();
 
     // Only start a timer for transaction's lifetime if we're going to log it.

And run:

resmoke.py run --suite=replica_sets jstests/replsets/change_stream_speculative_majority.js

Sprint: Repl 2020-11-16
Participants:

 Description   

Global locks are required to perform storage engine operations.

Without holding any locks, the function waitForSpeculativeMajorityReadConcernImpl calls getPointInTimeReadTimestamp() which starts a storage transaction implicitly if one is not already active.

This means it is possible for a speculative majority reader to start a transaction while the storage engine is shutting down, which is unsafe because it does not have defined behavior.



 Comments   
Comment by Githook User [ 12/Nov/20 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'email': 'jesse@mongodb.com', 'username': 'ajdavis'}

Message: SERVER-51807 Get point-in-time read timestamp in global lock
Branch: master
https://github.com/mongodb/mongo/commit/d0f87503e4d3dc265fb1340d4f492de884edcda4

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