[SERVER-41866] Reverse mutex acquisition order in CatalogCache::_scheduleDatabaseRefresh Created: 21/Jun/19  Updated: 29/Oct/23  Resolved: 08/Jul/19

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 4.0.10, 4.2.0-rc1
Fix Version/s: 4.0.11, 4.2.0-rc3, 4.3.1

Type: Bug Priority: Major - P3
Reporter: Randolph Tan Assignee: Kaloian Manassiev
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.2, v4.0
Sprint: Sharding 2019-07-15
Participants:

 Description   

CatalogCache::_mutex -> ShardServerCatalogCacheLoader::_mutex order:

CatalogCache::_scheduleDatabaseRefresh has catalog cache mutex and calls getDatabase:
https://github.com/mongodb/mongo/blob/2393ed14199eddebe25e56bc0a8fe1d47f2297cf/src/mongo/s/catalog_cache.cpp#L532

which will take the ShardServerCCL _mutex at the beginning of the call.

ShardServerCCL::_mutex -> CatalogCache::_mutex order:

Inside the async task lamda we take the ShardServerCCL mutex then tries to run a callback:
https://github.com/mongodb/mongo/blob/2393ed14199eddebe25e56bc0a8fe1d47f2297cf/src/mongo/db/s/shard_server_catalog_cache_loader.cpp#L460

And the callback tries to get the CatalogCache::_mutex:

https://github.com/mongodb/mongo/blob/2393ed14199eddebe25e56bc0a8fe1d47f2297cf/src/mongo/s/catalog_cache.cpp#L523



 Comments   
Comment by Githook User [ 09/Jul/19 ]

Author:

{'name': 'Kaloian Manassiev', 'email': 'kaloian.manassiev@mongodb.com', 'username': 'kaloianm'}

Message: SERVER-41866 On term mismatch do not invoke the getDatabase callback under mutex`

(cherry picked from commit 75dc5684d4c6be0e8ac7c653f5389df9f45f1baf)
Branch: v4.0
https://github.com/mongodb/mongo/commit/08d395bc9e66e5be6caa5ae59d1eb50c5b053193

Comment by Githook User [ 09/Jul/19 ]

Author:

{'name': 'Kaloian Manassiev', 'email': 'kaloian.manassiev@mongodb.com', 'username': 'kaloianm'}

Message: SERVER-41866 On term mismatch do not invoke the getDatabase callback under mutex`

(cherry picked from commit 75dc5684d4c6be0e8ac7c653f5389df9f45f1baf)
Branch: v4.2
https://github.com/mongodb/mongo/commit/3c4de4cae84a648e4a55a2b9cbef57b25a68cc0d

Comment by Githook User [ 08/Jul/19 ]

Author:

{'name': 'Kaloian Manassiev', 'username': 'kaloianm', 'email': 'kaloian.manassiev@mongodb.com'}

Message: SERVER-41866 On term mismatch do not invoke the getDatabase callback under mutex`
Branch: master
https://github.com/mongodb/mongo/commit/75dc5684d4c6be0e8ac7c653f5389df9f45f1baf

Generated at Thu Feb 08 04:58:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.