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

cleanupOrphaned does nothing on empty shard

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.5.2
    • Fix Version/s: 2.5.5
    • Component/s: Sharding
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

       
      var st = new ShardingTest({
          other: {
              rs: true,
              rsOptions: {nodes: 2}
          }
      });
       
      st.stopBalancer();
       
      var mongos = st.s0;
      var mongosAdmin = mongos.getDB('admin');
      var dbName = 'foo';
      var collectionName = 'bar';
      var ns = dbName + '.' + collectionName;
      var coll = mongos.getCollection(ns);
       
      assert.commandWorked(mongosAdmin.runCommand({
          enableSharding: coll.getDB().getName()
      }));
       
      assert.commandWorked(mongosAdmin.runCommand({
          shardCollection: ns,
          key: {_id: 1}
      }));
       
      // Collection's home is shard1, there are no chunks assigned to shard0.
      st.printShardingStatus();
      st.shard0.getCollection(ns).insert({});
      assert.eq(null, st.shard0.getDB(dbName).getLastError());
      assert.eq(1, st.shard0.getCollection(ns).count());
      jsTest.log('Running cleanupOrphaned on ' + st.shard0);
      response = st.shard0.getDB('admin').runCommand({cleanupOrphaned: ns});
      assert.commandWorked(response);
      assert.eq(null, response.stoppedAtKey);
      assert.eq(
          0, st.shard0.getCollection(ns).count(),
          "cleanupOrphaned didn't delete orphan on empty shard.");

      Show
        var st = new ShardingTest({ other: { rs: true, rsOptions: {nodes: 2} } });   st.stopBalancer();   var mongos = st.s0; var mongosAdmin = mongos.getDB('admin'); var dbName = 'foo'; var collectionName = 'bar'; var ns = dbName + '.' + collectionName; var coll = mongos.getCollection(ns);   assert.commandWorked(mongosAdmin.runCommand({ enableSharding: coll.getDB().getName() }));   assert.commandWorked(mongosAdmin.runCommand({ shardCollection: ns, key: {_id: 1} }));   // Collection's home is shard1, there are no chunks assigned to shard0. st.printShardingStatus(); st.shard0.getCollection(ns).insert({}); assert.eq(null, st.shard0.getDB(dbName).getLastError()); assert.eq(1, st.shard0.getCollection(ns).count()); jsTest.log('Running cleanupOrphaned on ' + st.shard0); response = st.shard0.getDB('admin').runCommand({cleanupOrphaned: ns}); assert.commandWorked(response); assert.eq(null, response.stoppedAtKey); assert.eq( 0, st.shard0.getCollection(ns).count(), "cleanupOrphaned didn't delete orphan on empty shard.");

      Description

      On a shard with no chunks assigned to it for a sharded collection, I expect cleanupOrphaned to remove any document in that collection. But in fact cleanupOrphaned returns without removing anything.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: