Resharding Does Not Properly Handle forceRedistribution With Time Series Collections

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Cluster Scalability
    • ALL
    • Hide

      Run the following as a test in the sharding_jscore_passthrough suite:

      const dbName = jsTestName();
      const collName = "coll";
      const ns = `${dbName}.${collName}`;
      const sourceDB = db.getSiblingDB(dbName);
      const sourceCollection = sourceDB.getCollection(collName);
      const shardKeyPattern = {
          "metadata.x": 1,
      };
      const timeseriesInfo = {
          timeField: "ts",
          metaField: "metadata",
      };
      assert.commandWorked(sourceDB.adminCommand({enableSharding: dbName}));
      assert.commandWorked(sourceDB.adminCommand({shardCollection: ns, key: shardKeyPattern, timeseries: timeseriesInfo}));
      assert.commandWorked(sourceDB.adminCommand({reshardCollection: ns, key: shardKeyPattern, forceRedistribution: true}));
      
      Show
      Run the following as a test in the sharding_jscore_passthrough suite: const dbName = jsTestName(); const collName = "coll"; const ns = `${dbName}.${collName}`; const sourceDB = db.getSiblingDB(dbName); const sourceCollection = sourceDB.getCollection(collName); const shardKeyPattern = { "metadata.x": 1, }; const timeseriesInfo = { timeField: "ts", metaField: "metadata", }; assert.commandWorked(sourceDB.adminCommand({enableSharding: dbName})); assert.commandWorked(sourceDB.adminCommand({shardCollection: ns, key: shardKeyPattern, timeseries: timeseriesInfo})); assert.commandWorked(sourceDB.adminCommand({reshardCollection: ns, key: shardKeyPattern, forceRedistribution: true}));
    • Cluster Scalability Priorities
    • 1
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Attempting to reshard a time series collection using forceRedistribution: true will result in the following error, even with the correct shard key:

      {
      	"ok" : 0,
      	"errmsg" : "The new shard key must be the same as the original shard key when using the forceRedistribution option. The forceRedistribution option is meant for redistributing the collection to a different set of shards.",
      	"code" : 72,
      	"codeName" : "InvalidOptions",
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1758732800, 4),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	},
      	"operationTime" : Timestamp(1758732800, 4)
      }
      

      This is from here and appears to be related to how resharding handles the name of the metadata field for the timeseries collection:

      "svc":"S", "ctx":"ShardingDDLCoordinator-1","msg":"bnawrocki","attr":{"cmOldPattern":{"meta.x":1},"docKey":{"metadata.x":1},"isShardKey":false}}
      

      This appears similar to the issue seen in SERVER-84180.

      The only way to work around this issue is ensure that "meta" is used as the name for the metadata field for the time series collection.

            Assignee:
            Unassigned
            Reporter:
            Brett Nawrocki
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: