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

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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.3
    • Affects Version/s: 3.1.1
    • Component/s: Index Maintenance
    • Fully Compatible
    • ALL
    • 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" );
    • Quint Iteration 3

      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.

            Assignee:
            rassi J Rassi
            Reporter:
            michael.grundy Michael Grundy
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: