blob: 4bd880477ce6253b3c41bcad5cdb89fe1db4bf6c (
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
|
/**
* Tests that the shard will update the min optime recovery document after startup.
* @tags: [requires_persistence]
*/
(function() {
"use strict";
var st = new ShardingTest({shards: 1});
// Insert a recovery doc with non-zero minOpTimeUpdaters to simulate a migration
// process that crashed in the middle of the critical section.
var recoveryDoc = {
_id: 'minOpTimeRecovery',
configsvrConnectionString: st.configRS.getURL(),
shardName: 'shard0000',
minOpTime: {ts: Timestamp(0, 0), t: 0},
minOpTimeUpdaters: 2
};
assert.writeOK(st.d0.getDB('admin').system.version.insert(recoveryDoc));
// Make sure test is setup correctly.
var minOpTimeRecoveryDoc =
st.d0.getDB('admin').system.version.findOne({_id: 'minOpTimeRecovery'});
assert.neq(null, minOpTimeRecoveryDoc);
assert.eq(0, minOpTimeRecoveryDoc.minOpTime.ts.getTime());
assert.eq(2, minOpTimeRecoveryDoc.minOpTimeUpdaters);
st.restartMongod(0);
// After the restart, the shard should have updated the opTime and reset minOpTimeUpdaters.
minOpTimeRecoveryDoc = st.d0.getDB('admin').system.version.findOne({_id: 'minOpTimeRecovery'});
assert.neq(null, minOpTimeRecoveryDoc);
assert.gt(minOpTimeRecoveryDoc.minOpTime.ts.getTime(), 0);
assert.eq(0, minOpTimeRecoveryDoc.minOpTimeUpdaters);
st.stop();
})();
|