Skip to content

The region failed over. Which promises survived?

One order, five failure boundaries · Part 5 of 5 · 9 min read

Read the worked explanation ↓

The order platform has been working for months. Checkout retries find the same order. The outbox repairs missed publications. The warehouse tolerates duplicate events. When someone asks whether the system is reliable, all three teams say yes.

Then region A becomes unreachable. Region B is promoted even though its asynchronously replicated database is two seconds behind.

Interview question. Region A acknowledged checkout c781 and committed its order and outbox event. The warehouse received the event and reserved stock. Region B is promoted without the transaction. The client retries c781, and region B creates another order. Explain the failure. Define a contract that survives a regional loss, including which writes may be accepted, how the old primary is excluded, and when downstream effects may happen.

The two-second loss is a stated fact of this fictional scenario. Real incident analysis would establish it from durable histories and log positions rather than a dashboard's last lag sample.

Think first

A primary acknowledged an order after local commit. Its asynchronous standby is promoted without the transaction. The client retries while the warehouse already acted. Define the regional durability, fencing, and publication contract.

Take a few minutes to form an approach, then compare it with the worked explanation.

Reveal the worked explanation

The local transaction was not the broken part

In A, one database transaction committed the checkout identity, order o481, and outbox event e901. It became durable on A's local storage. The API acknowledged the checkout. The relay published e901, and the warehouse committed a reservation.

Before that database log reached B, A became unreachable. B had none of those three records. A retry with c781 found no matching checkout in B, so B created o902 and another event. The warehouse saw a different event ID and possibly a different fulfillment identity.

A: c781 -> o481 -> e901 -> stock reserved
                   replication not yet at B
A unreachable
B promoted: c781 not found
B: c781 -> o902 -> e1202

The original transaction did not partially commit. Its records disappeared together from the promoted history. Database atomicity was intact. The deployment had only promised durability on A before acknowledging the client. It had not guaranteed that every acknowledged decision would survive losing that region.

If the warehouse also stores c781 as a durable business identity, it might reject the second reservation. That is useful defense in depth. It does not restore the missing order, settle which order ID clients should trust, or repair divergent histories elsewhere.

Decide which guarantee matters before choosing a topology

I would ask product and operations a precise question: after losing one region, must every order previously acknowledged as accepted still be recoverable?

Suppose the answer is yes. Then the contract is not “the API usually responds quickly.” It is this: an accepted checkout maps to one durable decision that remains recoverable after any single supported region loss. If the surviving system cannot establish that decision or safely establish write authority, it may return an unavailable or recovery-pending result. It must not reinterpret an uncertain checkout as definitely new.

Three decisions follow. Which copy must store the decision before success is returned? Who can be the writer during a partition? And when can that decision cause irreversible downstream action? Those choices must agree.

Move the acknowledgment boundary

One option is synchronous cross-region replication, configured so a successful transaction has reached a durable copy outside A under the chosen failure model. But the failover policy must promote a history that contains those acknowledged transactions. Waiting for a remote acknowledgment is useless if an automated failover can later choose an older replica.

Another option is consensus-backed replication. For example, three full voting replicas placed in three regions can require two votes to commit. If one region fails and the other two can communicate, a majority may remain. The tradeoff is additional coordination, wide-area latency, and the possibility of refusing writes when quorum is unavailable. A leader-election service does not provide this protection if the order database still acknowledges writes only on its local disk.

We should not describe either approach as simply “strong consistency” and stop there. Which participants record the transaction? Which failure domains are independent? What exactly does the acknowledgment prove? How are changes to membership handled? What happens when an entire region becomes slow instead of fully unavailable?

There is also no requirement to impose this cost on every kind of data. An accepted purchase may need stronger survival guarantees than a recommendation impression. The API should make the difference understandable instead of silently changing durability settings in an incident.

Promotion needs to revoke old authority

A network timeout does not prove region A is dead. A may still be reachable by some clients. Merely changing DNS or a load balancer does not stop its existing writers.

The promotion protocol must prevent the old primary from continuing to accept consequential writes. Depending on the design, that may require a consensus term, an enforced fencing epoch, or verified isolation of the old primary. The enforcement point matters. Writing a higher generation number in a control-plane log does not stop a stale process unless the storage system or action destination rejects its work.

Data survival and single-writer authority are separate properties. Preserving every log entry does not help if two primaries continue producing competing decisions.

Do not publish work before the decision is recoverable

Now revisit the outbox. Suppose the order service has not acknowledged the checkout because it is still waiting for remote durability, but a local relay can already publish its event. The warehouse acts. A fails and the valid replacement lacks the order.

Even though the client never saw success, an external effect has escaped. For this strict contract, the outbox relay must not publish consequential work until the underlying order decision satisfies the same supported recovery boundary as the accepted-order contract. A locally visible row alone is not enough evidence of that condition.

The warehouse needs its own durable identity for physical fulfillment too. A shipment cannot be rolled back by editing a database record. If the warehouse loses its fulfillment receipt during its own failover, the order system's stronger guarantee does not automatically fix it.

Recover the incident without inventing another history

For the incident in progress, stop unsafe checkout decisions and consequential publication for the affected scope. Preserve A's logs and all surviving copies. Establish valid write authority first, then determine the actual gap in recoverable transaction history. A two-second lag figure does not identify precisely which operations were lost.

Correlate checkout IDs, order IDs, outbox event IDs, warehouse reservations, and provider receipts. Keep uncertain requests in a recovery state until their outcomes are established. If A comes back, do not merge the two histories by taking whichever timestamp is newer. Recover and reconcile under a defined authority procedure, including explicit handling of any physical side effects.

In an interview, the strongest answer is not “use three regions.” It specifies which acknowledged decisions survive, who may still write, and which effects are permitted to escape. Then it explains the latency, availability, capacity, and operational cost of making those promises.

You could reuse the same problem for a build platform that publishes artifacts to a registry. If the registry publication survives but the build platform restores an older database snapshot, a retry is not automatically safe merely because the original database transaction was atomic. The external result has a history of its own.

Go deeper

Questions the diagram does not settle

“Synchronous” has several meanings

In PostgreSQL, waiting for standby remote_write, durable flush, or replay are different acknowledgment choices. A durable acknowledgment on a remote standby offers a stronger survival boundary than waiting only for the standby to write to its filesystem cache. Waiting for replay also changes when the result is visible on standby queries. These options must be configured with actual synchronous standbys. An appealing setting name alone is not evidence of a cross-region durability guarantee.

The failover policy is just as important as the write setting. If the application waits for replica X but the failover manager later promotes replica Y, which lacks the transaction, the acknowledgment rule has not delivered the promised outcome under that promotion policy.

An alternative is a database with a quorum-backed write protocol. A three-region, three-voter example can commit after a majority of two durable votes, under its specified protocol and failure model. A majority must still be reachable after failures. Some deployments use more replicas, voters and witnesses for different reasons. Do not assume that adding a witness without data is sufficient to make the order itself region-durable.

What happens to availability?

If remote durability is required for checkout success, a partition may stop new checkouts even while one region can still respond to reads. A product that insists on immediate checkout confirmation from every disconnected region is asking for a different guarantee. It may need preassigned ownership, inventory escrow with disjoint rights, or permission to reconcile conflicts later. None is an invisible optimization to the original single-decision contract.

A customer may prefer a truthful pending response to a fast but unsafe second order. That product behavior is part of the system design, not something to leave to error-message wording at the end.

Two primaries and the resource that enforces authority

A new lease or generation helps only when writes from the old generation are rejected by the resource that could be damaged. DNS, client routing and health checks do not prove an old primary has stopped executing. A failover protocol needs a verified authority transition, effective fencing, and tests for a partitioned primary that later reconnects.

When the old primary returns with extra transactions, do not choose the larger timestamp and merge rows casually. Preserve its history, establish the authoritative branch through the chosen recovery procedure, reconcile affected business effects, then rebuild or rewind replicas as supported. PostgreSQL pg_rewind is a mechanism for realigning data directories, not a method for merging two order histories at the application level.

External work makes the durability question sharper

An outbox row can become locally visible before a strict remote acknowledgment completes. Under a recovery contract that may later discard that locally visible transaction, publishing consequential effects from it too early can leave the warehouse with a reservation for an order the valid replacement does not know about.

The publisher therefore needs an eligibility rule tied to the recoverable decision boundary, or a workflow whose authoritative decision already satisfies it. That is a deliberate design requirement. The outbox pattern by itself does not impose it.

Apply the same scrutiny to the warehouse's own database and provider. If the fulfillment decision disappears during its failover after a physical shipment survives, a retry is again ambiguous. Each irreversible effect must have an identifiable, recoverable result at its real owner, or a provider that can reconcile the outcome.

Finally, distinguish recovery point objectives from dashboards. A sampled “two seconds of lag” is not the same as proving precisely which acknowledged decisions may be lost. Recovery needs durable log positions, candidate histories, publication records, and evidence from downstream systems.

Check your reasoning

  • Explains that the order, operation identity, and event vanished together from the promoted history
  • Defines exactly what success must survive and when unavailable or pending is acceptable
  • Pairs durable remote acknowledgment or quorum commits with a promotion policy preserving acknowledged transactions
  • Excludes stale writers through an enforced authority transition
  • Prevents external publication before the accepted decision satisfies its recovery boundary and describes reconciliation

Common mistake: Changing DNS to the new primary does not revoke authority from the old primary, and a consensus lock does not make locally acknowledged database records region durable.

Region A locally commits an order and begins replicating to B. Your contract says an accepted order must survive loss of A. When can the API return success?

Read the answer explanation

After the required remote durability or quorum commit is established under a matching promotion policy — The acknowledgment must prove the decision survives the supported failure, and failover must choose a history containing those acknowledged decisions. Local atomicity alone does not establish regional survival.

Apply it elsewhere

A build platform publishes a signed release artifact to a registry, then restores its database from an older regional snapshot. A retry arrives with the same release ID. Which authority and history do you consult before republishing?

Compare your approach

Keep the release intent identity stable, treat the restored database as potentially incomplete, and reconcile against the registry's durable publication result and other surviving logs. Reestablish one publication authority before retrying. Prevent downstream publication until the release decision meets its defined regional recovery boundary.

One more constraint

A two-region network partition leaves both regions reachable by some clients. Can both accept the same unseen checkout identity immediately while promising no duplicate order?

Quick revision

The answer in an interview

The first order transaction was atomic but became durable only in region A before the client received success. Region B was promoted without that transaction, so it lost the order and its operation identity together. The warehouse's earlier reservation survived, leaving conflicting histories.

I would start by defining the promise. If an acknowledged checkout must survive a region loss, the acceptance path needs an appropriate cross-region durable acknowledgment or a quorum-backed decision, and promotion must select a history containing those acknowledged decisions. That costs latency and may require refusing writes during a partition.

Failover also has to exclude stale writers through an enforced authority change, not only DNS updates. Consequential outbox publication should wait until the order decision satisfies the required recovery boundary. The warehouse needs its own durable fulfillment identity.

During an incident I would preserve divergent histories, establish authority, reconcile client and warehouse outcomes, and keep uncertain checkouts pending until evidence resolves them.

Trap: Region durability and fencing stale writers are separate guarantees. One does not imply the other.

References

  • Log-Shipping Standby Servers · PostgreSQL 18 documentation

    Asynchronous replication loss windows and synchronous-standby availability planning.

  • Write Ahead Log: synchronous_commit · PostgreSQL 18 documentation

    Differences among local, remote_write, durable standby acknowledgment, and remote_apply.

  • Failover · PostgreSQL 18 documentation

    Preventing an old primary from returning as a competing authority.

  • FAQ: Failure tolerance and cross-region deployments · etcd 3.6 documentation

    Majority requirements, failure tolerance, and remote communication costs in consensus.

  • pg_rewind · PostgreSQL 18 documentation

    Rejoining a diverged history. Rewind is not a business-level merge or reconciliation tool.