A version never changes
Faster on purpose, promoted to production without a rebuild, and an exact rollback.
Durable workflows live a long time. A transfer waiting for a person's review may sit for days; a batch may run for hours. In that time the code will change. Which version does a running workflow follow, and what happens when a new version turns out to be worse?
Cube Root's answer is that a version never changes. Each publish is a new version with its own mark. It is promoted from environment to environment as it is, and a rollback puts back the exact routing that was there before.
This article follows one small flow through those steps. It is lesson 1 of the tutorials in the browser IDE.
The flow, and making it faster
public class TwoSquares {
public String invoke(Integer n) {
long a;
long b;
a = Slow.square(n);
b = Slow.root(n);
return a + " " + b;
}
}
Slow.square and Slow.root are plain Java methods that take about 1,000 ms each, on purpose. Written like this they run
one after the other: about 2,000 ms.
Neither line reads what the other produces, so they could run at the same time. Mark both:
eager: a = Slow.square(n);
eager: b = Slow.root(n);
An eager: line starts the moment what it reads is there, on a thread of its own. The flow now takes about 1,000 ms. View
execution graph shows the two lines side by side and the return waiting for both. Like every label, eager: is a hint
the compiler checks: one that would race is refused, by name.
Changing the code makes a new version. The old one is not edited; it is still there, with its own mark.
From your own environment to production
Every developer has their own environment, where a new version first runs. From there it is promoted to a stage, then to production.
| Step | What happens |
|---|---|
| Publish | a new version, with its own mark, in your own environment |
| Promote to a stage | the same version, never rebuilt, on the stage's machines |
| Promote to production | the same version again, on production's machines |
Nothing is compiled twice. What was tested on the stage is, byte for byte, what runs in production. Each environment has its own machines: a stage under test does not share production's.
A rollback that is exact
Suppose the slower version reached production by mistake. The fix is Undo: it takes back the newest change and puts back the exact routing that was there before it. Not "redeploy what we think was running", but the routing as it was, because every routing change was recorded with the one before it.
Conversations already running keep the version they started on; new ones follow the restored routing.
Why "never changes" matters for durable work
In a replay-based engine, changing workflow code while old workflows are still running is delicate: the old workflows will replay through the new code, so the change must be written to replay the old history correctly, often with explicit version checks in the code.
When a version never changes and work continues from rows rather than replay, that problem has a simpler shape. A running conversation follows its own version to the end; a new version starts new conversations. The code carries no version branches.
Try it
All three steps are short video lessons on the tutorials page, and the flow is in the Basics sample of the browser IDE at cube-root.com.
This is the last article of the series. The first, durable execution without an SDK, starts with a money transfer.