Skip to content

fix(actuator): retry pause state read on broadcast update - #1289

Merged
andrzejfudro merged 3 commits into
mainfrom
fix/actuator-pause-broadcast-read-retry
Oct 16, 2026
Merged

andrzejfudro merged 3 commits into
mainfrom
fix/actuator-pause-broadcast-read-retry

Conversation

@andrzejfudro

@andrzejfudro andrzejfudro commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Pause listener: handleBroadcastUpdate now retries a failed read with the existing reconnect backoff until it succeeds or the listener shuts down.
  • Read timeout: each retried read (broadcast update, reconnect resync, and the reconnect's Redis offset query) gets its own ReadTimeout (default 10s), so a hung call becomes a retry instead of stalling the listener.
  • Shared test fake: storagetest.FakePauseStateRepository gains InjectGetFaults(hangs, failures) and GetCallCount() for simulating failed and hung reads.
  • Tests: table-driven cases for recovering after failed and hung reads, and for returning promptly on shutdown while reads fail or hang.

Assumptions

  • Retrying without an attempt cap is preferred — a capped retry would bring back the stale cache — during a long Spanner outage each pod logs one error per backoff interval (500 ms).
  • 10s is a reasonable bound for a single-row read — it normally takes milliseconds — if too short, Params.ReadTimeout can override it.
  • The cold-start read in Init keeps no per-call timeout — it runs once at startup and is not retried — a hang there behaves as before and delays startup.

Verification

  • bazel test on 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-commit lint steps: gofmt, golangci-lint, determinism check, go mod tidy (Passed)

TAG=agy
CONV=aca941d1-8c29-4820-96a9-0200c1071207

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
andrzejfudro marked this pull request as ready for review October 16, 2026 06:50
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

janzak-dev
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
@andrzejfudro
andrzejfudro added this pull request to the merge queue Oct 16, 2026
Merged via the queue into main with commit 5a3a3b0 Oct 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants