Title: Functions - Terminating a running orchestrator throws IllegalStateException · Issue #237 · microsoft/durabletask-java · GitHub
Open Graph Title: Functions - Terminating a running orchestrator throws IllegalStateException · Issue #237 · microsoft/durabletask-java
X Title: Functions - Terminating a running orchestrator throws IllegalStateException · Issue #237 · microsoft/durabletask-java
Description: When using this repo with Azure Functions with the MSSQL backend, and using the client.terminate() API to terminate an orchestraton that is still running, the orchestration will throw an IllegalStateException: [2025-08-22T16:32:56.240Z] ...
Open Graph Description: When using this repo with Azure Functions with the MSSQL backend, and using the client.terminate() API to terminate an orchestraton that is still running, the orchestration will throw an IllegalSta...
X Description: When using this repo with Azure Functions with the MSSQL backend, and using the client.terminate() API to terminate an orchestraton that is still running, the orchestration will throw an IllegalSta...
Opengraph URL: https://github.com/microsoft/durabletask-java/issues/237
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Functions - Terminating a running orchestrator throws IllegalStateException","articleBody":"When using this repo with Azure Functions with the MSSQL backend, and using the client.terminate() API to terminate an orchestraton that is still running, the orchestration will throw an IllegalStateException: \n\n```text\n[2025-08-22T16:32:56.240Z] Executed 'Functions.LongRunningOrchestrator' (Failed, Id=c6d1d1b9-32ee-4849-a841-5902bbbff2c6, Duration=51ms)\n[2025-08-22T16:32:56.241Z] System.Private.CoreLib: Exception while executing function: Functions.LongRunningOrchestrator. System.Private.CoreLib: Result: Failure\nException: IllegalStateException: The orchestrator has already completed\nStack: java.lang.IllegalStateException: The orchestrator has already completed\n[2025-08-22T16:32:56.242Z] at com.microsoft.durabletask.Helpers.throwIfOrchestratorComplete(Helpers.java:31)\n[2025-08-22T16:32:56.243Z] at com.microsoft.durabletask.TaskOrchestrationExecutor$ContextImplTask.completeInternal(TaskOrchestrationExecutor.java:799)\n[2025-08-22T16:32:56.244Z] at com.microsoft.durabletask.TaskOrchestrationExecutor$ContextImplTask.fail(TaskOrchestrationExecutor.java:787)\n[2025-08-22T16:32:56.244Z] at com.microsoft.durabletask.TaskOrchestrationExecutor.execute(TaskOrchestrationExecutor.java:71)\n[2025-08-22T16:32:56.245Z] at com.microsoft.durabletask.OrchestrationRunner.loadAndRun(OrchestrationRunner.java:136)\n[2025-08-22T16:32:56.247Z] at com.microsoft.durabletask.OrchestrationRunner.loadAndRun(OrchestrationRunner.java:69)\n[2025-08-22T16:32:56.249Z] at com.microsoft.durabletask.OrchestrationRunner.loadAndRun(OrchestrationRunner.java:42)\n[2025-08-22T16:32:56.249Z] at com.microsoft.durabletask.azurefunctions.internal.middleware.OrchestrationMiddleware.invoke(OrchestrationMiddleware.java:37)\n[2025-08-22T16:32:56.250Z] at com.microsoft.azure.functions.worker.chain.InvocationChain.doNext(InvocationChain.java:21)\n[2025-08-22T16:32:56.251Z] at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:125)\n[2025-08-22T16:32:56.252Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:34)\n[2025-08-22T16:32:56.253Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)\n[2025-08-22T16:32:56.254Z] at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:44)\n[2025-08-22T16:32:56.255Z] at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:94)\n[2025-08-22T16:32:56.256Z] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)\n[2025-08-22T16:32:56.257Z] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n[2025-08-22T16:32:56.258Z] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n[2025-08-22T16:32:56.258Z] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n[2025-08-22T16:32:56.259Z] at java.base/java.lang.Thread.run(Thread.java:842)\n[2025-08-22T16:32:56.260Z] .\n[2025-08-22T16:32:56.266Z] d88614d4-5cea-453a-9bbd-0a423a9059da: Function 'LongRunningOrchestrator (Orchestrator)' failed with an error. Reason: Microsoft.Azure.WebJobs.Host.FunctionInvocationException\n```\n\nCode:\n```java\n/**\n * Orchestration and activity functions for simulating long-running orchestration and termination.\n */\npublic class TerminateOrchestration {\n\n /**\n * This is the orchestrator function.\n */\n @FunctionName(\"LongRunningOrchestrator\")\n public List\u003cString> longRunningOrchestrator(\n @DurableOrchestrationTrigger(name = \"ctx\") TaskOrchestrationContext ctx,\n final ExecutionContext context) {\n Logger logger = context.getLogger();\n logger.info(\"Starting long-running orchestration.\");\n List\u003cString> outputs = new ArrayList\u003c>();\n\n // Call our fake activity 100,000 times to simulate an orchestration that might run for >= 10,000s (2.7 hours)\n for (int i = 0; i \u003c 100000; i++) {\n outputs.add(ctx.callActivity(\"SimulatedWorkActivity\", 100, String.class).await());\n }\n\n return outputs;\n }\n\n /**\n * This is the activity function.\n */\n @FunctionName(\"SimulatedWorkActivity\")\n public String simulatedWorkActivity(\n @DurableActivityTrigger(name = \"sleepMs\") int sleepMs,\n final ExecutionContext context) {\n context.getLogger().info(\"Sleeping for \" + sleepMs + \"ms.\");\n try {\n Thread.sleep(sleepMs);\n } catch (InterruptedException e) {\n Thread.currentThread().interrupt();\n return \"Sleep interrupted.\";\n }\n return \"Slept for \" + sleepMs + \"ms.\";\n }\n\n /**\n * HTTP-triggered function to terminate an orchestration instance.\n */\n @FunctionName(\"TerminateInstance\")\n public HttpResponseMessage run(\n @HttpTrigger(name = \"req\", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage\u003cOptional\u003cString>> request,\n @DurableClientInput(name = \"durableContext\") DurableClientContext durableContext,\n @BindingName(\"instanceId\") String instanceId,\n final ExecutionContext context) {\n DurableTaskClient client = durableContext.getClient();\n String reason = \"Long-running orchestration was terminated early.\";\n try {\n client.terminate(instanceId, reason);\n return request.createResponseBuilder(HttpStatus.OK).build();\n } catch (Exception ex) {\n context.getLogger().severe(ex.getMessage());\n return request.createResponseBuilder(HttpStatus.BAD_REQUEST)\n .header(\"Content-Type\", \"text/plain\")\n .body(ex.getMessage())\n .build();\n }\n }\n}\n```","author":{"url":"https://github.com/andystaples","@type":"Person","name":"andystaples"},"datePublished":"2025-08-22T16:35:27Z","url":"https://github.com/microsoft/durabletask-java/issues/237"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2a446320-e1d7-0677-92e3-07349d6dbfbe |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BE0:2218F3:657E1:89C1B:6AFE31A3 |
| html-safe-nonce | d2bffa2228598a1268abd50c055dd45e57055a13dcd1fced64fe7b0137eea4b9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkUwOjIyMThGMzo2NTdFMTo4OUMxQjo2QUZFMzFBMyIsInZpc2l0b3JfaWQiOiI4MzUyMTIyODUxNjE1OTc3ODkxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | dca9f5d8163dce358ee93775000e49a2f78ce4665b304b42414b88014c8dcaee |
| hovercard-subject-tag | issue:3346025606 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/durabletask-java/237/issue_layout |
| twitter:image | https://opengraph.githubassets.com/83a4d0456893638e66cb92929984562162da8f59a88618ed68af583e1402ec92/microsoft/durabletask-java/issues/237 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/83a4d0456893638e66cb92929984562162da8f59a88618ed68af583e1402ec92/microsoft/durabletask-java/issues/237 |
| og:image:alt | When using this repo with Azure Functions with the MSSQL backend, and using the client.terminate() API to terminate an orchestraton that is still running, the orchestration will throw an IllegalSta... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andystaples |
| hostname | github.com |
| expected-hostname | github.com |
| None | d70e31220a67f6376c108d2416fa8e7df854c1065b1672ab7a88ab6dc3a809e2 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/durabletask-java git https://github.com/microsoft/durabletask-java.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 452823832 |
| octolytics-dimension-repository_nwo | microsoft/durabletask-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 452823832 |
| octolytics-dimension-repository_network_root_nwo | microsoft/durabletask-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ccb88d9c92abe69245b429398c8a57ae87070c7c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width