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

Prohibit running $backupCursor/$backupCursorExtend on an aggregation against a collection

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.0-rc0, 4.4.18
    • Affects Version/s: None
    • Component/s: None
    • None
    • Minor Change
    • ALL
    • v4.4
    • Hide
      (function() {
      "use strict";
      
      const numNodes = 1;
      const rst = new ReplSetTest({
          nodes: numNodes,
          nodeOptions: {
              setParameter: {logComponentVerbosity: tojson({command: 2})},
          }
      });
      rst.startSet();
      rst.initiateWithNodeZeroAsPrimary()
      
      const dbName = "test";
      const collName = "foo";
      
      const db = rst.getPrimary().getDB(dbName);
      
      assert.commandWorked(db.getCollection(collName).insert({}));
      let cursor = db.getCollection(collName).aggregate([{$backupCursor: {}}]);  // crash.
      cursor.close();
      cursor = db.aggregate([{$backupCursor: {}}]);  // ok.
      cursor.close();
      
      rst.stopSet();
      }());
      
      Show
      (function() { "use strict" ; const numNodes = 1; const rst = new ReplSetTest({ nodes: numNodes, nodeOptions: { setParameter: {logComponentVerbosity: tojson({command: 2})}, } }); rst.startSet(); rst.initiateWithNodeZeroAsPrimary() const dbName = "test" ; const collName = "foo" ; const db = rst.getPrimary().getDB(dbName); assert .commandWorked(db.getCollection(collName).insert({})); let cursor = db.getCollection(collName).aggregate([{$backupCursor: {}}]); // crash. cursor.close(); cursor = db.aggregate([{$backupCursor: {}}]); // ok. cursor.close(); rst.stopSet(); }());
    • Execution Team 2021-05-03
    • 133

      When running a $backupCursor aggregation against a collection, we execute this code path. This path locks the collection the aggregation was executed against and opens a storage transaction using the lock-free reads AutoGetCollection helper.

      However, when running a collection-less $backupCursor aggregation, we execute this code path and we don't lock any collection. This is the documented way of opening a backup cursor.

       

      Collection-less aggregation example:

      db.aggregate([{$backupCursor: {}}]);
      

       

      Aggregration against a collection example:

      db.getCollection("...").aggregate([{$backupCursor: {}}]);
      

            Assignee:
            gregory.wlodarek@mongodb.com Gregory Wlodarek
            Reporter:
            gregory.wlodarek@mongodb.com Gregory Wlodarek
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: