[SERVER-38285] Only acquire database X-lock on the recipient if the collection does not exist Created: 28/Nov/18 Updated: 29/Oct/23 Resolved: 11/Jan/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | None |
| Fix Version/s: | 4.1.7 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Kaloian Manassiev | Assignee: | Kim Tao |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Sprint: | Sharding 2018-12-17, Sharding 2018-12-31, Sharding 2019-01-14 |
| Participants: |
| Description |
|
The chunk migration logic on the recipient side unconditionally acquires database X-lock acquisition at migration start in order to copy the collection indexes and options from the donor. Similarly to the donor side, this lock acquisition can block behind active transactions and lead to stalls. However, what makes them worse than the donor is that while these lock requests are waiting to be granted, the recipient is not making any progress cloning the chunk. This in turn has the potential to cause buildup of xferMods on the donor side, leading to high memory utilization and/or increased duration of the migration. Because of this, the MigrationDestinationManager should first use AutoGetCollection with MODE_IX lock to check whether the collection exists and only if it doesn't exist should it resort to MODE_X database lock. |
| Comments |
| Comment by Githook User [ 11/Jan/19 ] |
|
Author: {'username': 'Kimchelly', 'email': 'kimberly.tao@mongodb.com', 'name': 'Kim Tao'}Message: |
| Comment by Kaloian Manassiev [ 29/Nov/18 ] |
|
Yeah, the "auto-healing" is only for completely empty collections so I don't think it is worth keeping it given the complexity. |
| Comment by Esha Maharishi (Inactive) [ 29/Nov/18 ] |
|
kaloian.manassiev, with this, will this block that creates the indexes on the recipient be moved into the if (!collection) branch? If so, that means we will remove the "auto-healing indexes" behavior, but that behavior only applied if the recipient had no documents for the collection, so I don't think it's much of a loss and it sounds good to me. |