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

Able to rename drop-pending collection namespaces using applyOps command

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Replication
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

       
      load("jstests/libs/check_log.js");  // For 'checkLog'.
      function pauseOplogApplication(node) {
          assert.commandWorked(node.adminCommand(
              {configureFailPoint: "rsSyncApplyStop", mode: "alwaysOn"}));
          checkLog.contains(node, "rsSyncApplyStop fail point enabled");
      }
       
      function resumeOplogApplication(node) {
          assert.commandWorked(
              node.adminCommand({configureFailPoint: "rsSyncApplyStop", mode: "off"}));
      }
       
      function listAllCollections(adb){
          let res = assert.commandWorked(adb.runCommand("listCollections", {includePendingDrops: true}));
          return tojson(res.cursor.firstBatch);
      }
       
      let replTest = new ReplSetTest({name: "applyOpsTest", nodes: 2});
       
      replTest.startSet();
      replTest.initiate();
      replTest.awaitReplication();
       
      // Pause oplog application so collection drop doesn't commit.
      pauseOplogApplication(replTest.getSecondary());
       
      // Get connections and collection.
      let primary = replTest.getPrimary();
      let pdb = primary.getDB("test");
      let collName = "coll";
       
      // Create collection.
      pdb[collName].insert({x:1});
       
      let uuid = pdb.getCollectionInfos()[0].info.uuid;
       
      // Drop collection.
      jsTestLog("Doing collection drop.");
      assert.commandWorked(pdb.runCommand({drop: collName, writeConcern: {w: 1}}));
       
      // Print collections after drop.
      jsTestLog(listAllCollections(pdb));
       
      let renameOp = [{
          "op": "c",
          "ns": "test.$cmd",
          "ui": uuid,
          "o": {"renameCollection": "", "to": "test.not_drop_pending"}
      }];
       
      jsTestLog("Doing 'applyOps' command.");
      assert.commandWorked(pdb.adminCommand({applyOps: renameOp}));
       
      // Print collections after renameCollection.
      jsTestLog(listAllCollections(pdb));
      

      Show
        load( "jstests/libs/check_log.js" ); // For 'checkLog'. function pauseOplogApplication(node) { assert.commandWorked(node.adminCommand( {configureFailPoint: "rsSyncApplyStop" , mode: "alwaysOn" })); checkLog.contains(node, "rsSyncApplyStop fail point enabled" ); }   function resumeOplogApplication(node) { assert.commandWorked( node.adminCommand({configureFailPoint: "rsSyncApplyStop" , mode: "off" })); }   function listAllCollections(adb){ let res = assert.commandWorked(adb.runCommand( "listCollections" , {includePendingDrops: true })); return tojson(res.cursor.firstBatch); }   let replTest = new ReplSetTest({name: "applyOpsTest" , nodes: 2});   replTest.startSet(); replTest.initiate(); replTest.awaitReplication();   // Pause oplog application so collection drop doesn't commit. pauseOplogApplication(replTest.getSecondary());   // Get connections and collection. let primary = replTest.getPrimary(); let pdb = primary.getDB( "test" ); let collName = "coll" ;   // Create collection. pdb[collName].insert({x:1});   let uuid = pdb.getCollectionInfos()[0].info.uuid;   // Drop collection. jsTestLog( "Doing collection drop." ); assert.commandWorked(pdb.runCommand({drop: collName, writeConcern: {w: 1}}));   // Print collections after drop. jsTestLog(listAllCollections(pdb));   let renameOp = [{ "op" : "c" , "ns" : "test.$cmd" , "ui" : uuid, "o" : { "renameCollection" : "" , "to" : "test.not_drop_pending" } }];   jsTestLog( "Doing 'applyOps' command." ); assert.commandWorked(pdb.adminCommand({applyOps: renameOp}));   // Print collections after renameCollection. jsTestLog(listAllCollections(pdb));
    • Linked BF Score:
      0

      Description

      By executing a renameCollection operation via the applyOps command, and specifying a specific collection UUID for a drop-pending collection, it is possible to rename a drop-pending collection namespace to an arbitrary value. See repro script. I expect this may cause us to never clean up such a drop-pending collection, if it was renamed away from its proper namespace format.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-repl Backlog - Replication Team
              Reporter:
              william.schultz William Schultz (Inactive)
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: