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-27 18:14:41 +0000
commit23fff6621a57dbfd088e42078b11b9e2ef0a7810 (patch)
tree042078f993ede40eac6f1ca39be3d6c7a986f4f7
parent202f27642004fc8a87efa543940825b4f5c8d866 (diff)
downloadmongo-23fff6621a57dbfd088e42078b11b9e2ef0a7810.tar.gz
SERVER-48058 Make sure abort_transactions_on_step_up waits for optime to be applied
(cherry picked from commit d5829d9c7ff5209b1c60440dac62f81c2e5dfe24)
-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");