[SERVER-38207] Cannot insert document with MaxKey shard key Created: 19/Nov/18  Updated: 01/Sep/23

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: 4.1.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Randolph Tan Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: open_todo_in_code, query-product-scope-1, query-product-urgency-3, query-product-value-3
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-67529 Resharding silently skips documents w... Closed
Assigned Teams:
Query Execution
Operating System: ALL
Participants:

 Description   

mongos> db.adminCommand({ enableSharding: 'test' })
mongos> db.adminCommand({ shardCollection: 'test.user', key: { x: 1 }})
mongos> db.user.insert({ x: MaxKey })
WriteCommandError({
	"ok" : 0,
	"errmsg" : "Cannot target single shard using key { x: MaxKey }",
	"code" : 61,
	"codeName" : "ShardKeyNotFound",
	"operationTime" : Timestamp(1542658417, 1),
	"$clusterTime" : {
		"clusterTime" : Timestamp(1542658417, 1),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	}
})

This could be a potential edge case where { x: MaxKey } was inserted before collection was sharded and it would practically be invisible to the sharded cluster (since chunk upper bound is exclusive and migrations and versioned queries will ignore it).



 Comments   
Comment by Brenda Rodriguez [ 23/Aug/22 ]

christopher.harris@mongodb.com can we close this? Thanks!

Comment by Ana Meza [ 16/Aug/22 ]

Hi christopher.harris@mongodb.com did you get a chance to look at this one?

Comment by Ana Meza [ 05/Jul/22 ]

Passing to the Query Product team to advise on whether we need to fix it tor not

Comment by Kaloian Manassiev [ 30/Jun/22 ]

The decision after sharding/product team meeting was that we should fix the sharding targeting (ChunkManager/ChunkManagerTargeter) so that it can find shard keys that contain MaxKey. This part is owned by the Query Execution team, so assigning it there.

Comment by Randolph Tan [ 20/Nov/18 ]

Yes, MinKey works fine.

Comment by Kaloian Manassiev [ 20/Nov/18 ]

And I presume Minkey works, right? I guess it should be enough to fix this in the ChunkManager targeting only (the filtering should then just work).

Generated at Thu Feb 08 04:48:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.