blob: b39c041e7d5f7e5caf93cc86398ec24e5eaab4e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/**
* Tests that retrying a prepared transaction does not block stepDown.
* @tags: [uses_transactions, uses_prepare_transaction]
*/
(function() {
"use strict";
load("jstests/core/txns/libs/prepare_helpers.js");
// This test completes with a prepared transaction still active, so we cannot enforce an accurate
// fast count.
TestData.skipEnforceFastCountOnValidate = true;
const replTest = new ReplSetTest({nodes: 1});
replTest.startSet();
replTest.initiate();
let primary = replTest.getPrimary();
const dbName = "test";
const collName = "coll";
assert.commandWorked(primary.getDB(dbName).createCollection(collName));
let session = primary.startSession();
let sessionDB = session.getDatabase(dbName);
const sessionColl = sessionDB.getCollection(collName);
session.startTransaction();
assert.commandWorked(sessionColl.insert([{_id: 1}]));
jsTestLog("Prepare the transaction");
PrepareHelpers.prepareTransaction(session);
jsTestLog("Retry the prepared transaction");
PrepareHelpers.prepareTransaction(session);
// Test that stepDown can proceed.
jsTestLog("Step down primary");
assert.commandWorked(
primary.adminCommand({replSetStepDown: ReplSetTest.kForeverSecs, force: true}));
replTest.stopSet();
}());
|