dine. a kitchen run by sagas Book a table
Log in with Google (coming soon)

Articles

Tiếng Việt · English

Late success: the order is cancelled, yet a service reports done

October 14, 2026 · about 6 min read

Payment declines the card, and the order is cancelled at once. A few hundred milliseconds later, the table service reports "done", and then the kitchen reports "done" too. The order is already cancelled, so how can anyone still be finishing work? This is not a bug; it is perfectly normal in a system where the services run in parallel and do not wait for each other. This article is about how dine deals with it.

What happens

When an order is created, order sends commands to all three services at the same time. Each one does its own job and answers when it is done; whoever is fastest answers first. No ordering is guaranteed.

Suppose payment answers first, and the answer is "failed". order cancels the order right away. At that point no service has reported done yet, so there is nothing to undo. But the table service and the kitchen had already received their commands and are midway through. They do not know the order has been cancelled, so they finish and report "done". The table really was held, the ingredients really were taken.

Timeline of the sample order "Early failure, others finish late": payment fails at 0.35 seconds and the order is cancelled; the table reports done at 0.62 seconds and the kitchen at 0.81 seconds, each undone separately; at about 1.2 seconds the order goes back to cancelled. reservation kitchen payment 0.35s 0.62s done late 0.81s done late order processing cancelled reopened: undoing cancelled Red square: failure. Striped: done after the order was cancelled. Blue ring: undone.
The sample order "Early failure, others finish late". The order is cancelled at 0.35 seconds, then reopened to clean up the two late jobs, and goes back to "cancelled" once the cleanup is done.

Why not wait for all three before deciding

There is one way to never run into this: when a service reports a failure, order keeps waiting until all three have answered, and only then cancels, undoing everything in one go.

dine does not do that, because "waiting for all three" can mean waiting a long time. If one service has gone silent, the order would hang for the full 5 seconds before it could be cancelled, even though the failure was clear from the first second. Cancelling right away means the guest learns the outcome sooner, and whatever has been finished is released sooner.

The price is that, now and then, one more late job has to be cleaned up. dine chooses to decide fast, clean up later. This is a choice, not a requirement: another system might choose to wait for everyone before deciding, if for them undoing costs more than waiting.

What has happened must be undone

When order receives a "done" reply for an order that has been cancelled, it cannot ignore it. The table really was held; ignore it, and that table stays held forever for an order that no longer exists. So order does exactly this:

  1. Reopen the order, from "cancelled" to "undoing".
  2. Send a separate undo command to exactly the service that just reported done late. Nobody else gets it again.
  3. When that service reports the undo is done, the order goes back to "cancelled".

If several services are late, each one gets its own undo command as soon as it reports done, without waiting for the others. The order only goes back to "cancelled" once every undo command has finished. The undo itself works exactly as described in Compensation is not rollback: release the table, return the stock, refund the money.

"Cancelled" is not necessarily the end

This leads to something slightly odd: dine's two outcomes, "done" and "cancelled", are not equally final.

This follows directly from the "decide fast, clean up later" choice above. When reading the state of an order at dine, keep this in mind: a "cancelled" order has only truly settled when it has no step left that is being undone.

What if a late reply is a failure

The opposite case is much simpler: the order is cancelled, and a service arrives late reporting "failed". That service did not get anything done, so there is nothing to undo. order just records it and does nothing more.

Put together, every reply order receives falls into one of four cases:

ReplyOrder still runningOrder already cancelled
DoneRecorded. Once all three are done, the order succeeds.Reopen, undo this service on its own.
FailedCancel the order, undo the services that finished.Do nothing.

The bold cell is the subject of this article. The two cells in the "Order still running" column came up in earlier articles. dine's order detail page shows which cell each reply falls into, when you open the technical chart below the diagram.

See it for yourself

To try it yourself, log in, press Book a table and turn on “Incident test”: have the payment declined and set payment to answer first. On the diagram, the other two services will show a striped "late" box.

Spotted a mistake, or have a question? Write to [email protected].

dine is a personal project about distributed systems, written in Go: orchestrated sagas, transactional outbox, Kafka. More articles.