1
/** Test TTL docs are not deleted from secondaries directly
4
var rt = new ReplSetTest( { name : "ttl_repl" , nodes: 2 } );
7
var nodes = rt.startSet();
9
var master = rt.getMaster();
10
rt.awaitSecondaryNodes();
11
var slave1 = rt.getSecondary();
14
var masterdb = master.getDB( 'd' );
15
var slave1db = slave1.getDB( 'd' );
16
var mastercol = masterdb[ 'c' ];
17
var slave1col = slave1db[ 'c' ];
19
// create TTL index, wait for TTL monitor to kick in, then check things
20
mastercol.ensureIndex( { x : 1 } , { expireAfterSeconds : 10 } );
22
rt.awaitReplication();
25
slave1col.getDB().adminCommand({setParameter:1, logLevel:1});
27
//insert old doc (10 minutes old) directly on secondary using godinsert
28
slave1col.runCommand("godinsert",
29
{obj: {_id: new Date(), x: new Date( (new Date()).getTime() - 600000 ) } })
30
assert.eq(1, slave1col.count(), "missing inserted doc" );
32
sleep(70*1000) //wait for 70seconds
33
assert.eq(1, slave1col.count(), "ttl deleted my doc!" );
35
// looking for this error : "Assertion: 13312:replSet error : logOp() but not primary"
36
// indicating that the secondary tried to delete the doc, but shouldn't be writing
37
var errorString = "13312";
38
var foundError = false;
39
var globalLogLines = slave1col.getDB().adminCommand({getLog:"global"}).log
40
for (i in globalLogLines) {
41
var line = globalLogLines[i];
42
if (line.match( errorString )) {
44
errorString = line; // replace error string with what we found.
49
assert.eq(false, foundError, "found error in this line: " + errorString);
b'\\ No newline at end of file'