Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-17984

TTL Monitor doesn't modify query to match partial Index filter

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.1.1
    • Fix Version/s: 3.1.3
    • Component/s: Indexing
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      var t = db.index_filtered_ttl;
      t.drop();
       
      t.ensureIndex({x:1}, {expireAfterSeconds:2000, filter:{z:{$exists:1}}} )
       
      var now = (new Date()).getTime();
      var past = new Date(now - (3600 * 1000 * 2));
      t.insert( { x : past, z:2} );
      t.insert( { x : past} );
       
      printjson(t.validate().keysPerIndex);
      assert.eq(1,t.find({$query: {z:{$exists:1}}, $hint:{x:1}}).itcount(),
                "Wrong number of documents in partial index, before ttl monitor run");
      assert.eq(2,t.find({}).itcount(),
                "Wrong number of documents in database, before ttl monitor run");
       
      // wait for the ttl monitor to run
      sleep(70 * 1000);
      printjson(t.validate().keysPerIndex);
      assert.eq(0,t.find({$query: {z:{$exists:1}}, $hint:{x:1}}).itcount(),
                "Wrong number of documents in partial index, after ttl monitor run");
      assert.eq(1,t.find({}).itcount(),
                "Wrong number of documents in database, after ttl monitor run");
      

      Show
      var t = db.index_filtered_ttl; t.drop();   t.ensureIndex({x:1}, {expireAfterSeconds:2000, filter:{z:{$exists:1}}} )   var now = (new Date()).getTime(); var past = new Date(now - (3600 * 1000 * 2)); t.insert( { x : past, z:2} ); t.insert( { x : past} );   printjson(t.validate().keysPerIndex); assert.eq(1,t.find({$query: {z:{$exists:1}}, $hint:{x:1}}).itcount(), "Wrong number of documents in partial index, before ttl monitor run"); assert.eq(2,t.find({}).itcount(), "Wrong number of documents in database, before ttl monitor run");   // wait for the ttl monitor to run sleep(70 * 1000); printjson(t.validate().keysPerIndex); assert.eq(0,t.find({$query: {z:{$exists:1}}, $hint:{x:1}}).itcount(), "Wrong number of documents in partial index, after ttl monitor run"); assert.eq(1,t.find({}).itcount(), "Wrong number of documents in database, after ttl monitor run");
    • Sprint:
      Quint Iteration 3

      Description

      When you create a partial TTL index the TTL Monitor uses the index key to perform the deletes. This results in documents that have the key value, but don't meet the filter criteria (therefore not indexed in the partial index), being deleted.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: