Details
-
Improvement
-
Status: Backlog
-
Major - P3
-
Resolution: Unresolved
-
None
-
None
-
Sharding NYC
-
(copied to CRM)
Description
findAndModify and delete with justOne=true must be targeted to a single shard which they check by extracting a shard key from their query and targeting the chunk that owns that key. This is done through ShardKeyPattern::extractShardKeyFromQuery() which requires a simple query that will exactly match some value, e.g. {skey: 5} or {skey; {$eq: 5}}. More complex queries that don't produce an exact match, but can still be targeted to a single shard are currently rejected.
This could be improved by changing findAndModify and delete to target using ChunkManager::getShardIdsForQuery(), which returns the shards that own ranges that overlap with the shard key index bounds generated by the query (after checking for an exact shard key match first), and throwing if more than one shard is targeted. This is already how an update is targeted by its query .
Attachments
Issue Links
- related to
-
SERVER-61683 Operation findAndModify not possible on hashed sharded collection
-
- Closed
-