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

ndeleted:0 is logged/profiled when the number of deleted documents is not known

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.0.6
    • Affects Version/s: None
    • Component/s: Logging, Write Ops
    • Query
    • Fully Compatible
    • ALL
    • Hide

      Run this from one shell:

      (function() {
          "use strict";
      
          db.c.drop();
          for (let i = 0; i < 100; i++) {
              assert.commandWorked(db.c.insert({a: 1}));
          }
          assert.commandWorked(db.c.createIndex({a: 1}));
      
          assert.commandWorked(db.setLogLevel(1));
      
          db.c.remove({$where: "sleep(1000);", a: 1});
      }());
      

      Then use db.currentOp() and db.killOp() to kill the multi-delete operation from another shell.

      Show
      Run this from one shell: (function() { "use strict"; db.c.drop(); for (let i = 0; i < 100; i++) { assert.commandWorked(db.c.insert({a: 1})); } assert.commandWorked(db.c.createIndex({a: 1})); assert.commandWorked(db.setLogLevel(1)); db.c.remove({$where: "sleep(1000);", a: 1}); }()); Then use db.currentOp() and db.killOp() to kill the multi-delete operation from another shell.
    • Query 2018-12-17, Query 2018-12-31

      The ndeleted stat is filled out twice. First, we set it to zero at the beginning of a delete op:

      https://github.com/mongodb/mongo/blob/9f54046049edc156b38bacb3d4d7d78b60ab213b/src/mongo/db/ops/write_ops_exec.cpp#L740

      Then, we set it to the actual number of deleted documents at the end:

      https://github.com/mongodb/mongo/blob/9f54046049edc156b38bacb3d4d7d78b60ab213b/src/mongo/db/ops/write_ops_exec.cpp#L780

      Setting the statistic to zero has the adverse consequence of causing the system to log/profile ndeleted:0 when the actual number of deleted documents is unknown. I believe this line of code is superfluous and can be removed.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: