ExportXMLWordPrintableJSON

    • v9.0, v8.3, v8.0, v7.0

      Problem
      __wt_log_get_backup_files calls __wti_log_force_write after setting WTI_LOG_FORCE_NEWFILE, then returns the file list for the caller to copy. The force write rolls the file, but it does not guarantee that records already allocated to it have reached it:

      1. alloc_lsn advances at __log_slot_close from the slot's *joined* byte count, before those bytes are copied into the slot buffer or written.
      2. __wti_log_release writes its own slot buffer and, unless the slot is FLUSH/SYNC and the log server is running, marks the slot WRITTEN and returns. __log_wait_for_earlier_slot runs only on the flush/sync branch, so earlier closed slots can still be pending.
      3. If another thread switches the active slot first, __log_slot_switch_internal returns without switching, and the FORCE_NEWFILE roll is left to the next log acquire — after the list may already have been returned.

      The caller copies the files immediately after the list is returned, so it can read zeros for
      records counted in the file's LSN space but not yet written. The backup's journal copy is short, and recovery later stops at a hole. __wt_log_flush performs the missing wait; the backup path did not.

      Fix
      After the forced write:

      • retry until alloc_lsn has moved past the captured max_file, so the returned list cannot contain a file that still accepts writes;
      • wait for write_lsn to reach the new active slot's slot_release_lsn (the end of the sealed file) before building the list.

      Test

      New csuite test test/csuite/wt18969_log_backup_seal. Sixteen writer threads insert ~12 KB records with log=(file_max=1MB). Each iteration opens a backup: cursor, copies the highest-numbered journal in the returned list immediately, closes the cursor, calls session->log_flush(), then byte-compares the copy with the sealed source file.

      Acceptance criteria

      • The test fails on the unfixed tree (the sealed copy has zeros where the source has the final record) and passes 3 x 200 iterations on the fixed tree.
      • test_incr_backup, test_truncated_log, and the live-restore tests still pass.
      • The wait runs while the backup holds the checkpoint and schema locks; no deadlock observed, to be called out in the PR.

        1. verify_logs.py
          3 kB
        2. backup-seal-before-after.md
          8 kB

            Assignee:
            Etienne Petrel
            Reporter:
            Etienne Petrel
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: