microsoft / durabletask-mssql

Microsoft SQL storage provider for Durable Functions and the Durable Task Framework
MIT License
87 stars 32 forks source link

WaitForOrchestrationAsync does not work #121

Closed mol-pensiondk closed 1 year ago

mol-pensiondk commented 2 years ago

The call

var os = await _taskHubClient.WaitForOrchestrationAsync(orchestrationInstance, TimeSpan.MaxValue);

never finishes (that is, the task never finishes) with the MSSQL backend. It works fine with the Azure Storage backend, returning the orchestration status once the given orchestration instance has reached a final state.

cgillum commented 2 years ago

@mol-pensiondk can you provide a simple reproducer for this? Nearly all of our orchestration integration tests indirectly depend on this API (reference).

mol-pensiondk commented 2 years ago

@cgillum: While simplifying my code to provide a reproducer, I found that the problem is actually not (as I originally thought) that the task never finishes, but rather that the call to WaitForOrchestrationAsync itself throws an exception (this was hidden from me before because the code making the call ran in a background task that was not awaited). The problem is that here the constructor of CancellationToken throws because TimeSpan.MaxValue is out of range. Replacing TimeSpan.MaxValue in my call with TimeSpan.FromMilliseconds(Int32.MaxValue) avoids this and then the task is started and finishes on orchestration completion as expected.

The Azure Storage backend accepts TimeSpan.MaxValue and it would be nice if the MSSQL backend too would not limit the TimeSpan values allowed in WaitForOrchestrationAsync; TimeSpan.MaxValue is to me a natural way to indicate that no timeout is wanted.