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.
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.
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.