cleanupOrphaned doesn't verify startingFromKey matches shard key spec

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • 2.5.4
    • Affects Version/s: 2.5.2
    • Component/s: Sharding
    • None
    • ALL
    • Hide
      var st = new ShardingTest({
          other: {
              rs: true,
              rsOptions: {nodes: 2}
          }
      });
      
      var mongos = st.s0;
      var coll = mongos.getCollection('foo.bar');
      var shardAdmin = st.shard0.getDB('admin');
      
      mongosAdmin.runCommand({
          enableSharding: coll.getDB().getName()
      });
      
      mongosAdmin.runCommand({
          shardCollection: coll.getFullName(),
          key: {_id: 1}
      });
      
      // Doesn't match number of keys.
      assert.commandFailed(shardAdmin.runCommand({
          cleanupOrphaned: coll.getFullName(),
          startingFromKey: {someKey: 'someValue', someOtherKey: 1}
      }));
      
      // Matches number of keys but not key name. This will succeed but should fail.
      assert.commandFailed(shardAdmin.runCommand({
          cleanupOrphaned: coll.getFullName(),
          startingFromKey: {someKey: 'someValue'}
      }));
      
      Show
      var st = new ShardingTest({ other: { rs: true , rsOptions: {nodes: 2} } }); var mongos = st.s0; var coll = mongos.getCollection( 'foo.bar' ); var shardAdmin = st.shard0.getDB( 'admin' ); mongosAdmin.runCommand({ enableSharding: coll.getDB().getName() }); mongosAdmin.runCommand({ shardCollection: coll.getFullName(), key: {_id: 1} }); // Doesn't match number of keys. assert .commandFailed(shardAdmin.runCommand({ cleanupOrphaned: coll.getFullName(), startingFromKey: {someKey: 'someValue' , someOtherKey: 1} })); // Matches number of keys but not key name. This will succeed but should fail. assert .commandFailed(shardAdmin.runCommand({ cleanupOrphaned: coll.getFullName(), startingFromKey: {someKey: 'someValue' } }));
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The cleanupOrphaned command only checks that the startingFromKey parameter has the same number of fields as the shard key, not that the fields match.

              Assignee:
              Greg Studer (Inactive)
              Reporter:
              A. Jesse Jiryu Davis
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: