fs_directory_list_single skips eligible source-only files when the first source entry is ineligible

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • WT12.0.0, 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: Live Restore
    • None
    • Environment:
      GCC 13, Ubuntu 24.04
    • Storage Engines - Persistence
    • 562.722
    • None
    • 1

      In __live_restore_fs_directory_list_worker (src/live_restore/live_restore_fs.c line 245), when the single flag is set, the goto done statement (line 350) at the bottom of the source-file iteration loop fires unconditionally after every file is examined, regardless of whether that file was added to the output list.

      As a result, fs_directory_list_single returns count=0 whenever the first source-layer file (in readdir order) is ineligible (i.e. it has a stop file or a destination copy), even if a qualifying source-only file exists later in the listing. The log subsystem uses this function to enumerate log files during live restore; missing a log file in that context can cause incomplete recovery.

      The correct pattern, used by the destination loop in the same function, places goto done inside the if(add_source_file) block so that early termination only occurs after a qualifying entry has been found.

      For ReProduce:
      A Catch2 test case is added bottom of test/catch2/live_restore/api/test_live_restore_fs_directory_list.cpp that reproduces the bug.

      I intentionally did not include the test code in the PR; we can discuss whether the test code is appropriate for the PR. I have attached the test code. However, I have implemented the fix in the PR.

      Purposed Fix:
      Move the if(single) goto done; inside the if(add_source_file) block in the source-file loop of __live_restore_fs_directory_list_worker, matching the pattern of the destination loop.

            Assignee:
            Luke Pearson
            Reporter:
            Tuna KARABACAK (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: