Repository navigation
Retry RangeDigest publication after the distributor regains its lock - #14700
tclinkenbeard-oai wants to merge 2 commits into
Conversation
A distributor can regain the move-keys lock without rerunning audit initialization. Retain the reservation and retry the original audit under the current lock at boundaries with no outstanding child tasks. Reuse the audit's normal error handling and cancel its core when the distributor exits. Exercise both lock orderings, cancellation and a failed metadata read.
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.
tclinkenbeard-oai
left a comment
There was a problem hiding this comment.
Generated by Codex.
What problem is this PR trying to solve? (ELI10)
Imagine the storage servers have finished making a fingerprint of the database. Just before the data distributor saves the result, someone pauses data distribution. That takes away the distributor’s permission to write. The write fails, and the distributor forgets the job even though its saved status still says Running. If the same distributor gets permission back, it skips the startup step that loads unfinished jobs. Anyone waiting on that audit ID can time out. Old conflict handler · One-time audit initialization
How does this PR solve the problem? (ELI10 and review walkthrough)
The distributor keeps the job number while it waits. Once it has permission again, it uses the saved pieces of the fingerprint to finish the original job.
- A lock conflict qualifies for this retry before any range work starts or when the finished fingerprint is ready to publish. The distributor resets the tentative result in memory, keeps the ID reserved during the delay, and checks that the same job still occupies the slot before starting another attempt. Lock conflicts at these two points leave the ordinary retry budget intact. Retry conditions and budget · Reset and restart
- The next attempt reads the lock and the saved audit together. The record must still be
Runningand belong to this distributor. After the read returns, the distributor checks that its local job and lock are still current before sending work. Check the saved record · Check ownership after the wait - Completed ranges are skipped during dispatch. The distributor checks coverage, rebuilds the fingerprint and both counts, then writes
Completeand clears the saved pieces in one transaction. A rejected write therefore leaves the pieces available for another attempt. Skip completed ranges · Rebuild the result · Commit under the lock
What is it trying to do?
Let a RangeDigest audit survive lock loss at either end of its range work without requiring a new distributor or a second client request.
Is it correct?
Yes. The regression forces the stale write both before and after the same distributor reacquires the lock. It checks the original ID and owner, compares the fingerprint and counts against an independent scan, and verifies that a duplicate launch returns the pending ID. The cancellation case checks that the cancelled record still says Failed after a later audit succeeds. Order the conflict and reacquisition · Check the original result · Recheck cancellation
I reviewed the code and public CI without running builds or tests. The sole failing check is unrelated. The PR Builder log reports a Go data race on restoreDelay between Kubernetes monitor test cleanup and its file watcher. PR Builder report and log
Are there bugs?
I found no correctness bug in the retry. A prolonged pause keeps the audit slot occupied and can cost a lock read per retry interval. Cancellation can release the slot, and distributor shutdown detaches the entries before cancelling their actors. Client cancellation · Distributor shutdown
Are there omissions?
The fixture exercises recovery by the same distributor. Shutdown during the retry delay is covered by code inspection only. The fingerprint still requires quiescent data throughout the audit, including the pause. Quiescence requirement
Are there better ways of doing things?
Reusing the existing audit loop keeps ownership checks, range recovery, and publication on one path. I’d keep that design.
Should this CL be LGTMd?
Yes, LGTM.
Result of foundationdb-pr-clang-arm on Linux RHEL 9
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-macos on macOS
macOS stat flags, not linux compatiblelock_mtime() { stat -f %m $LOCK || echo 0 }
|
Result of foundationdb-pr-macos-m1 on macOS
macOS stat flags, not linux compatiblelock_mtime() { stat -f %m $LOCK || echo 0 }
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
A RangeDigest audit can finish all its range tasks just as the data distributor (DD) loses the move-keys lock. The final transaction gets
movekeys_conflict, and the DD drops the audit from memory while its persisted state is stillRunning. When data distribution is re-enabled, the same DD can reacquire the lock. It has already loaded pending audits at startup, so the original audit staysRunninguntil the client times out.Use the existing audit retry loop when a RangeDigest loses the lock before dispatch or while publishing the completed digest. Both points have zero outstanding range tasks. Keep the original ID reserved and wait
DD_ENABLED_CHECK_DELAYbetween lock conflicts. A prolonged lock loss can cause repeated metadata reads, spaced one second apart by default. Other retryable errors use the audit's normal retry budget.Before dispatch, each attempt checks the current lock and verifies that the original record is still
Runningand belongs to this DD. The audit rebuilds the digest and counts from persisted range progress. A retry checks that it still owns the in-memory entry before replacing it, so cancellation can retire the audit during the wait. On exit, the DD detaches its RangeDigest entries and cancels their actors.Regression coverage
RangeDigestLockRecoveryuses a simulated cluster to order the client'ssetDDModetransaction, the DD's lock acquisition and the audit's final write. It pauses publication after the root is computed and exercises rejection of the stale write both before and after the same DD reacquires the lock. It also injects oneoperation_failedduring a metadata read on retry.The test reads the original audit ID, checks its owner and compares the persisted digest, key count and byte count with an independent scan. It also checks that a duplicate launch returns the pending ID and that a cancelled record stays
Failedafter a later audit completes.Validation
With only the regression fixture applied, seed
862407215found the original audit stillRunning121 simulated seconds after the same DD regained the lock. On0bc213aa223d, that seed and 12 additional seeds passed all three cases. The traces showed one successful publication per completed audit and no repeated storage tasks.RangeDigestValidationand the native and simulated/DataDistribution/Audit/unit checks also passed.The directed fixture keeps connections stable and disables random faults so the same DD can exercise both lock orderings. The new lock retry applies only to RangeDigest when no child work is outstanding. Conflicts during active range work and failures to persist an error remain outside its scope.