Both shards said ready. Is the transfer committed?
1:14·Reel
Theory
Read or listen first. About 1 min.
What it is
Moving credits involves a local question at each shard and a shared question across them. Is the debit valid against the current balance? Will both shards finalize the same transfer outcome? Replicating each shard helps it survive a machine failure. A cross-shard transaction also needs agreement on whether this particular operation committed.
A prepared participant waits for the decision
Both shards durably prepare and promise that they can commit. Their reserved changes stay pending until a decision arrives.
Why it exists
In a prepare-and-commit protocol, a participant that promises it can commit must retain enough durable state to honor the eventual decision. If the decision is temporarily unavailable, independently guessing an outcome can leave one account debited and the other uncredited.
View diagram · Commit decisionRetrying the same intent must resolve its existing outcome. Full size
Words to know
Atomic commit
Participants agree on one outcome for all parts of a transaction.
Prepared state
A durable promise that a participant can commit if instructed.
How it works
Step through the idea, or press Play.
Step 1 of 3
Separate replication and commit. Consensus orders changes within a replica group. Atomic commit coordinates the outcome across participating groups. A quorum on one shard says nothing about whether the other shard debited its account.
Recover the decision. Prepared participants retain enough state to finish consistently. Consult the durable transaction decision after a timeout. Spanner combines replicated groups with distributed transactions spanning groups.
Bound retries. A timeout leaves the outcome unknown. Reuse the operation identity, check status, and retry within a deadline using backoff and jitter. If the business allows compensation, model its visible intermediate states explicitly.
Understand it
Start here
Follow transfer T17
Track receipt T17 as forty credits move from A to B. Watch the account values and the receipt separately: the money can move even when the client never receives the reply.
Follow transfer T17
Check the original transaction identity.
Structure
Commit decision
Commit decision
Retrying the same intent must resolve its existing outcome.
One missing acknowledgment
Debit 40 credits on shard A and credit 40 on B. Drop the reply immediately after a durable commit. Replay the same logical transfer. Check both account histories and the total across accounts: there should be one movement of 40, with the total unchanged.
Prepared work can occupy locks or other resources while the outcome is resolved. Long network paths and slow participants extend that interval. Place strongly related data together when the common operation needs a single commit boundary. If the data must span shards, monitor time spent prepared and the oldest unresolved transactions.
When intermediate states are acceptable
A travel itinerary can sometimes expose a flight reservation while a hotel request is pending, then cancel the flight if the hotel fails. That choice requires customer-visible states, a durable workflow, and a plan for failed compensation. Account balances that promise atomic movement impose a different contract. Choose the contract before choosing the protocol.
Resolve T17
Check the original transaction identity.
Create a new transfer
An unknown outcome can become a duplicate movement.
Balance after one transfer
(100−40)+(0+40)=100
Check transfer history as well: a second balanced transfer would also preserve the total.
Summary
The whole topic in one minute.
A missing reply is an observation about transport. Recover the durable outcome of the original operation before initiating another movement.