What Guarantees Exist (If Any) for Draining Signals?

Hi,

Let’s say I have the following simple workflow.

func SimpleSignalWorkfow(ctx workflow.Context) error {
	err := workflow.Sleep(ctx, 24*time.Hour)
	ch := workflow.GetSignalChannel(ctx, "signal")
	var s string
	for ch.ReceiveAsync(&s) {
		workflow.GetLogger(ctx).Info(s)
	}
	return err
}

What guarantees exist, if any, that a signal won’t be missed? Couldn’t the Temporal server receive a signal for that workflow run after the worker existed the for-loop? Wouldn’t that result in a signal being dropped?

If so, how should I write this workflow to prevent signal loss?

Thanks!

Albert

Temporal detects the race condition you described, rolls back the workflow state to the Sleep line, and then executes the workflow with the new signal.

1 Like