[SERVER-70793] Make database metadata refresh first check new metadata under the IS lock before taking X lock Created: 24/Oct/22  Updated: 29/Oct/23  Resolved: 08/Nov/22

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 6.1.1, 5.0.14, 6.0.4, 6.2.0-rc0

Type: Task Priority: Major - P3
Reporter: Jordi Serra Torrens Assignee: Antonio Fuschetto
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-66972 Database critical section does not se... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v6.1, v6.0, v5.0
Sprint: Sharding EMEA 2022-11-14
Participants:
Case:

 Description   

`onDbVersionMismatch`, when not invoked with a `receivedDbVersion`, after getting the latest metadata from the configsvr will unconditionally attempt to acquire the DB lock in MODE_X, even if the received metadata is not newer than the cached one. Taking the DB lock in MODE_X is expensive, as it serialized with any ongoing writer or transaction on that db. This causes stalls on the user workload.

Before SERVER-66972, there used to be an early check under the IS lock to exit early if the received version is not newer than the cached. This early check should be reintroduced to reduce the impact caused by secondaries calling _flushDatabaseCacheUpdates.



 Comments   
Comment by Githook User [ 10/Nov/22 ]

Author:

{'name': 'Antonio Fuschetto', 'email': 'antonio.fuschetto@mongodb.com', 'username': 'afuschetto'}

Message: SERVER-70793 Make database metadata refresh first check new metadata under the IS lock before taking X lock
Branch: v5.0
https://github.com/mongodb/mongo/commit/1b3b0073a0b436a8a502b612f24fb2bd572772e5

Comment by Githook User [ 09/Nov/22 ]

Author:

{'name': 'Antonio Fuschetto', 'email': 'antonio.fuschetto@mongodb.com', 'username': 'afuschetto'}

Message: SERVER-70793 Make database metadata refresh first check new metadata under the IS lock before taking X lock
Branch: v6.0
https://github.com/mongodb/mongo/commit/024a3693d888584cb3b10efd4cf5e9749cefc613

Comment by Githook User [ 09/Nov/22 ]

Author:

{'name': 'Antonio Fuschetto', 'email': 'antonio.fuschetto@mongodb.com', 'username': 'afuschetto'}

Message: SERVER-70793 Make database metadata refresh first check new metadata under the IS lock before taking X lock
Branch: v6.1
https://github.com/mongodb/mongo/commit/78d555f1c06d73df273fc0b47ac4d2b69e7a618e

Comment by Githook User [ 08/Nov/22 ]

Author:

{'name': 'Antonio Fuschetto', 'email': 'antonio.fuschetto@mongodb.com', 'username': 'afuschetto'}

Message: SERVER-70793 Make database metadata refresh first check new metadata under the IS lock before taking X lock
Branch: master
https://github.com/mongodb/mongo/commit/ac0a38a08ac02d83632b1d82b7c3c5b6e5276b41

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