Skip to content

Handle poller resubmission during shutdown - #3076

Open
frojasg wants to merge 1 commit into
temporalio:mainfrom
frojasg:frojas/fix-poller-shutdown-race
Open

frojasg wants to merge 1 commit into
temporalio:mainfrom
frojasg:frojas/fix-poller-shutdown-race

Conversation

@frojasg

@frojasg frojasg commented Sep 16, 2026

Copy link
Copy Markdown

What changed?

Catch RejectedExecutionException when a poll loop re-submits itself and its executor has shut down. Rejections from an executor that is still running continue to reach the uncaught exception handler.

Why?

MultiThreadedPoller checks shouldTerminate() before it schedules the next poll. Shutdown can start between that check and execute(this). The resulting rejection escapes from finally, bypasses the shutdown-aware handler, and produces an ERROR log during normal worker shutdown.

The catch handles that race without changing task handoff or shutdown ordering. It checks the executor's shutdown state, so thread interruption alone cannot suppress an unexpected rejection.

Validation

The two new shutdown-race tests fail on the original code and pass with this change. Tests also verify that running-executor rejections remain visible, including on an interrupted thread.

On Java 21, formatting, SDK assembly, and all 13 tests across MultiThreadedPollerTest, GracefulPollShutdownTest, ShutdownManagerTest, and WorkerShutdownTest passed. The full test suite was not run locally.

Breaking changes?

None. No public API changes.

Server PR

None required.

Generated with Codex

@CLAassistant

CLAassistant commented Sep 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@frojasg
frojasg marked this pull request as ready for review September 16, 2026 00:41
@frojasg
frojasg requested a review from a team as a code owner September 16, 2026 00:41
@Quinn-With-Two-Ns

Copy link
Copy Markdown
Contributor

Hi, thank you for the contribution. Before we review your PR could you please sign the CLA

@frojasg

frojasg commented Sep 17, 2026

Copy link
Copy Markdown
Author

Done signing

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.

3 participants