[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:
Related
related to SERVER-73751 movePrimary shouldn't create indexes ... Closed
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 SERVER-73751.

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 SERVER-73751, this scenario is no longer possible, since the indexes will only be created for empty unsharded collections on the recipient. This check ensures that no unsharded collections exist on the intended recipient before the cloning procedure begins and so creating indexes on an non-empty unsharded collection is not possible.

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