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

The WiredTiger event handler is not used correctly when calling compact

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

      Include WT-11434 in MongoDB and execute the storage_wiredtiger_test test suite.

      Show
      Include WT-11434 in MongoDB and execute the storage_wiredtiger_test test suite.
    • Execution NAMR Team 2023-08-21

      The WiredTiger team tried to perform a drop yesterday, see the patch build which contains failures related to compact testing in MDB.

      When compaction is performed, we check periodically if it has been interrupted by the application or if the timeout (if configured) has elapsed, see here.

      With WT-11434, we are now doing those checks before taking a checkpoint as part of compaction, see here.

      To know whether compaction has been interrupted by the application, we check the event handler.

      There was some work done related to this through SERVER-70201 and the issue is in this new code here:

          OperationContext* opCtx = reinterpret_cast<OperationContext*>(session->app_private);
          invariant(opCtx);
      

      The session->app_private field is set only if a SessionDataRAII is constructed and used for the compact operation, which is the case here.

      However, there is another call to compact in the MDB layer such as in wiredtiger_util_test.cpp that is not using the SessionDataRAII so when the event handler is checked, it crashes with the invariant. There might be other calls to compact that would lead to the issue.

      After checking why it was not failing prior to WT-11434, the code that triggers the event handler is not executed and this might be related to SERVER-75814.

      The suggested code changes are the following ones:

      diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
      index bda44e1e9ac..11e94fde9f9 100644
      --- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
      +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
      @@ -862,12 +862,11 @@ int mdb_handle_general(WT_EVENT_HANDLER* handler,
                              WT_SESSION* session,
                              WT_EVENT_TYPE type,
                              void* arg) {
      -    if (type != WT_EVENT_COMPACT_CHECK) {
      +    if (type != WT_EVENT_COMPACT_CHECK || session == nullptr || session->app_private == nullptr) {
               return 0;
           }
       
           OperationContext* opCtx = reinterpret_cast<OperationContext*>(session->app_private);
      -    invariant(opCtx);
       
           Status status = opCtx->checkForInterruptNoAssert();
           if (!status.isOK()) {
      

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            etienne.petrel@mongodb.com Etienne Petrel
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: