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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/**
* Tests that tickets can be resized during runtime, if not being dynamically adjusted. This test
* exercises both increase and decrease of tickets.
*
* @tags: [
* requires_replication, # Tickets can only be resized when using the WiredTiger engine.
* requires_wiredtiger,
* ]
*/
(function() {
'use strict';
load("jstests/libs/feature_flag_util.js");
jsTestLog("Start a replica set with execution control enabled by default");
let replTest = new ReplSetTest({
name: jsTestName(),
nodes: 1,
});
replTest.startSet();
replTest.initiate();
let mongod = replTest.getPrimary();
// TODO (SERVER-67104): Remove the feature flag check.
if (FeatureFlagUtil.isPresentAndEnabled(mongod, 'ExecutionControl')) {
// Users cannot manually adjust read/write tickets once execution control is enabled at startup.
assert.commandFailedWithCode(
mongod.adminCommand({setParameter: 1, wiredTigerConcurrentWriteTransactions: 10}),
ErrorCodes.IllegalOperation);
assert.commandFailedWithCode(
mongod.adminCommand({setParameter: 1, wiredTigerConcurrentReadTransactions: 10}),
ErrorCodes.IllegalOperation);
}
replTest.stopSet();
const gfixedConcurrentTransactions = "fixedConcurrentTransactions";
jsTestLog("Start a replica set with execution control explicitly disabled on startup");
replTest = new ReplSetTest({
name: jsTestName(),
nodes: 1,
nodeOptions: {
// Users can opt out of execution control by specifying the 'fixedConcurrentTransactions'
// option on startup.
setParameter: {storageEngineConcurrencyAdjustmentAlgorithm: gfixedConcurrentTransactions}
},
});
replTest.startSet();
replTest.initiate();
mongod = replTest.getPrimary();
assert.commandWorked(
mongod.adminCommand({setParameter: 1, wiredTigerConcurrentWriteTransactions: 20}));
assert.commandWorked(
mongod.adminCommand({setParameter: 1, wiredTigerConcurrentReadTransactions: 20}));
replTest.stopSet();
jsTestLog("Start a replica set with execution control implicitly disabled on startup");
replTest = new ReplSetTest({
name: jsTestName(),
nodes: 1,
nodeOptions: {
// If a user manually sets read/write tickets on startup, implicitly set the
// 'storageEngineConcurrencyAdjustmentAlgorithm' parameter to 'fixedConcurrentTransactions'
// and disable execution control.
setParameter: {wiredTigerConcurrentReadTransactions: 20}
},
});
replTest.startSet();
replTest.initiate();
mongod = replTest.getPrimary();
const getParameterResult =
mongod.adminCommand({getParameter: 1, storageEngineConcurrencyAdjustmentAlgorithm: 1});
assert.commandWorked(getParameterResult);
assert.eq(getParameterResult.storageEngineConcurrencyAdjustmentAlgorithm,
gfixedConcurrentTransactions);
// The 20, 10, 30 sequence of ticket resizes are just arbitrary numbers in order to test a decrease
// (20 -> 10) and an increase (10 -> 30) of tickets.
assert.commandWorked(
mongod.adminCommand({setParameter: 1, wiredTigerConcurrentWriteTransactions: 20}));
assert.commandWorked(
mongod.adminCommand({setParameter: 1, wiredTigerConcurrentWriteTransactions: 10}));
assert.commandWorked(
mongod.adminCommand({setParameter: 1, wiredTigerConcurrentWriteTransactions: 30}));
assert.commandWorked(
mongod.adminCommand({setParameter: 1, wiredTigerConcurrentReadTransactions: 20}));
assert.commandWorked(
mongod.adminCommand({setParameter: 1, wiredTigerConcurrentReadTransactions: 10}));
assert.commandWorked(
mongod.adminCommand({setParameter: 1, wiredTigerConcurrentReadTransactions: 30}));
replTest.stopSet();
}());
|