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

Compact with WiredTiger does not rebuild indexes

    • Fully Compatible
    • ALL
    • Hide
      var coll = db.foo;
      coll.drop();
      
      coll.insert({_id: 1});
      assert.neq(null, coll.findOne({_id: 1}));
      
      var res = coll.runCommand({compact: coll.getName()});
      assert.commandWorked(res, tojson(res));
      
      // this assert fails because findOne returns null
      assert.neq(null, coll.findOne({_id: 1}));
      
      // run validate to see index keys: { "test.foo.$_id_" : 0 }
      res = coll.runCommand({validate: coll.getName(), full: true});
      printjson(res.keysPerIndex);
      
      Show
      var coll = db.foo; coll.drop(); coll.insert({_id: 1}); assert .neq( null , coll.findOne({_id: 1})); var res = coll.runCommand({compact: coll.getName()}); assert .commandWorked(res, tojson(res)); // this assert fails because findOne returns null assert .neq( null , coll.findOne({_id: 1})); // run validate to see index keys: { "test.foo.$_id_" : 0 } res = coll.runCommand({validate: coll.getName(), full: true }); printjson(res.keysPerIndex);

      Compacting a WiredTiger collection removes or corrupts index keys, which leads to failed queries.


      Version: b0014456ddef

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            kamran.khan Kamran K.
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: