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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/**
* Checks that DDL command that use step-down resilient coordinators are shown when calling the
* currentOp command.
*
* @tags: [
* requires_fcv_50,
* featureFlagShardingFullDDLSupport
* ]
*/
(function() {
'use strict';
load('jstests/libs/fail_point_util.js');
const kDbName = 'db';
const kCollectionName = 'test';
const nss = kDbName + '.' + kCollectionName;
const toNss = nss + '_renamed';
let st = new ShardingTest({shards: 1});
st.s.adminCommand({enableSharding: kDbName});
st.s.getDB(kDbName).getCollection(kCollectionName).insert({x: 1});
let getCurrentOpOfDDL = (ddlOpThread, desc) => {
let ddlCoordinatorFailPoint =
configureFailPoint(st.rs0.getPrimary(), 'hangBeforeRunningCoordinatorInstance');
ddlOpThread.start();
ddlCoordinatorFailPoint.wait();
let currOp = st.s.getDB('admin')
.aggregate([{$currentOp: {allUsers: true}}, {$match: {desc: desc}}])
.toArray();
ddlCoordinatorFailPoint.off();
ddlOpThread.join();
return currOp;
};
{
jsTestLog('Check create collection shows in current op');
let shardKey = {_id: 1};
let ddlOpThread = new Thread((mongosConnString, nss, shardKey) => {
let mongos = new Mongo(mongosConnString);
mongos.adminCommand({shardCollection: nss, key: shardKey});
}, st.s0.host, nss, shardKey);
let currOp = getCurrentOpOfDDL(ddlOpThread, 'CreateCollectionCoordinator');
// There must be one operation running with the appropiate ns.
assert.eq(1, currOp.length);
assert.eq(nss, currOp[0].ns);
// It must have at least the shardKey.
assert(currOp[0].hasOwnProperty('command'));
assert(currOp[0].command.hasOwnProperty('request'));
assert(currOp[0].command.request.hasOwnProperty('shardKey'));
assert.eq(shardKey, currOp[0].command.request.shardKey);
}
{
jsTestLog('Check rename collection shows in current op');
let ddlOpThread = new Thread((mongosConnString, fromNss, toNss) => {
let mongos = new Mongo(mongosConnString);
mongos.getCollection(fromNss).renameCollection(toNss.split('.')[1], true);
}, st.s0.host, nss, toNss);
let currOp = getCurrentOpOfDDL(ddlOpThread, 'RenameCollectionCoordinator');
// There must be one operation running with the appropiate ns.
assert.eq(1, currOp.length);
assert.eq(nss, currOp[0].ns);
// It must have the target collection.
assert(currOp[0].hasOwnProperty('to'));
assert.eq(toNss, currOp[0].to);
}
{
jsTestLog('Check drop collection shows in current op');
let ddlOpThread = new Thread((mongosConnString, nss) => {
let mongos = new Mongo(mongosConnString);
mongos.getCollection(nss).drop();
}, st.s0.host, toNss);
let currOp = getCurrentOpOfDDL(ddlOpThread, 'DropCollectionCoordinator');
// There must be one operation running with the appropiate ns.
assert.eq(1, currOp.length);
assert.eq(toNss, currOp[0].ns);
}
{
jsTestLog('Check drop database shows in current op');
let ddlOpThread = new Thread((mongosConnString, dbName) => {
let mongos = new Mongo(mongosConnString);
mongos.getDB(dbName).dropDatabase();
}, st.s0.host, kDbName);
let currOp = getCurrentOpOfDDL(ddlOpThread, 'DropDatabaseCoordinator');
// There must be one operation running with the appropiate ns.
assert.eq(1, currOp.length);
assert.eq(kDbName, currOp[0].ns.split('.')[0]);
}
st.stop();
})();
|