diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2014-10-13 11:26:11 -0400 |
---|---|---|
committer | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2014-10-13 22:16:18 -0400 |
commit | 1a44dc6a150524de75dd46c8dc464c7182a37389 (patch) | |
tree | cc570f70678f39fc0be4f3ee9b51cf6c1fb5e9f4 /jstests/noPassthroughWithMongod | |
parent | aa31cae71bc5390fc02d48fc793eebb1991d0ff3 (diff) | |
download | mongo-1a44dc6a150524de75dd46c8dc464c7182a37389.tar.gz |
SERVER-15570 Avoid querying system.indexes in ttl.cpp.
Changed so that the TTL indexes are processed in multiple phases:
- Acquire an IS-mode lock on the database and find all of the
TTL indexes
For each TTL index,
- Acquire an IX-mode lock on the collection and delete all of the
expired documents
Also avoid checking `userFlags` of collection stats in TTL index
tests since it is not set by some storage engines.
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r-- | jstests/noPassthroughWithMongod/ttl1.js | 2 | ||||
-rw-r--r-- | jstests/noPassthroughWithMongod/ttl_repl.js | 18 |
2 files changed, 5 insertions, 15 deletions
diff --git a/jstests/noPassthroughWithMongod/ttl1.js b/jstests/noPassthroughWithMongod/ttl1.js index 3ce494bc2ef..a2d923fc9f5 100644 --- a/jstests/noPassthroughWithMongod/ttl1.js +++ b/jstests/noPassthroughWithMongod/ttl1.js @@ -51,9 +51,7 @@ var msg = RegExp("ttl indexes require the expireAfterSeconds" + assertEntryMatches(log, msg); // Part 2 -assert.eq( 0, t.stats().userFlags ); t.ensureIndex( { x : 1 } , { expireAfterSeconds : 20000 } ); -assert.eq( 1, t.stats().userFlags ); assert.soon( function() { diff --git a/jstests/noPassthroughWithMongod/ttl_repl.js b/jstests/noPassthroughWithMongod/ttl_repl.js index 5646ce22a39..8311e8db85d 100644 --- a/jstests/noPassthroughWithMongod/ttl_repl.js +++ b/jstests/noPassthroughWithMongod/ttl_repl.js @@ -1,8 +1,7 @@ /** Test TTL collections with replication - * Part 1: Initiate replica set. Insert some docs and create a TTL index. Check that both primary - * and secondary get userFlags=1 (indicating that usePowerOf2Sizes is on), - * and check that the correct # of docs age out. - * Part 2: Add a new member to the set. Check it also gets userFlags=1 and correct # of docs. + * Part 1: Initiate replica set. Insert some docs and create a TTL index. + * Check that the correct # of docs age out. + * Part 2: Add a new member to the set. Check that it also gets the correct # of docs. * Part 3: Change the TTL expireAfterSeconds field and check successful propogation to secondary. */ @@ -38,18 +37,14 @@ rt.awaitReplication(); assert.eq( 24 , mastercol.count() , "docs not inserted on primary" ); assert.eq( 24 , slave1col.count() , "docs not inserted on secondary" ); -// before TTL index created, check that userFlags are 0 print("Initial Stats:") print("Master:"); printjson( mastercol.stats() ); print("Slave1:"); printjson( slave1col.stats() ); -assert.eq( 0 , mastercol.stats().userFlags , "userFlags not 0 on primary"); -assert.eq( 0 , slave1col.stats().userFlags , "userFlags not 0 on secondary"); - // create TTL index, wait for TTL monitor to kick in, then check that -// userFlags get set to 1, and correct number of docs age out +// the correct number of docs age out assert.commandWorked(mastercol.ensureIndex({ x: 1 }, { expireAfterSeconds: 20000 })); rt.awaitReplication(); @@ -61,8 +56,6 @@ printjson( mastercol.stats() ); print("Slave1:"); printjson( slave1col.stats() ); -assert.eq( 1 , mastercol.stats().userFlags , "userFlags not 1 on primary" ); -assert.eq( 1 , slave1col.stats().userFlags , "userFlags not 1 on secondary" ); assert.eq( 6 , mastercol.count() , "docs not deleted on primary" ); assert.eq( 6 , slave1col.count() , "docs not deleted on secondary" ); @@ -76,11 +69,10 @@ rt.awaitSecondaryNodes(); var slave2col = slave.getDB( 'd' )[ 'c' ]; -// check that its userFlags are also 1, and it has right number of docs +// check that the new secondary has the correct number of docs print("New Slave stats:"); printjson( slave2col.stats() ); -assert.eq( 1 , slave2col.stats().userFlags , "userFlags not 1 on new secondary"); assert.eq( 6 , slave2col.count() , "wrong number of docs on new secondary"); |