microsoft / durabletask-mssql

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

Timer events fire before completion #50

Closed vivogaet closed 2 years ago

vivogaet commented 2 years ago

When there are multiple event all timer fire up before reaching the scheduled time, the relatives tasks resulting as completed.

I think the issue originated in the stored procedure _LockNextOrchestration, in fact while the condition at line 38 prevents to select an orchestration awaiting a single Timer event before the scheduled time it not prevents the selection of orchestrations having multiple events (including, eventually some timer).

In order to resove the issue I suggest to add the same condition at line 65 and 98.

Tanks. Gaetano.

cgillum commented 2 years ago

Thanks for filing this issue and for pointing out the problematic lines of code! I was able to write a unit test to confirm the bad behavior and will look into making a fix.