temporalio / features

Behavior and history compatibility testing for Temporal SDKs
13 stars 15 forks source link

[Feature Request] Workfow sleep/await with 0 duration #145

Open tsurdilo opened 1 year ago

tsurdilo commented 1 year ago

Example:

 Workflow.await(Duration.ofSeconds(n), () -> condition);
 activities.doSomething(...);

Workflow.await / sleep produces different sequence of events if n<=0 and when n>0 (basically if n>0 will have TimerStarted event from command in history, if n<=0 TimerStarted event is not in history) Similar for Workflow.sleep

This can cause non-deterministic issues during replay, if user calculates n in workflow code (even if they do not use system time, but some initial wf inputs so code itself is deterministic).

Feature request is for SDKS not to cause non-deterministic failure here and replay the workflow task but to log it and dont fail. Another option could be to fail workflow task with like "duration cannot be 0" or similar message but first option imo would be preferred if possible

Workarounds are currently for the "n" calculation to be done inside side effect or local activity/activity so n is not re-calculated on replay each time.

cretz commented 1 year ago

Workflow.await / sleep produces different sequence of events if n<=0 and when n>0 (basically if n>0 will have TimerStarted event from command in history, if n<=0 TimerStarted event is not in history)

Can you confirm this is happening in all SDKs or is this server behavior? I would guess some (most?) SDKs don't inspect the value before sending to the server.