Coordinator failure and decision recovery
Use durable state and transaction identity to resolve prepared work without inventing outcomes after a timeout.
On this page
The question for today
What you’ll understand
- Classify coordinator crashes by their last durable state.
- Explain recovery obligations after a commit record exists.
- Separate resolving participant outcomes from forgetting coordinator metadata.
A coordinator fails halfway through a transfer, leaving an operator with three dashboards and an old transaction identifier. The tempting response is to choose whichever outcome clears the alerts fastest. A correct recovery procedure instead asks what the protocol has already promised and which recoverable record can establish that promise. Recovery is part of transaction execution, not an administrative exception to atomicity.
Recover from records rather than remembered messages
List failure points before prepare, after some participants prepare, after all yes votes, after the decision becomes durable, and after only some decision messages arrive. These states can look similar from one participant’s viewpoint. The coordinator’s recovery rule must distinguish them using durable information and the protocol’s documented defaults. A conventional coordinator may recover an undecided transaction by choosing abort when no commit decision was ever made, but an individual prepared participant cannot infer that absence merely because it cannot reach the coordinator.
Once commit is durably decided, recovery must preserve commit and redeliver it to required participants until they can complete. Aborting the remaining participants would not repair the failure; it would create disagreement with participants that already committed. Keep transaction identifiers stable across retrying decision delivery. A newly elected coordinator must be fenced from an obsolete owner and must read the authoritative state under the replication protocol. A fresh process with an empty memory map is not evidence that no decision exists.
Prepared state has an owner and a cost
A prepared transaction can retain locks and recovery metadata while waiting for resolution. PostgreSQL exposes prepared transaction identifiers and preparation times through pg_prepared_xacts. That inventory helps locate an external transaction manager’s unresolved work; it does not determine commit versus rollback by itself. Store enough application correlation to identify the owning workflow and decision authority. Avoid putting secrets or personally sensitive payloads into identifiers merely for convenient incident searches.
Resolution should be idempotent at the logical protocol level. A participant may process a commit decision and lose its acknowledgment, causing the coordinator to send the same decision again. Preserve enough terminal knowledge or reconciliation evidence to distinguish already completed work from a different transaction. Only forget coordinator state after the protocol’s acknowledgment and recovery conditions permit it. Prematurely deleting the record can turn an ordinary retry into an unresolvable ambiguous state, even if every server is otherwise healthy.
Replicate the authority without guessing its meaning
A replicated decision service may continue when one node fails if its consensus, storage, and fencing conditions hold. This improves the availability of evidence; it does not transform an undecided transaction into a committed one. Record both the decision-service epoch and transaction identity when the design requires them. Test coordinator restart after persistence but before reply, participant restart while prepared, and repeated decision delivery. The checker should inspect recovered decisions and effects, not merely whether the retry returned a success status.
In the reliability lab, press Reset, set replica count to 3 and unavailable count to 1, predict majority availability, then Step. For a separate run, Reset and explicitly set both counts to 3 and 2, predict, then Step. The model counts two versus one available replicas; it contains no consensus messages, persistent decisions, or fencing. Use that limitation to explain why a majority indicator is only one input to a decision-service availability argument, and cannot select a prepared transaction’s outcome.
Work it through
A crash after the decision record
A coordinator durably records commit for a three-participant transaction. A and B apply commit; C is still prepared when the coordinator crashes. Ten seconds later the coordinator recovers its commit record and reaches C after two more seconds. C applies the decision in one second.
At the crash, A and B have final commit decisions and C is undecided. C’s prepared state cannot safely choose abort based solely on the coordinator’s absence.
Recovery at ten seconds reads the durable commit decision. Redelivery reaches C at twelve seconds, preserving the same transaction identity and outcome.
C finishes at thirteen seconds. Its unresolved interval after the crash was thirteen seconds, even though the decision had already been durable throughout that interval.
Recovery completes the existing commit. It does not rerun the transfer as a new transaction or undo the two participants that already committed.
The living notebook
Explore the model
Interactive lab · reliability
Can the decision service still form a majority?
Reset, set replica count n = 3 and unavailable count k = 1, predict majority availability, then Step. Compare another Reset with both n = 3 and k = 2, predicting before Step. No transaction decision, log recovery, or fencing is simulated.
- Available replicas
- 4 of 5
- Majority needed
- 3
- Majority available?
- Yes
A replica count and a majority threshold, without a consensus protocol. Playback highlights fixed replica states. Having a majority alone does not establish linearizability, durability or failure independence. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forAvailability of a decision authority and the content of its durable decision require separate evidence.
Pause & reason
Check your understanding
Your turn
Try it yourself
A recovery inventory contains 2,400 unresolved transactions, each uniquely retaining 3 KiB of tracked coordinator metadata. Compute that category’s size. Then explain why deleting the oldest half merely to reduce memory is not a correct recovery policy.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Calculate the inventory before considering the semantics of its records.
Compare with the solution
The category is 2,400 × 3 = 7,200 KiB, about 7.03 MiB. Age does not determine the recorded or still-possible outcome. Deleting unresolved records may remove the evidence required to complete prepared participants safely. Resolve or archive them according to the transaction manager’s recovery and forgetting protocol; measure retained locks and logs separately from this metadata estimate.
Keep the idea
Take it with you
- A recovered commit decision remains commit even when delivery was partial.
- Prepared-transaction age identifies work to investigate, not an outcome to invent.
- Decision retention, stable identity, replication, and fencing belong in recovery design.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.