Does Temporal Cluster guarantee atomicity of function execution?

Hi everyone! My question is about the atomicity of execution Workflow Functions and then saving the results of commands.
For example, Worker Entity has completed Workflow Function, that did some action like sent email,
but not saved yet state in Temporal Cluster. Then my Worker Entity has crushed
(for example, the host was disconnected from electricity).
Will Temporal Cluster schedule that Workflow Function again and process it again?
As a result, I will receive email twice. I want to execute activity exactly once and have guaranty of atomicity. Will help me Temporal Cluster?

Hi @andrey,

Welcome to the Temporal Community,

Yes, if the worker crash before notifying Temporal Server about an activity completion, the activityTask is gonna timeout, and as you have mentioned, the activity is gonna be rescheduled to be executed by another worker.

One thing you can do is to use heartbeat from inside your activity to notify the Temporal Server about the activity’s progress. So the next time the activity is executed, you can skip sending the email.

Temporal Server has to be notified somehow about the workflow progress.

@antonio.perez Thank you!