Skip to content

Track recovered TLog retirement with a single phase - #14721

Open
tclinkenbeard-oai wants to merge 1 commit into
apple:mainfrom
tclinkenbeard-oai:dev/tclinkenbeard/tlog-retirement-phase
Open

tclinkenbeard-oai wants to merge 1 commit into
apple:mainfrom
tclinkenbeard-oai:dev/tclinkenbeard/tlog-retirement-phase

Conversation

@tclinkenbeard-oai

@tclinkenbeard-oai tclinkenbeard-oai commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

A recovered TLog moves through four retirement phases. The monitor requests retirement, the worker claims the log before its first wait, and the final persistent-data commit completes retirement. Express those transitions in one phase and keep the transition checks with it.

The worker selects pending logs. Spilling checks whether retirement has ever been requested, including after the worker claims the log. Queue advancement requires completed retirement and the final durable version. The existing removal checks still end a worker that loses its log while waiting.

Validation

All 16 tests in fdbserver_tlog_test passed on Linux with Clang 19.1.5. A temporary probe extended the in-memory TLog fixture to signal removal while the worker was waiting for a log to stop, a queue commit, or a durable spill. In each case the worker exited, left the log incomplete, and skipped it on subsequent selection. A fourth case checked that queue advancement requires both completed retirement and a matching durable version. All four cases passed in native mode and Sim2.

Built fdbserver and passed tests/slow/GcGenerations.toml with seed 123456 and buggify enabled. The run completed with unseed 51931.

@tclinkenbeard-oai
tclinkenbeard-oai marked this pull request as ready for review December 2, 2026 21:55

@tclinkenbeard-oai tclinkenbeard-oai left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated by Codex.

What problem is this PR trying to solve? (ELI10)

After FoundationDB recovers, an old transaction log can still have cleanup work to do. Imagine the log ends at version 100, but its storage has only saved through version 99. A worker can take responsibility for cleanup immediately. It has to wait for version 100 to be saved before it can finish. The old code handled this correctly, but readers had to combine three yes/no flags to tell how far the worker had gotten. Original flags · Original worker selection

How does this PR solve the problem? (ELI10 and review walkthrough)

Each log now has one phase that says how far cleanup has gotten. In the example, the log is InProgress while the worker waits for version 100. That tells the worker selector to skip it and the storage loop to keep writing. Phase transitions and predicates

  1. Request cleanup. Once the cluster is fully recovered, the monitor identifies logs still listed in the configuration from an older generation. Only the first request moves a log from None to Requested. Repeated configuration updates leave its progress intact. Monitor
  2. Claim the log. The worker prefers the pending log at the front of the write order. It can also select a pending log whose last version is already saved. It calls start() before its first wait, so the same log cannot be selected twice. Selection and claim
  3. Save the last batch. After the claim, pending() is false and requested() is still true. The storage loop uses requested(), so it writes version 100 even if that batch is smaller than the normal write threshold. This lets the waiting worker proceed. Storage decision · Worker’s durability wait
  4. Release the queue space. The worker marks the log Complete only after committing the metadata that records which messages can be discarded. Queue advancement checks both completion and the final durable version, and a restored queue must have a committed position first. Final commit · Queue advancement

What is it trying to do?

Make the legal retirement sequence explicit and enforce its ordering where the state changes. start() requires a pending request, and finish() requires a worker that has already claimed the log.

Is it correct?

Yes. I traced every write to the original flags. In (requested, started, retired) order, the only reachable combinations were 000 → 100 → 110 → 111. They map exactly to None → Requested → InProgress → Complete. Every caller uses the predicate corresponding to its original condition. The phase lives in memory, and the transition methods add no waits, scans, or disk writes. Reviewed diff

Are there bugs?

I found no correctness bugs. In particular, removal during the wait for the log to stop, the queue to commit, or the last batch to become durable exits the worker with the log still InProgress. That excludes it from both reselection and retirement-based queue advancement. A failed final commit also exits before finish(). Removal checks · Commit ordering

Are there omissions?

One nonblocking coverage gap is progress on a small final batch after the worker claims the log. GcGenerations finishes once the old-generation count has fallen and the cluster reaches FULLY_RECOVERED, which is when the monitor can first request retirement. The author’s temporary probes cover removal during waits and the queue advancement conditions. A deterministic test of the version-99-to-100 example would catch an accidental switch to pending() in the storage loop by checking that the queue eventually advances. Workload completion condition · Author’s validation

Are there better ways of doing things?

I’d keep the implementation as written. The private phase lets each caller ask the question it needs to answer, and the class keeps the transition assertions together.

Should this CL be LGTMd?

Yes, LGTM. The refactor preserves the distinction between claiming work, making the last write durable, and releasing queue space. I reviewed base 25d8e2c080fd and head fd929722acb9 by inspection and ran no builds or tests. At the final check, three public checks had passed and seven were pending, with zero failures. Public checks

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-macos-m1 on macOS

  • Commit ID: fd92972
  • Duration 0:18:44
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-macos on macOS

  • Commit ID: fd92972
  • Duration 0:22:37
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang-ide on Linux RHEL 9

  • Commit ID: fd92972
  • Duration 0:30:58
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang-arm on Linux RHEL 9

  • Commit ID: fd92972
  • Duration 0:50:20
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang on Linux RHEL 9

  • Commit ID: fd92972
  • Duration 0:51:41
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr on Linux RHEL 9

  • Commit ID: fd92972
  • Duration 0:52:48
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-cluster-tests on Linux RHEL 9

  • Commit ID: fd92972
  • Duration 1:40:29
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)
  • Cluster Test Logs zip file of the test logs (available for 30 days)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants