[SERVER-83998] Get the lock IX before calling autoCompact Created: 07/Dec/23  Updated: 10/Dec/23  Resolved: 10/Dec/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Bug Priority: Major - P3
Reporter: Etienne Petrel Assignee: Etienne Petrel
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
is caused by SERVER-83734 Create a server parameter to enable b... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

See this patch build

Sprint: 2023-12-12 - Heisenbug
Participants:
Story Points: 2

 Description   

In SERVER-80123, we found that we were hitting the following assert as we are not holding the lock IX:

    dassert(shard_role_details::getLocker(opCtx)->isWriteLocked());

Suggested code change:

diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
index 5cdcfabc190..43e2e7a0ea2 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
@@ -632,6 +632,7 @@ void WiredTigerKVEngine::notifyStartupComplete(OperationContext* opCtx) {
     StorageEngine::AutoCompactOptions options{/*enable=*/true,
                                               /*freeSpaceTargetMB=*/boost::none,
                                               /*excludedIdents*/ std::vector<StringData>()};
+    Lock::GlobalLock lk(opCtx, MODE_IX);
     auto status = autoCompact(opCtx, options);
     uassert(8373401, "Failed to execute autoCompact.", status.isOK());
 }



 Comments   
Comment by Githook User [ 10/Dec/23 ]

Author:

{'name': 'Etienne Petrel', 'email': 'etienne.petrel@mongodb.com', 'username': 'etienneptl'}

Message: SERVER-83998 Get the lock IX before executing autoCompact

GitOrigin-RevId: eba6be874bd24c51dded9e6946b86883db64c48e
Branch: master
https://github.com/mongodb/mongo/commit/2ae9d3a0549b26c2aa8e3ec1c1a33299c6bfe427

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