Repository navigation
Stopping the high water agent cancels its poll wait (JasperFx/wolverine#5318) - #1100
Merged
Merged
Conversation
…ne#5318) HighWaterAgent.StopAsync awaited the poll loop, but the loop only noticed the stop after its current FastPollingTime / SlowPollingTime wait ran out, so every daemon pause (StopAllAsync) cost up to a full polling interval. Each loop now gets its own CancellationTokenSource linked to the daemon token; StopAsync cancels it before awaiting the loop, a restart cancels the retired loop's source, and every launch creates a fresh one so stop-then-start works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DCggXgxnG3EBXoR9rrq37U
… loop doesn't spin Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DCggXgxnG3EBXoR9rrq37U
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.
Refs JasperFx/wolverine#5318
JasperFxAsyncDaemon.StopAllAsynccallsHighWaterAgent.StopAsync, which awaits the poll loop. The loop's wait (IDaemonWakeup.WaitAsyncwithFastPollingTimeorSlowPollingTime) was only tied to the daemon's own token, which a stop does not cancel, so every stop waited out the rest of the current tick: about 250 ms after activity, up to 1 s after a quiet spell. Wolverine'sPauseThenCatchUpOnMartenDaemonActivitypays that on every tracked call.Change
CancellationTokenSource, linked to the daemon token and created inlaunchAsync, so every start (and every watchdog restart) has a fresh one and stop-then-start keeps working.StopAsynccancels it before awaiting the loop; the cancelled wait is the normal exit path (waitAsyncalready swallows it, and the loop then seesIsRunning == falseand leaves).Detectcalls still use the daemon token; only the waits changed.I looked at the other daemon loops. Subscription agents are fed by the high-water mark rather than polling, and the coordinator loops in
ProjectionCoordinatorBasealready wait on their stopping token, so nothing else has this shape.Tests
New
HighWaterAgent_stop_cancels_poll_wait_Tests:FastPollingTime/SlowPollingTime= 5 s, stop must return in under 1 s, then start again, check the new loop polls, and stop again in under 1 s.EventTests --filter-namespace "EventTests.Daemon*": 499/499 on net9.0 and 499/499 on net10.0.🤖 Generated with Claude Code
https://claude.ai/code/session_01DCggXgxnG3EBXoR9rrq37U