Repository navigation
Track recovered TLog retirement with a single phase - #14721
tclinkenbeard-oai wants to merge 1 commit into
Conversation
tclinkenbeard-oai
left a comment
There was a problem hiding this comment.
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
- 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
NonetoRequested. Repeated configuration updates leave its progress intact. Monitor - 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 - Save the last batch. After the claim,
pending()is false andrequested()is still true. The storage loop usesrequested(), 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 - Release the queue space. The worker marks the log
Completeonly 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
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Result of foundationdb-pr-macos-m1 on macOS
|
Result of foundationdb-pr-macos on macOS
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
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_testpassed 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
fdbserverand passedtests/slow/GcGenerations.tomlwith seed123456and buggify enabled. The run completed with unseed51931.