Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-83998

Get the lock IX before calling autoCompact

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • Hide

      See this patch build

      Show
      See this patch build
    • 2023-12-12 - Heisenbug
    • 2

      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());
       }
      

            Assignee:
            etienne.petrel@mongodb.com Etienne Petrel
            Reporter:
            etienne.petrel@mongodb.com Etienne Petrel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: