Repository navigation
fix(actuator): retry pause state read on broadcast update - #1289
Merged
Merged
Conversation
When a pause/resume broadcast arrives, the Actuator listener re-reads the pause state from Spanner. A failed read was logged and dropped while the stream offset still advanced, so the pod kept a stale cache until the next broadcast, reconnect, or restart. A pod stuck on paused keeps buffering new tasks that no resumption run will pick up. Retry the read with the existing reconnect backoff until it succeeds or the listener shuts down. Broadcasts are invalidation pings, so any that queue up while retrying are redundant once the read succeeds. Each retried read (broadcast update and reconnect resync) also gets its own timeout, 10s by default, so a hung Spanner call turns into a retry instead of stalling the listener indefinitely. TAG=agy CONV=aca941d1-8c29-4820-96a9-0200c1071207
There was a problem hiding this comment.
Code Review
This pull request introduces a configurable read timeout for querying the pause scheduling state and implements a retry mechanism in handleBroadcastUpdate to handle failed or timed-out reads, accompanied by new unit tests. Feedback suggests optimizing the retry loop by checking ctx.Err() immediately after the backoff wait to prevent an unnecessary database read if the context is cancelled during the backoff period.
Check for context cancellation right after the retry backoff, so a shutdown that lands during the wait returns immediately instead of issuing one more pause state read. This matches the reconnect loop in StartListening. Comment link: #1289 (comment) TAG=agy CONV=aca941d1-8c29-4820-96a9-0200c1071207
andrzejfudro
marked this pull request as ready for review
October 16, 2026 06:50
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
andrzejfudro
enabled auto-merge
October 16, 2026 06:50
janzak-dev
previously approved these changes
Oct 16, 2026
- Bound the Redis LatestOffset query in resyncOnReconnect with the read timeout, so the reconnect path does not rely on client defaults alone. - Restructure the broadcast retry loop to read once per iteration. The loop condition still stops right after a shutdown interrupts the backoff. - Move the failing and hanging read simulation into the shared storagetest.FakePauseStateRepository (InjectGetFaults, GetCallCount) and drop the local test double. Comment link: #1289 (comment) Comment link: #1289 (comment) Comment link: #1289 (comment) TAG=agy CONV=aca941d1-8c29-4820-96a9-0200c1071207
janzak-dev
approved these changes
Oct 16, 2026
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.
Summary
When a pause/resume broadcast arrives, the Actuator listener re-reads the pause state from Spanner. If that read failed, the update was logged and dropped while the stream offset still advanced, so the pod kept a stale cache until the next broadcast, reconnect, or restart. A pod stuck on paused keeps buffering tasks that no resumption run will pick up.
Key Changes
handleBroadcastUpdatenow retries a failed read with the existing reconnect backoff until it succeeds or the listener shuts down.ReadTimeout(default 10s), so a hung call becomes a retry instead of stalling the listener.storagetest.FakePauseStateRepositorygainsInjectGetFaults(hangs, failures)andGetCallCount()for simulating failed and hung reads.Assumptions
Params.ReadTimeoutcan override it.Initkeeps no per-call timeout — it runs once at startup and is not retried — a hang there behaves as before and delays startup.Verification
bazel teston all affected targets://cmd/actuator:actuator_test,//cmd/actuator/pausescheduling:pausescheduling_test,//cmd/actuator/workunittaskhandler:workunittaskhandler_test,//cmd/experiment_state_server/resumption:resumption_test,//cmd/health_service:server_test,//internal/storage/testing:testing_test(Passed)bazel test --@io_bazel_rules_go//go/config:race //cmd/actuator/pausescheduling:pausescheduling_test //internal/storage/testing:testing_test(Passed)./.githooks/pre-commitlint steps: gofmt, golangci-lint, determinism check, go mod tidy (Passed)TAG=agy
CONV=aca941d1-8c29-4820-96a9-0200c1071207