summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@10gen.com>2020-05-08 14:59:56 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-19 20:04:38 +0000
commitd5829d9c7ff5209b1c60440dac62f81c2e5dfe24 (patch)
treebddc8938c371694d426991f555b876c7f7003b93
parent956b43ff33c8c3c3c98cc0dc18fd439b54d29394 (diff)
downloadmongo-d5829d9c7ff5209b1c60440dac62f81c2e5dfe24.tar.gz
SERVER-48058 Make sure abort_transactions_on_step_up waits for optime to be applied
-rw-r--r--jstests/replsets/abort_in_progress_transactions_on_step_up.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/jstests/replsets/abort_in_progress_transactions_on_step_up.js b/jstests/replsets/abort_in_progress_transactions_on_step_up.js
index 7c4f37c4769..e58ede11577 100644
--- a/jstests/replsets/abort_in_progress_transactions_on_step_up.js
+++ b/jstests/replsets/abort_in_progress_transactions_on_step_up.js
@@ -70,14 +70,18 @@ jsTestLog("Committing transaction but fail on replication");
let res = session.commitTransaction_forTesting();
assert.commandFailedWithCode(res, ErrorCodes.WriteConcernFailed);
-// Remember the commit OpTime on primary.
+// Remember the start and commit OpTimes on primary.
let txnTableEntry = getTxnTableEntry(testDB);
assert.eq(txnTableEntry.state, "committed");
-const commitOpTime = getTxnTableEntry(testDB).lastWriteOpTime;
+const commitOpTime = txnTableEntry.lastWriteOpTime;
+const startOpTime = testDB.getSiblingDB("local").oplog.rs.findOne({ts: commitOpTime.ts}).prevOpTime;
jsTestLog("Wait for the new primary to block on fail point.");
stopReplProducerOnDocumentFailPoint.wait();
+jsTestLog("Wait for the new primary to apply the first op of transaction.");
+assert.soon(() => getLastOpTime(newPrimary) >= startOpTime);
+
// Now the transaction should be in-progress on newPrimary.
txnTableEntry = getTxnTableEntry(newTestDB);
assert.eq(txnTableEntry.state, "inProgress");