[SERVER-74679] mongos allows for rename of config db collections on config shard Created: 07/Mar/23  Updated: 29/Oct/23  Resolved: 30/Mar/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: James Wahlin Assignee: Wenqin Ye
Resolution: Fixed Votes: 0
Labels: skunkelodeon-odcs
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-74734 After renaming the "config.shards" co... Closed
Assigned Teams:
Sharding NYC
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

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);

Sprint: Sharding NYC 2023-04-03
Participants:

 Description   

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)
		}
	}
}



 Comments   
Comment by Githook User [ 28/Mar/23 ]

Author:

{'name': 'wenqinYe', 'email': 'wenqin908@gmail.com', 'username': 'wenqinYe'}

Message: SERVER-74679: Disallow renameCollection via mongos on config server when catalog shard is enabled
Branch: master
https://github.com/mongodb/mongo/commit/5cd4bfd3ec28d3a4175c8aecad6039fadaf77ad1

Generated at Thu Feb 08 06:28:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.