Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-12989

Invalid assert in background compaction with run_once

    • Storage Engines
    • 2
    • Megabat - 2024-05-14, 2024-05-28 - FOLLOW ON SPRINT
    • v8.0

      There is an invalid WT_ASSERT in the background compaction code when setting it up to run once:

              /* The server has been signalled to change state. */
              if (conn->background_compact.signalled) {
                  /* If configured to run once, start from the beginning. */
                  if (conn->background_compact.run_once) {
                      WT_ASSERT(session, running);
      

      Indeed, if we turn it on and off rapidly, the running variable could be set to false. Here is a reproducer:

      diff --git a/src/conn/conn_compact.c b/src/conn/conn_compact.c
      index 1184ad328..c0a7b32c0 100644
      --- a/src/conn/conn_compact.c
      +++ b/src/conn/conn_compact.c
      @@ -534,6 +534,9 @@ __background_compact_server(void *arg)
               if (!__background_compact_server_run_chk(session))
                   break;
       
      +        if(conn->background_compact.run_once)
      +            __wt_sleep(5, 0);
      +
               __wt_spin_lock(session, &conn->background_compact.lock);
               running = conn->background_compact.running;
       
      diff --git a/test/suite/test_compact06.py b/test/suite/test_compact06.py
      index 4d31526ca..423e426d6 100644
      --- a/test/suite/test_compact06.py
      +++ b/test/suite/test_compact06.py
      @@ -108,7 +108,8 @@ class test_compact06(wttest.WiredTigerTestCase):
               # Enable background and configure it to run once. Don't use the helper function as the
               # server may go to sleep before we have the time to check it is actually running.
               self.session.compact(None, 'background=true,run_once=true')
      -
      +        time.sleep(2)
      +        self.session.compact(None, 'background=false')
               # Wait for background compaction to process the HS table. Even though there is no work to
               # do, it is considered as a success.
               while self.get_bg_compaction_success() == 1:
      

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

              Created:
              Updated:
              Resolved: