mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-22 04:59:34 +01:00
SERVER-81109:Fix internal_transactions_sharded_from_mongod.js's handling of causal consistency across sessions (#24784)
GitOrigin-RevId: 92fa8926e2b284dfd18cc6b1e8d6e7b7a572c213
This commit is contained in:
parent
57056038a8
commit
56499efea5
@ -108,15 +108,6 @@ export const $config = extendWorkload($baseConfig, function($config, $super) {
|
||||
print("Starting new sessions after internal transaction error: " +
|
||||
tojsononeline(e));
|
||||
this.startSessions(defaultDb);
|
||||
// When causal consistency is required, the verifyDocuments state would perform
|
||||
// reads against mongos with afterClusterTime equal to the max of the clusterTimes
|
||||
// of all sessions that it has created on the shard that it uses to run internal
|
||||
// transactions from. Bump the clusterTime on the mongos after the shard has
|
||||
// recovered so that the mongos can gossip the clusterTime correctly to the other
|
||||
// shard; otherwise when the next state is the verifyDocuments state, the
|
||||
// afterClusterTime in the command could be higher than the clusterTime known to
|
||||
// that shard and that would cause the command to fail.
|
||||
this.bumpClusterTime(defaultDb, collName);
|
||||
return;
|
||||
}
|
||||
throw e;
|
||||
|
@ -639,6 +639,14 @@ export function extendWithInternalTransactionsUnsharded($config, $super) {
|
||||
// The read below should not be done inside a transaction (and use readConcern level
|
||||
// "snapshot").
|
||||
fsm.forceRunningOutsideTransaction(this);
|
||||
const session = db.getMongo().startSession();
|
||||
const sessionDb = session.getDatabase(db.getName());
|
||||
for (const s of this.sessions) {
|
||||
if (s.getClusterTime() !== undefined)
|
||||
session.advanceClusterTime(s.getClusterTime());
|
||||
if (s.getClusterTime() !== undefined)
|
||||
session.advanceOperationTime(s.getOperationTime());
|
||||
}
|
||||
|
||||
const numDocsExpected = Object.keys(this.expectedCounters).length;
|
||||
const findCmdObj = {
|
||||
@ -652,7 +660,7 @@ export function extendWithInternalTransactionsUnsharded($config, $super) {
|
||||
findCmdObj.readConcern.level = "majority";
|
||||
}
|
||||
}
|
||||
const docs = assert.commandWorked(db.runCommand(findCmdObj)).cursor.firstBatch;
|
||||
const docs = assert.commandWorked(sessionDb.runCommand(findCmdObj)).cursor.firstBatch;
|
||||
print("verifyDocuments " +
|
||||
tojsononeline(
|
||||
{findCmdObj, numDocsFound: docs.length, numDocsExpected: numDocsExpected}));
|
||||
|
Loading…
Reference in New Issue
Block a user