Repository navigation
test(daemon): replay a settled hook failure once, not per poll - #4181
Merged
Merged
Conversation
The replay loop re-admitted the same envelope every 5 ms while the replayed cycle ran. Each pass joined that cycle, and once 32 joins accumulated the next one hit MAX_COALESCED_HOOK_COMPLETIONS and was backpressured, which the loop asserted could never happen. A cycle on a loaded process runtime outlives 32 polls, so the test failed under load while production behaved as designed: the spool consumer treats Backpressured as replay-later. The test now waits for the failed cycle to settle, replays once, and awaits that replay's terminal. It still fails if the settled failure keeps its permit or stays in flight. Fixes #4172
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4172.
Root cause
The test was wrong. Production was not. Neither #4144's fix nor #4147's rework regressed.
The replay loop re-admitted the same envelope every 5 ms until the acknowledgement fired. While the replayed cycle ran, each pass joined it. After 32 joins, the next pass hit
MAX_COALESCED_HOOK_COMPLETIONSand gotBackpressured. The loop assertedEnqueuedon every pass. A fullunit_testbinary loads the shared native runtime. Under that load, the replayed cycle stays in flight past 32 polls, about 160 ms, so the test failed.Production behaves as designed. The coalescing bound is deliberate. The host spool treats
Backpressuredas replay-later (tracedecay-agent-hosts/src/hooks/dispatch.rs).I checked the paths named in the issue against the current
settle_operation:None. It owns nothing.Some(permit).settle_operationdrops it under the in-flight lock, right after it removes the entry.permitssemaphore.#4147's atomicity guarantee is unchanged.
Change
The test now waits for the failed cycle to settle. It replays once and awaits that replay's terminal, so it no longer polls. It asserts exactly one acknowledgement and exactly two attempts.
Verification
left: Backpressured, right: Enqueued. The new test passes with the same delay.//crates/tracedecay:unit_testrun on master46092b64d4without this fix failed attypes_tests.rs:570with the same assertion.mem::forgeton the retryable path). The test fails withBackpressured.--runs_per_test=30 --local_test_jobs=20 --run_under=taskset -c 0-7).//crates/tracedecay:unit_testpassed in two full runs (901/901).//crates/tracedecay:daemon_suitepassed. That suite does not compile these test files. Clippy (--config=clippy) andrustfmt_check_2024passed.