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

mongos allows for rename of config db collections on config shard

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Sharding NYC
    • Fully Compatible
    • ALL
    • Hide

      The following succeeds on config-shard and fails on a CSRS configuration:

      use test;
      sh.enableSharding("test");
      sh.shardCollection("test.test", {_id: "hashed"});
      use config;
      assert.gte(db.shards.count(), 1);
      assert.commandWorked(db.shards.renameCollection("foo"));
      assert.eq(db.shards.count(), 0);
      
      Show
      The following succeeds on config-shard and fails on a CSRS configuration: use test; sh.enableSharding( "test" ); sh.shardCollection( "test.test" , {_id: "hashed" }); use config; assert .gte(db.shards.count(), 1); assert .commandWorked(db.shards.renameCollection( "foo" )); assert .eq(db.shards.count(), 0);
    • Sharding NYC 2023-04-03

      On a cluster with a config-server replica set, we ban operations from mongos that would drop, rename or overwrite config database internal collections.  This includes via drop command, renameCollection command and $out aggregation stage.

      When running a cluster with a config-shard configuration, drop and $out are blocked, but renameCollection is allowed, and can be used to rename collections like config.chunks and config.shards.

      It appears that the gating factor for this command on CSRS is whether the process is started with --shardsvr:

      uncaught exception: Error: command failed: {
      	"ok" : 0,
      	"errmsg" : "Cannot accept sharding commands if not started with --shardsvr",
      	"code" : 193,
      	"codeName" : "NoShardingEnabled",
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1678213485, 33),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	},
      	"operationTime" : Timestamp(1678213485, 33)
      } with original command request: {
      	"renameCollection" : "config.shards",
      	"to" : "config.foo",
      	"dropTarget" : false,
      	"lsid" : {
      		"id" : UUID("54900959-4b38-4e91-a349-a45c3d0002c9")
      	},
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1678213485, 33),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      

            Assignee:
            wenqin.ye@mongodb.com Wenqin Ye
            Reporter:
            james.wahlin@mongodb.com James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: