Hi All,
I am trying to create a sharded time series collection and add updateZoneKeyRange as below
db.createCollection( "test_timeseries", {
timeseries: {
timeField: "timeStamp",
metaField: "metaData",
granularity: "seconds"
},
expireAfterSeconds: 604800
});
db.adminCommand({ shardCollection: "test.test_timeseries", key: { "metaData.location": 1 } });
db.adminCommand({ updateZoneKeyRange: "test.test_timeseries", min: { "metaData.location": 11 }, max: { "metaData.location": 20 }, zone: "rs1" });
db.adminCommand({ updateZoneKeyRange: "test.test_timeseries", min: { "metaData.location": 1 }, max: { "metaData.location": 10 }, zone: "rs2" });
But the time series collection “test_timeseries” is getting created only on rs1 shard. Also, documents inserted to “test_timeseries” collection are getting inserted into only rs1 irrespective of metaData.location value.
If I execute same commands for regular collection as below
db.createCollection( "test_regular"});
db.adminCommand({ shardCollection: "test.test_regular", key: { "metaData.location": 1 } });
db.adminCommand({ updateZoneKeyRange: "test.test_regular", min: { "metaData.location": 11 }, max: { "metaData.location": 20 }, zone: "rs1" });
db.adminCommand({ updateZoneKeyRange: "test.test_regular", min: { "metaData.location": 1 }, max: { "metaData.location": 10 }, zone: "rs2" });
Here, for regular collection, “test_regular” collection is getting created on rs1 as well as rs2. Also, documents inserted to “test_regular” collection are getting inserted into rs1 and rs2 shards based on the metaData.location.
Mongodb version:5.0.17
Does updateZoneKeyRange works with Time Series Collection In Mongodb? What is wrong here?
CC: @Kushagra_Kesav
Thanks in advance.