[SERVER-14520] Chunks split on $minKey don't work as expected Created: 10/Jul/14  Updated: 10/Dec/14  Resolved: 16/Jul/14

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 2.6.3
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: John Page Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

From shell in mongos with >1 shard added

mongos>sh.enableSharding("ismbtest")
mongos>sh.shardCollection("ismbtest.audit",{region:1,_id:1}) 
mongos>sh.splitAt("ismbtest.audit",{region:"NA",_id:null})
mongos>sh.setBalancerState(false)
mongos>sh.status()

— Sharding Status —

  sharding version: {
	"_id" : 1,
	"version" : 4,
	"minCompatibleVersion" : 4,
	"currentVersion" : 5,
	"clusterId" : ObjectId("53be36b80698700e22a3bb6f")
}
  shards:
	{  "_id" : "shard0000",  "host" : "localhost:27502" }
	{  "_id" : "shard0001",  "host" : "localhost:27503" }
  databases:
	{  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }
	{  "_id" : "test",  "partitioned" : false,  "primary" : "shard0000" }
	{  "_id" : "ismbtest",  "partitioned" : true,  "primary" : "shard0000" }
		ismbtest.audit
			shard key: { "region" : 1, "_id" : 1 }
			chunks:
				shard0001	1
				shard0000	1
			{ "region" : { "$minKey" : 1 }, "_id" : { "$minKey" : 1 } } -->> { "region" : "NA", "_id" : { "$minKey" : 1 } } on : shard0001 Timestamp(2, 0) 
			{ "region" : "NA", "_id" : { "$minKey" : 1 } } -->> { "region" : { "$maxKey" : 1 }, "_id" : { "$maxKey" : 1 } } on : shard0000 Timestamp(2, 1) 
	{  "_id" : "isbmtest",  "partitioned" : false,  "primary" : "shard0001" }

mongos> db.audit.insert({region:"EMEA",_id:"123-456-789-101112",text:"On Emea"})
WriteResult({ "nInserted" : 1 })
mongos> db.audit.insert({region:"NA",_id:"123-456-789-101113",text:"On NA"})
WriteResult({ "nInserted" : 1 })

mongos> db.audit.stats()
{
	"sharded" : true,
	"systemFlags" : 1,
	"userFlags" : 1,
	"ns" : "ismbtest.audit",
	"count" : 2,
	"numExtents" : 2,
	"size" : 224,
	"storageSize" : 16384,
	"totalIndexSize" : 32704,
	"indexSizes" : {
		"_id_" : 16352,
		"region_1__id_1" : 16352
	},
	"avgObjSize" : 112,
	"nindexes" : 2,
	"nchunks" : 2,
	"shards" : {
		"shard0000" : {
			"ns" : "ismbtest.audit",
			"count" : 0,
			"size" : 0,
			"storageSize" : 8192,
			"numExtents" : 1,
			"nindexes" : 2,
			"lastExtentSize" : 8192,
			"paddingFactor" : 1,
			"systemFlags" : 1,
			"userFlags" : 1,
			"totalIndexSize" : 16352,
			"indexSizes" : {
				"_id_" : 8176,
				"region_1__id_1" : 8176
			},
			"ok" : 1
		},
		"shard0001" : {
			"ns" : "ismbtest.audit",
			"count" : 2,
			"size" : 224,
			"avgObjSize" : 112,
			"storageSize" : 8192,
			"numExtents" : 1,
			"nindexes" : 2,
			"lastExtentSize" : 8192,
			"paddingFactor" : 1,
			"systemFlags" : 1,
			"userFlags" : 1,
			"totalIndexSize" : 16352,
			"indexSizes" : {
				"_id_" : 8176,
				"region_1__id_1" : 8176
			},
			"ok" : 1
		}
	},
	"ok" : 1
}

Both went to same shard, it appears that a chunk range of

{ "region" : { "$minKey" : 1 }, "_id" : { "$minKey" : 1 } } -->> { "region" : "NA", "_id" : { "$minKey" : 1 } } on : shard0001 Timestamp(2, 0) 

Somehow includes

{region:"NA","_id:"123-456-789-101113"}

in sorting does minKey not come first?

Participants:

 Description   

I hate to raise bugs that don't work the way 'I expect' as it's probably me that's wrong but here goes.

If I have a compound shard key and when presplitting use {$minKey:1} as the split point it appears to work but then the split is not where I think it is, if I use null instead it works.



 Comments   
Comment by Scott Hernandez (Inactive) [ 10/Jul/14 ]

Please provide a dump of your config db, and the steps you used to split at MinKey (in your example you just split on null).

Generated at Thu Feb 08 03:35:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.