Java 102: how is Workflow Task data saved between worker crashes?

Hi, first time posting, new to Temporal, new to this forum. Please tell me if this is the wrong place for this question.

I’m working through the Java 102 course, currently on the ”Understanding Workflow Determinism” chapter, watching the “History replay: How Temporal Provides Durable Execution” video.

Mason is talking about the events in the workflow history. I see there are Workflow Tasks, and Activity Tasks. As I understand, the difference is that the latter issue commands to the Temporal server/cluster, and in doing so send the activity input data which the cluster can persist in case a replay is needed.

My question is this: if I have a Workflow Task that does some calculation or has some data (possibly derived from the result of an earlier Activity Task), what happens if the Worker crashes after that Workflow Task is completed? A new Worker can continue the Workflow with the recreated state of the crashed Worker, but where is workflow data saved between Workers?

For example (in Scala using Java SDK),

@WorkflowInterface
trait Greeting:
  @WorkflowMethod
  def greetSomeone(name: String, question: String): String

class GreetingImpl extends Greeting:
  override def greetSomeone(name: String, question: String): String =
    val result1 = activities.getGreeting(name)
    val s = "prefix " + result1
    val result2 = activities.getAnswer(question)
    s + result2

What if the Worker crashes while the second Activity Task is running? Another Worker can resume progress on the workflow, correct? But how will it know what the value of s was? Looking in my event history I see that Activity Task input is sent from the client to the Temporal cluster, but I don’t see the word “prefix” anywhere in the output of temporal workflow show --fields long. Is the value of s saved somewhere, or is result1 saved and the statement that generates s re-executed using the saved result1?

Update: I have now finished the video which seems to have answered my question. The results of (possibly non-deterministic) Activity Tasks are persisted by the Temporal cluster and therefore need not be re-executed after a crash. The results of Workflow Tasks can be re-evaluated because they are deterministic, and therefore need not be persisted before a crash.

Yes, you’ve got it.

By relegating non-determinstic code to Activities, the deterministic code in the Workflow Definition can be re-executed safely, since it has no side effects. The result returned by an Activity is persisted into the Event History, which another Worker will request upon taking over for one that crashed. When the new Worker reaches a call to execute an Activity, it will evaluate the history to determine if it ran prior to the crash. If so, it uses the earlier result instead of executing the Activity again.