[SERVER-70832] Don't take DB lock in MODE_X when installing new sharding database metadata Created: 25/Oct/22 Updated: 08/Nov/23 Resolved: 30/Jan/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | 6.1.1, 6.2.0-rc6 |
| Fix Version/s: | 6.3.0-rc0 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Jordi Serra Torrens | Assignee: | Antonio Fuschetto |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | shardingemea-qw | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||
| Backport Requested: |
v6.0, v5.0, v4.4
|
||||||||||||||||||||||||
| Sprint: | Sharding EMEA 2022-11-28, Sharding EMEA 2022-12-12, Sharding EMEA 2022-12-26, Sharding EMEA 2023-01-09, Sharding EMEA 2023-01-23, Sharding EMEA 2023-02-06 | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||||||
| Story Points: | 3.33 | ||||||||||||||||||||||||
| Description |
|
Database metadata refresh should not take the database lock in MODE_X. Instead, we should be able to do it under MODE_IX. This prevents database metadata refreshes from blocking behind ongoing transactions. This is similar to what |
| Comments |
| Comment by Githook User [ 30/Jan/23 ] |
|
Author: {'name': 'Antonio Fuschetto', 'email': 'antonio.fuschetto@mongodb.com', 'username': 'afuschetto'}Message: |
| Comment by Antonio Fuschetto [ 02/Dec/22 ] |
|
This change is not trivial as initially assumed and would cause at least one race condition. Relaxing the lock on database when the metadata is set from X mode to IX mode, the AutoGetDb constructor is exposed to a race condition with the thread that refreshes the database metadata. The sequence of events triggering the problem are:
Before Now the database metadata is managed by the DatabaseHolder class, since this is an information associated to the database directly (and this makes sense from the point of view that all collections are sharded). Although we have no fine grain mechanism mentioned above, unless to use the one currently exposed by the DSS or to implement something similar at the database level (to be used only for metadata access). We will discuss about this problem internally in order to find a solution fully compatibile with our future goals |