Skip to content

Commit 7d6a6ff

Browse files
committed
Don't block on shutdown RPC in interrupt mode
1 parent 8ae11f5 commit 7d6a6ff

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ src/main/idls/*
1818
.settings
1919
.vscode/
2020
*/bin
21-
/.claude
21+
/.claude
22+
**/.factorypath

temporal-sdk/src/main/java/io/temporal/worker/Worker.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,13 @@ CompletableFuture<Void> shutdown(ShutdownManager shutdownManager, boolean interr
472472
shutdownManager.waitOnWorkerShutdownRequest(
473473
service.futureStub().shutdownWorker(requestBuilder.build()));
474474

475-
return shutdownWorkerRpc.thenCompose(
475+
// When interrupting tasks (shutdownNow), fire the RPC but don't block on it — proceed to
476+
// shut down pollers immediately. For graceful shutdown, wait for the RPC so the server can
477+
// complete outstanding polls with empty responses before we start waiting on them.
478+
CompletableFuture<Void> preShutdown =
479+
interruptUserTasks ? CompletableFuture.completedFuture(null) : shutdownWorkerRpc;
480+
481+
return preShutdown.thenCompose(
476482
ignore -> {
477483
CompletableFuture<Void> workflowWorkerShutdownFuture =
478484
workflowWorker.shutdown(shutdownManager, interruptUserTasks);

0 commit comments

Comments
 (0)