[SERVER-42242] Acquire locks by collection UUID during the createIndexes command Created: 15/Jul/19 Updated: 29/Oct/23 Resolved: 29/Jul/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Storage |
| Affects Version/s: | None |
| Fix Version/s: | 4.3.1 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Daniel Solnik (Inactive) | Assignee: | Daniel Solnik (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||
| Sprint: | Execution Team 2019-07-15, Execution Team 2019-07-29 | ||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Linked BF Score: | 15 | ||||||||||||||||||||
| Description |
|
In the past, when a collection lock is dropped during an index build, there was no chance that the name of the collection would change. Because of this, createIndexes could be sure that for the entire lifetime of the function the name of the collection wouldn't change. However, SERVER 37720 will allow renameCollection during index builds. This will no longer allow us to be sure that the name of the collection stays the same for the duration of the function. To fix this, first get a collection X lock on the collection based on the namespace provided by the createIndexes request, fetch the collection UUID under a lock, then use AutoGetCollection to acquire the collection lock by UUID for the remainder of the createIndexes operation. For the remainder of the function, locks of the collection should be done using AutoGetCollection to lock the collection given the UUID. |
| Comments |
| Comment by Githook User [ 29/Jul/19 ] |
|
Author: {'name': 'Daniel Solnik', 'username': 'Dsolnik', 'email': 'dansolnik@gmail.com'}Message: |
| Comment by Benety Goh [ 17/Jul/19 ] |
|
dianna.hohensee, dan.solnik, I'm actively working on the IndexBuildsCoordinator. Please limit the scope of this ticket to the runCreateIndexes() function in create_indexes.cpp. Thank you. |
| Comment by Dianna Hohensee (Inactive) [ 15/Jul/19 ] |
|
benety.goh, an FYI since this will touch code you're working on. |
| Comment by Dianna Hohensee (Inactive) [ 15/Jul/19 ] |
|
There is currently another parallel path being built for the createIndexes command – part of another ongoing project. You'll need to update this code, too (it does the same thing as the regular createIndexes code): https://github.com/mongodb/mongo/blob/b7cec5064fb03f1e1f9bd39af35e495facfdcdc9/src/mongo/db/index_builds_coordinator.cpp#L862. I don't actually see why we'd need to keep passing the Collection/CollectionLock into the function, actually, or take an X lock and immediately relock to IX, so if nothing bad happens pull that stuff out, too. |