[SERVER-73665] Cloner::copyDb should handle the scenario where a collection already exists before calling IndexBuildsCoordinator::createIndexesOnEmptyCollection and hitting an invariant Created: 06/Feb/23 Updated: 11/Apr/23 Resolved: 27/Mar/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Dianna Hohensee (Inactive) | Assignee: | Nandini Bhartiya |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | sharding-nyc-subteam1 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Sharding NYC
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Linked BF Score: | 9 | ||||||||
| Description |
|
I don't see any obvious checks done in the Cloner code before calling createIndexesOnEmptyCollection, which may hit an invariant if the collection exists. Cloner should error and log more information in such scenarios. |
| Comments |
| Comment by Nandini Bhartiya [ 11/Apr/23 ] |
|
dianna.hohensee@mongodb.com on closer examination, there is a check in the cloner logic to ensure the unsharded collection does not exist before cloning, which in turn ensures that indexes will only be created on for newly created empty unshared collections. |
| Comment by Dianna Hohensee (Inactive) [ 29/Mar/23 ] |
|
nandini.bhartiya@mongodb.com Could we still have a check in the cloner code that the collection is empty before calling createIndexesOnEmptyCollection? That would be a clearer indication of the issue if the scenario returns in future. The code is fragile. |
| Comment by Nandini Bhartiya [ 27/Mar/23 ] |
|
The issue has been fixed by |
| Comment by Nandini Bhartiya [ 27/Mar/23 ] |
|
The only scenario where an index could be created on a non-empty collection by the Cloner::copyDB() method was if collection was sharded and already existed (with documents) on the intended recipient of a movePrimary operation. With sergi.mateo-bellido@mongodb.com's fix for |