temporalio / sdk-dotnet

Temporal .NET SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Workflow that completes with no actions times out with deadlock error

cgillum opened this issue · comments

What are you really trying to do?

Trying to run a workflow that doesn't do anything (as a test).

Describe the bug

The [WorkflowRun] method starts and completes, but is replayed continuously until it times out.

The dashboard then shows the following failure details in the WorkflowTaskFailed event.

{
  "message": "Workflow with ID eaa5ad6b-764a-486d-9d49-65a2b2adbf12 deadlocked after 00:00:02",
  "source": "",
  "stackTrace": "   at Temporalio.Worker.WorkflowWorker.HandleActivationAsync(IPayloadCodec codec, WorkflowActivation act)",
  "encodedAttributes": null,
  "cause": null,
  "applicationFailureInfo": {
    "type": "InvalidOperationException",
    "nonRetryable": false,
    "details": null
  }
}

Additionally, I get this warning banner asking me to open a support request:

image

Minimal Reproduction

I can't easily share the full project since it's very advanced/complicated. However, this is basically the workflow that reproduces the problem:

[Workflow]
class WorkflowShim
{
    public WorkflowShim() { }

    [WorkflowRun]
    public Task Run() { return Task.CompletedTask; }
}

Adding a simple delay to the [WorkflowRun] fixes the problem - e.g.:

[WorkflowRun]
public async Task Run()
{
    await Workflow.DelayAsync(TimeSpan.FromSeconds(3));
}

Obviously not a big issue since an empty workflow isn't a real use case, but it is a confusing error message. It might be realistic if, for example, a developer writes code that only conditionally causes a workflow to actually take some action.

Environment/Versions

  • OS and processor: Windows 11, x64
  • Temporal Version: temporal version 0.8.0 (server 1.20.1) (ui 2.13.3)
  • SDK version: 0.1.0-alpha4
  • Are you using Docker or Kubernetes or building Temporal from source? Running from the temporal CLI.

Additional context

Thanks for the report! I'll investigate soon.

I know we have test cases (e.g.

public Task<string> RunAsync(string name) => Task.FromResult($"Hello, {name}!");
) and samples (e.g. https://github.com/temporalio/samples-dotnet/blob/2b9d8e300b9cac8634d1963c967009567de15269/src/AspNet/Worker/MyWorkflow.workflow.cs#L13) that just return Task.FromResult. I wonder if I just messed something up for Task sans return type. I will replicate and fix

I cannot replicate this. In my tests/Temporalio.Tests/Worker/WorkflowWorkerTests.cs I added:

    [Workflow]
    public class CompletedTaskWorkflow
    {
        public static readonly CompletedTaskWorkflow Ref = WorkflowRefs.Create<CompletedTaskWorkflow>();

        [WorkflowRun]
        public Task RunAsync() => Task.CompletedTask;
    }

    [Fact]
    public async Task ExecuteWorkflowAsync_CompletedTask_Succeeds()
    {
        await ExecuteWorkerAsync<CompletedTaskWorkflow>(async worker =>
        {
            await Env.Client.ExecuteWorkflowAsync(
                CompletedTaskWorkflow.Ref.RunAsync,
                new(id: $"workflow-{Guid.NewGuid()}", taskQueue: worker.Options.TaskQueue!));
        });
    }

And it succeeds as expected. Granted this is against main but I don't know of any changes since last release that would have affected this. Can you provide a standalone replication?

Closing due to no response.