Skip to content

Backport poller c6b601d#1255

Open
yuandrew wants to merge 2 commits into
temporalio:backport/poller-shutdown/c6b601dfrom
yuandrew:backport-poller-c6b601d
Open

Backport poller c6b601d#1255
yuandrew wants to merge 2 commits into
temporalio:backport/poller-shutdown/c6b601dfrom
yuandrew:backport-poller-c6b601d

Conversation

@yuandrew
Copy link
Copy Markdown
Contributor

@yuandrew yuandrew commented May 12, 2026

What was changed

Back port #1224 (commit 64cb6ed) onto commit c6b601d to fix poller shutdown for sdk-dotnet 1.12.0

Why?

Back port poller shutdown fix to affected SDKs

Checklist

  1. How was this tested: CI
  2. Any docs updates needed? No

Note

Medium Risk
Changes worker shutdown sequencing and poll-stream termination behavior, which is concurrency-sensitive and could affect how workers stop polling in production. Added tests reduce risk but regressions could still surface under real server/poll timing.

Overview
Fixes a graceful poll shutdown deadlock by moving the ShutdownWorker RPC into Worker::initiate_shutdown (spawned in the background and awaited by Worker::shutdown) so the server is signaled to flush in-flight long polls.

Updates poll-stream behavior so empty poll responses after shutdown are treated as a termination signal (instead of poll timeouts that retry forever), and threads namespace capability plumbing via a new exported NamespaceCapabilities.

Expands unit/integration coverage around shutdown (including a tight timer+activity loop scenario), adjusts heartbeat/shutdown assertions, enables the dev-server dynamic config for cancel-on-shutdown, and bumps the test CLI override to v1.6.3-serverless.

Reviewed by Cursor Bugbot for commit 96ac534. Bugbot is set up for automated code reviews on this repo. Configure here.

@yuandrew yuandrew requested a review from a team as a code owner May 12, 2026 15:36
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 96ac534. Configure here.

_ => {}
}
});
*guard = Some(handle);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Race between concurrent initiate_shutdown and shutdown loses RPC handle

Low Severity

When initiate_shutdown() is called concurrently from one thread (Thread A) while shutdown() is called from another (Thread B), Thread B's internal initiate_shutdown() sees already_initiated_shutdown = true and returns early without spawning. Thread B then proceeds to self.shutdown_rpc_handle.lock().take() which may return None if Thread A hasn't yet reached the mutex to store the handle. This causes shutdown() to skip awaiting the RPC, potentially proceeding to wait for polls to drain before the server has been told to release them—the exact deadlock scenario this PR aims to fix.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 96ac534. Configure here.

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