MongoDB’s db.printShardingStatus command, when run from a mongos process, prints some json corresponding to the current state of accessible partitioned databases.
e.g.
--- Sharding Status ---
sharding version: { "_id" : 1, "version" : 3 }
shards:
{ "_id" : "rs_a", "host" : "rs_a/host1:27018,host2:27018" }
{ "_id" : "rs_b", "host" : "rs_b/host3:27018,host4:27018" }
databases:
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "test", "partitioned" : false, "primary" : "rs_a" }
{ "_id" : "users", "partitioned" : true, "primary" : "rs_a" }
database.Coll chunks:
rs_b 4
rs_a 6
{ "scope" : { $minKey : 1 } } -->> { "scope" : "0014669e-d4b0-45e8-b4ee-0f5de07f86d5" } on : rs_b { "t" : 2000, "i" : 0 }
{ "scope" : "0014669e-d4b0-45e8-b4ee-0f5de07f86d5" } -->> { "scope" : "02726c5a-5f2c-4d6e-b124-b258aabcd3a0" } on : rs_b { "t" : 3000, "i" : 0 }
{ "scope" : "02726c5a-5f2c-4d6e-b124-b258aabcd3a0" } -->> { "scope" : "0275fb19-7cec-4dfc-9150-97ceab4f23b5" } on : rs_b { "t" : 4000, "i" : 0 }
{ "scope" : "0275fb19-7cec-4dfc-9150-97ceab4f23b5" } -->> { "scope" : "0847aae5-c41b-4470-8a9f-de90f2cb2c1e" } on : rs_b { "t" : 5000, "i" : 0 }
{ "scope" : "0847aae5-c41b-4470-8a9f-de90f2cb2c1e" } -->> { "scope" : "084e756f-c4b0-4569-bb1e-37d7220b30c9" } on : rs_a { "t" : 5000, "i" : 1 }
{ "scope" : "084e756f-c4b0-4569-bb1e-37d7220b30c9" } -->> { "scope" : "0894dd26-6b6f-4382-bdbd-d05199e913b9" } on : rs_a { "t" : 1000, "i" : 13 }
{ "scope" : "0894dd26-6b6f-4382-bdbd-d05199e913b9" } -->> { "scope" : "08d0ffcb-c273-4bb7-8951-5f19e95b2fe4" } on : rs_a { "t" : 5000, "i" : 2 }
{ "scope" : "08d0ffcb-c273-4bb7-8951-5f19e95b2fe4" } -->> { "scope" : "102282f1-9049-4a47-ac06-07d62399dd60" } on : rs_a { "t" : 5000, "i" : 4 }
{ "scope" : "102282f1-9049-4a47-ac06-07d62399dd60" } -->> { "scope" : "ffe9ada1-367d-4358-ac98-d21a7194ee5f" } on : rs_a { "t" : 5000, "i" : 5 }
{ "scope" : "ffe9ada1-367d-4358-ac98-d21a7194ee5f" } -->> { "scope" : { $maxKey : 1 } } on : rs_a { "t" : 1000, "i" : 4 }
I’m specifically curious about what the { "t" : 5000, "i" : 4 } values mean for each chunk. I cannot find any official documentation.
The “t” and “i” values are the major and minor version of the chunk. “t” gets increased if the chunk is moved manually or by the balancer. At that point “i” will be reset to “0”. “i” will be increased if the chunk is split.
The fact that your “t” is a timestamp like value is probably MongoDB trying to give it a value that it knows is functionally correct (max across cluster). I’ve never seen such a value for “t” in production environments. (EDIT <– speculation)
By popular request the relevant bits of code in the server and complete explanation of why it looks the way it looks :
https://github.com/mongodb/mongo/blob/master/s/util.h (ShardChunkVersion)
https://github.com/mongodb/mongo/blob/master/s/d_split.cpp (line 709 onwards)
https://github.com/mongodb/mongo/blob/master/s/d_migrate.cpp (line 963 onwards)
Major and minor versions are integers. “t” looks like it’s converted to/pushed in as a timestamp on output hence the multiplication by 1000 (https://github.com/mongodb/mongo/blob/master/bson/bsonelement.h line 357)