blob: ca159b59242f09809ca5c92e35f78b58ee03bb52 (
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
45
46
47
48
49
50
51
52
53
|
/**
* Test that a deletion triggered by a TTL index recovers the sharding filtering metadata
*
* * @tags: [
* # Needed since previous versions didn't require the sharding filtering information to filter
* # direct writes to shards.
* requires_fcv_53,
* # It requires persistence because it assumes shards will still have their data after restarting.
* requires_persistence
* ]
*/
(function() {
'use strict';
load("jstests/sharding/libs/find_chunks_util.js");
var st = new ShardingTest({
mongos: 1,
shards: 1,
rs: {
nodes: 1,
// Reducing the TTL Monitor sleep
setParameter: {ttlMonitorSleepSecs: 5}
}
});
var kDbName = 'db';
var kCollName = 'foo';
var mongos = st.s0;
var shard0 = st.shard0.shardName;
assert.commandWorked(mongos.adminCommand({enableSharding: kDbName}));
var ns = kDbName + '.' + kCollName;
assert.commandWorked(mongos.adminCommand({shardCollection: ns, key: {a: 1}}));
assert.commandWorked(
mongos.getDB(kDbName)[kCollName].createIndex({b: 1}, {expireAfterSeconds: 20}));
for (let i = 0; i < 20; ++i) {
mongos.getDB(kDbName)[kCollName].insert({a: i, b: new Date()});
}
// At this point the shard is restarted to have an unknown filtering metadata
st.restartShardRS(0);
// The find is perfomed directly against the shard to avoid to force a refresh as part of the shard
// versioning protocol
assert.soon(() => st.shard0.getDB(kDbName)[kCollName].find({}).count() == 0);
st.stop();
})();
|