[SERVER-35017] Multi-document transactions do not respect atClusterTime Created: 16/May/18  Updated: 29/Oct/23  Resolved: 18/May/18

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

Type: Bug Priority: Major - P3
Reporter: Tess Avitabile (Inactive) Assignee: Max Hirschhorn
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-34778 Add support for specifying atClusterT... Closed
Related
is related to SERVER-34388 Continue converting snapshot reads te... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: TIG 2018-06-04
Participants:

 Description   

When we added support for speculative execution, multi-document transactions stopped respecting atClusterTime. That is, convertingĀ this test to use multi-document transactions would fail. We should convert this test and make the code changes necessary to ensure it passes.



 Comments   
Comment by Githook User [ 18/May/18 ]

Author:

{'username': 'visemet', 'name': 'Max Hirschhorn', 'email': 'max.hirschhorn@mongodb.com'}

Message: SERVER-35017 Disable speculative behavior when using atClusterTime.
Branch: master
https://github.com/mongodb/mongo/commit/05651d31cad6fa886a436fda597234ceebf52dfd

Comment by Tess Avitabile (Inactive) [ 16/May/18 ]

I don't think we want to disable speculative behavior when atClusterTime is specified. Instead, we should read at the specified cluster time, but only wait for it to be locally committed (rather than wait for it to be majority committed). I suppose, however, that we could disable speculative behavior with atClusterTime for now and re-enable it in SERVER-34620.

Comment by Max Hirschhorn [ 16/May/18 ]

tess.avitabile, matthew.russotto, does the following seem like the appropriate change to make to disable speculative behavior when using readConcern={level: "snapshot", atClusterTime: ...}?

diff --git a/src/mongo/db/read_concern.cpp b/src/mongo/db/read_concern.cpp
index 46c9e8b..59294da 100644
--- a/src/mongo/db/read_concern.cpp
+++ b/src/mongo/db/read_concern.cpp
@@ -212,8 +212,11 @@ Status waitForReadConcern(OperationContext* opCtx,
                                                                  replCoord->getReplicationMode());
 
     auto session = OperationContextSession::get(opCtx);
-    // Currently speculative read concern is used only for transactions and snapshot reads.
-    const bool speculative = session && session->inSnapshotReadOrMultiDocumentTransaction();
+    // Currently speculative read concern is used only for transactions and snapshot reads. However,
+    // we don't use speculative read concern if "atClusterTime" was explicitly specified as we've
+    // already been instructed to use an opTime that isn't last applied.
+    const bool speculative = session && session->inSnapshotReadOrMultiDocumentTransaction() &&
+        !readConcernArgs.getArgsAtClusterTime();
 
     if (readConcernArgs.getLevel() == repl::ReadConcernLevel::kLinearizableReadConcern) {
         if (replCoord->getReplicationMode() != repl::ReplicationCoordinator::modeReplSet) {

Generated at Thu Feb 08 04:38:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.