[SERVER-74097] Sharded find with expected collection UUID does not handle all cases of concurrent DDL operations Created: 16/Feb/23  Updated: 29/Oct/23  Resolved: 17/Feb/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.0.0-rc0, 6.0.5, 6.3.0-rc1

Type: Bug Priority: Major - P3
Reporter: Gregory Noma Assignee: Gregory Noma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.3, v6.0
Sprint: Execution Team 2023-02-20, Execution Team 2023-03-06
Participants:
Linked BF Score: 129

 Description   

When running a find command on a sharded collection with collectionUUID parameter, there is some special logic in the case where we don't target the primary shard but got a CollectionUUIDMismatch error without an actualCollection. In this case, we go to the primary shard in case the actualCollection is unsharded and thus only exists on that shard. The current logic expects that going to the primary shard will always throw an error (CollectionUUIDMismatch, StaleShardVersion, or StaleDbVersion), however it turns out this is not always the case and it is possible for no error to be thrown. Consider a concurrent collection drop on the collection that is being queried; it will executed in three steps:

  1. Remove entry from config.collections
  2. Perform local dropCollection on all non-primary shards
  3. Perform local dropCollection on the primary shard

If we go to the primary shard between steps 2 and 3, that shard will still have the collection despite not getting a stale version error.



 Comments   
Comment by Githook User [ 21/Feb/23 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-74097 Populate `CollectionUUIDMismatch` via `listCollections` for sharded find
Branch: v6.0
https://github.com/mongodb/mongo/commit/5a85ba8e15a9f0968c2307e35aefc8c259bc7151

Comment by Githook User [ 21/Feb/23 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-74097 Populate `CollectionUUIDMismatch` via `listCollections` for sharded find

(cherry picked from commit 4c670108b0aa1f5903ddb0c4e74ab0cee518b151)
Branch: v6.3
https://github.com/mongodb/mongo/commit/3dfde12941d33555ee44d935f5d55fd143d41801

Comment by Githook User [ 17/Feb/23 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-74097 Populate `CollectionUUIDMismatch` via `listCollections` for sharded find
Branch: master
https://github.com/mongodb/mongo/commit/4c670108b0aa1f5903ddb0c4e74ab0cee518b151

Generated at Thu Feb 08 06:26:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.