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

keyUpdates not set on MMAPv1 document move

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.3.2
    • Component/s: Diagnostics, Querying
    • Labels:
      None
    • Query
    • Fully Compatible
    • ALL
    • Hide
      var getLatestProfileDoc = function() {
          return db.system.profile.find().sort({ts: -1}).limit(1).next();
      }
      
      // Confirm test is run against MMAPv1
      use admin;
      assert.eq(db.runCommand({ getCmdLineOpts: 1 }).parsed.storage.engine, "mmapv1");
      
      
      db.test.drop();
      db.test.ensureIndex({a: 1});
      
      db.test.insert({a: 1, b: 1});
      
      // In place document update
      db.setProfilingLevel(2);
      db.test.update({}, {$inc: {a: 1}});
      db.setProfilingLevel(0);
      var profileDoc = getLatestProfileDoc();
      assert(!profileDoc.nmoved);
      assert.eq(profileDoc.keyUpdates, 1, tojson(profileDoc)); 
      
      // Update that triggers document move
      db.setProfilingLevel(2);
      db.test.update({}, {$inc: {a: 1}, $set: {c: Array(1024).toString()}});
      db.setProfilingLevel(0);
      var profileDoc = getLatestProfileDoc();
      assert.eq(profileDoc.nmoved, 1, tojson(profileDoc));
      assert.eq(profileDoc.keyUpdates, 1, tojson(profileDoc));
      
      Show
      var getLatestProfileDoc = function() { return db.system.profile.find().sort({ts: -1}).limit(1).next(); } // Confirm test is run against MMAPv1 use admin; assert .eq(db.runCommand({ getCmdLineOpts: 1 }).parsed.storage.engine, "mmapv1" ); db.test.drop(); db.test.ensureIndex({a: 1}); db.test.insert({a: 1, b: 1}); // In place document update db.setProfilingLevel(2); db.test.update({}, {$inc: {a: 1}}); db.setProfilingLevel(0); var profileDoc = getLatestProfileDoc(); assert (!profileDoc.nmoved); assert .eq(profileDoc.keyUpdates, 1, tojson(profileDoc)); // Update that triggers document move db.setProfilingLevel(2); db.test.update({}, {$inc: {a: 1}, $set: {c: Array(1024).toString()}}); db.setProfilingLevel(0); var profileDoc = getLatestProfileDoc(); assert .eq(profileDoc.nmoved, 1, tojson(profileDoc)); assert .eq(profileDoc.keyUpdates, 1, tojson(profileDoc));

      CurOp.OpDebug contains a "keyUpdates" metric that is meant to track the # of index changes for a given document update. For the MMAPv1 storage engine, keyUpdates is only updated when a document is updated in place and not when a document has to be moved on disk. This metric should include key updates on document move.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            james.wahlin@mongodb.com James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: