Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eternal Functions not working as expected in Function Runtime Version: 4 #138

Closed
kanupriya15025 opened this issue Jun 1, 2023 · 5 comments · Fixed by #139
Closed

Eternal Functions not working as expected in Function Runtime Version: 4 #138

kanupriya15025 opened this issue Jun 1, 2023 · 5 comments · Fixed by #139
Assignees
Labels
need investigation Need investigation from a maintainer

Comments

@kanupriya15025
Copy link

kanupriya15025 commented Jun 1, 2023

I was trying out the below example on my local machine with the following conf:
Core Tools Version: 4.0.5198 Commit hash: N/A (64-bit)
Function Runtime Version: 4.21.1.20667

https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-eternal-orchestrations?tabs=java#periodic-work-example

This is the tweaked version of the function I ran :

    @FunctionName("EternalOrchestrator")
    public void startWorkflowSchedule(@DurableOrchestrationTrigger(name = "runtimeState") TaskOrchestrationContext ctx) 
     {
        LOGGER.info("Doing something in the cleanup loop");

        ctx.createTimer(Duration.ofSeconds(60)).await();

        ctx.continueAsNew(null);
     }

I doesn't work anymore with the upgrade to Function Runtime Version 4.21. This is the error I get before the second time timer starts in the loop :

Executed 'Functions.EternalOrchestrator' (Failed, Id=3eff24fa-d8ad-492e-8d8d-ac730bcb0a40, Duration=40ms)
[2023-06-01T06:24:50.322Z] System.Private.CoreLib: Exception while executing function: Functions.EternalOrchestrator. System.Private.CoreLib: Result: Failure
[2023-06-01T06:24:50.322Z] Exception: IllegalStateException: The orchestrator has already completed
[2023-06-01T06:24:50.322Z] Stack: java.lang.IllegalStateException: The orchestrator has already completed
[2023-06-01T06:24:50.322Z]      at com.microsoft.durabletask.Helpers.throwIfOrchestratorComplete(Helpers.java:31)
[2023-06-01T06:24:50.322Z]      at com.microsoft.durabletask.TaskOrchestrationExecutor$ContextImplTask.completeInternal(TaskOrchestrationExecutor.java:724)
[2023-06-01T06:24:50.322Z]      at com.microsoft.durabletask.TaskOrchestrationExecutor$ContextImplTask.completeInternal(TaskOrchestrationExecutor.java:717)
[2023-06-01T06:24:50.322Z]      at com.microsoft.durabletask.TaskOrchestrationExecutor$ContextImplTask.complete(TaskOrchestrationExecutor.java:704)
[2023-06-01T06:24:50.323Z]      at com.microsoft.durabletask.TaskOrchestrationExecutor.execute(TaskOrchestrationExecutor.java:60)
[2023-06-01T06:24:50.323Z]      at com.microsoft.durabletask.OrchestrationRunner.loadAndRun(OrchestrationRunner.java:135)
[2023-06-01T06:24:50.323Z]      at com.microsoft.durabletask.OrchestrationRunner.loadAndRun(OrchestrationRunner.java:69)
[2023-06-01T06:24:50.323Z]      at com.microsoft.durabletask.OrchestrationRunner.loadAndRun(OrchestrationRunner.java:42)
[2023-06-01T06:24:50.324Z]      at com.microsoft.durabletask.azurefunctions.internal.middleware.OrchestrationMiddleware.invoke(OrchestrationMiddleware.java:33)
[2023-06-01T06:24:50.324Z]      at com.microsoft.azure.functions.worker.chain.InvocationChain.doNext(InvocationChain.java:21)
[2023-06-01T06:24:50.324Z]      at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:125)
[2023-06-01T06:24:50.324Z]      at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:34)
[2023-06-01T06:24:50.324Z]      at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
[2023-06-01T06:24:50.325Z]      at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:44)
[2023-06-01T06:24:50.325Z]      at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:94)
[2023-06-01T06:24:50.325Z]      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
[2023-06-01T06:24:50.325Z]      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[2023-06-01T06:24:50.326Z]      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[2023-06-01T06:24:50.326Z]      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[2023-06-01T06:24:50.326Z]      at java.base/java.lang.Thread.run(Thread.java:1589)
@kanupriya15025
Copy link
Author

The same works fine on the below functions runtime version :


Azure Functions Core Tools
Core Tools Version:       3.0.4899 Commit hash: N/A  (64-bit)
Function Runtime Version: 3.17.0.0

@kanupriya15025 kanupriya15025 changed the title Eternal Functions not working as expected Eternal Functions not working as expected in Function Runtime Version: 4 Jun 1, 2023
@lilyjma
Copy link
Member

lilyjma commented Jun 1, 2023

thanks @kanupriya15025 for reporting this. We'll look into it

@kaibocai kaibocai added need investigation Need investigation from a maintainer and removed Needs: Triage 🔍 labels Jun 1, 2023
@kanupriya15025
Copy link
Author

@kaibocai @lilyjma I tried this fix with updating my pom.xml with updating the following

com.microsoft
durabletask-azure-functions
1.1.1

But this doesn't fix the issue. I still see my orchestrator failing with error : java.lang.RuntimeException: Unexpected failure in the task execution

The same code works fine with updating the Runtime Version back to ~3.

Can we look at this?

@kaibocai
Copy link
Member

@kanupriya15025 , I cannot reproduce your issue on my side with version 1.1.1

My function is the same as yours:
image

My local results work fine:
image

As you can see host version is 4.21.1 and SDK version is 1.1.1.

I think you may not have the right setup on your local. As I said in the last meeting, azure function runtime v3 doesn't even support durable function java. It's only supported on v4 runtime.

I am getting below errors with the basic orchestration sample when running on v3
image

So I was wondering how you were able to run durable function java on v3 function runtime.
Please reach out to @lilyjma if you need me to jump on a call to check and help. Thanks.

@kanupriya15025
Copy link
Author

@kaibocai My bad..I wasn't testing it right. It works fine now. However, this breaks the suspend orchestration functionality now. I'll raise a separate bug for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need investigation Need investigation from a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants