When One Commit Spans Multiple Services: Trade-offs Across 2PC, 3PC, CAP, and TCC

A single-node transaction keeps commit and rollback inside one database. Once an operation crosses a database or service boundary, things change: one node finishes while another stops responding, and the coordinator can’t tell whether the other side failed or its success reply was just delayed. At that point, committing is only part of the problem. You also have to decide whether to wait during a failure, how to resume after recovery, and how to keep retried messages from running the same operation twice.

2PC, 3PC, and TCC all try to coordinate a commit across nodes, while CAP, asynchronous replication, and Quorums explain why you always have to give something up once a network partition hits. Putting them side by side makes it much easier to tell which mechanisms are solving atomic commit, and which are tuning the boundary between consistency and availability.

Once an operation spans two nodes, the problem isn’t just rollback

Suppose an operation has to update both Node A and Node B. A finishes its local transaction, while B never replies. All A observes is silence: B might have crashed, might still be working, or might have committed just fine with the response lost in transit. If A rolls back unilaterally, B may have already committed. If A goes ahead and commits, B may have never finished.

A network timeout only tells you that waiting exceeded some limit; it never proves the remote side didn’t execute. So distributed transaction protocols have to solve two problems at once: getting every participant to converge on the same outcome, and keeping each node in a recoverable state while the outcome is still undecided.

That is what makes distributed transactions harder than local ones. A single database process can no longer guarantee atomicity on its own. Instead, you have to build it out of multiple message rounds, durable state, and crash recovery.

2PC trades two rounds of communication for a single decision

Two-Phase Commit (2PC) introduces a coordinator alongside the participants. Instead of assuming everyone can commit, the coordinator collects votes first and broadcasts the global decision second.

The first phase is usually called Prepare. The coordinator asks every participant whether it can commit. Each participant runs its local checks, writes recoverable transaction state to durable storage, and holds whatever resources it will need to commit. Voting yes is a promise: the participant is ready to commit later and can no longer back out unilaterally.

1
2
Coordinator ── Prepare ──→ Participants A, B, C
Coordinator ←── Yes/No ── Participants A, B, C

In the second phase, the coordinator tallies the votes. Only if every participant votes yes does the coordinator record a Commit decision and tell everyone to commit. If even one participant votes no or fails to prepare, the coordinator tells everyone to Abort. Once participants finish the second phase, they release the resources held since Prepare.

1
2
All voted yes:   Coordinator ── Commit ──→ A, B, C
Any voted no: Coordinator ── Abort ──→ A, B, C

On the happy path without failures, Prepare and its votes make up one round, and the final decision and its acknowledgments make up another, for two round trips in total. The cost isn’t just network latency: while a participant sits in the Prepared state, it may keep holding locks or other resources until the global outcome arrives.

Why participants can’t just roll back when the coordinator crashes

The most awkward spot in 2PC is when a participant has voted yes to Prepare, but hasn’t yet received the phase-two decision. If the coordinator disappears right then, the participant cannot safely roll back on a timeout, because the coordinator might have already decided Commit and sent it to other participants. It cannot safely commit on its own either, because another participant might have voted no in phase one.

Adding a watchdog or standby node for the coordinator improves recovery, but a standby cannot safely take over just by “asking everyone again.” At a minimum, it needs access to the coordinator’s durable transaction log to check whether a global decision was already written, plus reliable leader failover and fencing so the old and new coordinators don’t run at the same time. Participants likewise need to persist Prepared, Committed, or Aborted states so they can resume unfinished transactions after a restart.

If the original coordinator’s decision cannot be recovered and another participant is also down or unreachable, the new coordinator lacks the information required to make a safe decision. The remaining participants have no choice but to wait. That is 2PC’s blocking problem. Durable logs and high-availability coordinators shorten recovery in many failure scenarios, but they don’t change the protocol’s basic limit: when information is missing, participants have to wait.

3PC adds a phase for conditional non-blocking

Three-Phase Commit (3PC) inserts a PreCommit phase between asking whether participants can commit and executing the final commit. First, the coordinator collects yes votes from everyone; next, it tells everyone to enter PreCommit; only after participants acknowledge PreCommit does the coordinator send the final Commit.

1
2
CanCommit?      →  PreCommit              →  DoCommit
Collect votes Propagate commit intent Execute decision

That extra state gives participants more information. A participant that times out before entering PreCommit can lean toward aborting; one that has already entered PreCommit knows everyone previously agreed to commit. Under crash-failure models with bounded communication delays, nodes can use these states and timeout rules to keep moving forward instead of blocking indefinitely on a dead coordinator.

Still, 3PC cannot guarantee both atomicity and non-blocking behavior under arbitrary network partitions. Two isolated partitions can act differently based on what each side sees, and if they wait to avoid diverging, blocking comes right back. It also costs an extra round trip compared to 2PC. 3PC is more useful as an example of how an extra layer of shared state reduces blocking than as a fix for every failure mode in 2PC.

Recovering participants from durable logs isn’t unique to 3PC either. XA resources in 2PC also persist Prepared branches and support recovery scans. What 3PC actually adds is a new protocol state along with timeout-based decision rules tied to it.

CAP only forces a choice when a partition happens

The three terms in CAP have fairly strict definitions:

  • Consistency means linearizability. After a write succeeds, subsequent operations behave as if every request executed against a single, real-time-ordered copy of the data.
  • Availability means every request reaching a non-failing node eventually receives a response. It is about whether requests terminate, not about fixed latency SLAs from everyday monitoring.
  • Partition Tolerance means the system continues operating according to its rules despite arbitrary message loss or network isolation between nodes.

CAP does not ask you to pick two letters out of three during normal operation. When there is no network partition, consistency and availability can both hold. Only when a partition actually occurs must the two disconnected sides choose between C and A. Keeping linearizability forces a side that cannot confirm the latest state to reject or stall requests, sacrificing availability. Letting both sides keep accepting requests risks creating mutually invisible versions, temporarily giving up linearizability.

In engineering practice, P isn’t a toggle you can switch off. Network and node faults can never be permanently ruled out, and from an observer’s perspective, a crashed remote node and continuous packet loss to that node can look identical. Conceptually they are different, yet both produce the exact same inability to know the other side’s state.

Linearizability isn’t the only consistency model either. Sequential consistency requires all operations to form a single global order that preserves each client’s own program order, without requiring that order to match real-world wall-clock time. Eventual consistency lets replicas diverge temporarily, guaranteeing only that they converge once new updates stop and communication resumes. Which constraint you relax determines how much availability and performance headroom you get back.

Asynchronous replication and Quorums don’t bypass CAP

The typical asynchronous replication path is straightforward: the primary writes locally, returns to the caller, and propagates the change to replicas afterward. Writes don’t wait on replicas, which cuts latency, but reading from a lagging replica before sync finishes can return stale data. On its own, asynchronous replication cannot provide strongly consistent reads. If multiple isolated nodes accept writes concurrently, you also have to resolve version conflicts.

Quorums express replica access rules with N, W, and R: N is the total number of replicas, W is the number of replicas that must acknowledge a write, and R is the number that must respond to a read. When R + W > N, the read set overlaps with the most recent successful write set by at least one replica. When you also need to prevent two write sets from being completely disjoint, you typically require W > N / 2.

Overlapping sets are an important foundation for seeing newer versions, but by themselves they do not establish full linearizability. You still need version comparison, ordering of concurrent writes, failover handling, and conflict resolution. And when a partition strikes, if one side cannot assemble the required W or R replicas, it has to reject requests; if you lower the threshold so both sides keep writing, you accept temporary divergence and reconcile later.

Dynamo, built with high availability as a primary goal, explicitly gave up consistency under certain failures and relied on object versioning and conflict resolution to converge replicas later. That doesn’t mean Quorums give you all three letters of CAP. What N, R, and W actually do is turn the trade-off among consistency, latency, and availability into a configurable policy.

Why retrying alone isn’t enough when acknowledgments go missing

Uncertainty in distributed transactions echoes the Two Generals’ Problem: over an unreliable channel, a sender can never gain absolute certainty that both sides know the outcome through any finite number of acknowledgments. Resending after a timeout raises the odds of eventual delivery, but it introduces another problem: the previous message might have already run, with only its reply lost.

That is why retries must be designed alongside idempotency. Every transaction or branch needs a stable unique identifier, and each participant has to record whether it has already processed a given phase. If the same Commit, Cancel, or business request shows up again, it should return the existing result rather than deducting inventory, transferring funds, or releasing resources a second time. The coordinator also has to persist its state so that after a restart it resumes from where it left off instead of starting a brand-new transaction with the same intent.

Retrying isn’t a guarantee of eventual success either. Permanent faults, business validation errors, and conflicts that can’t be resolved automatically still need timeout termination, alerting, reconciliation, or manual intervention. Idempotency keeps duplicate executions from creating extra side effects, while persistence and recovery let unfinished work survive process restarts. Together they limit the impact of uncertain states.

TCC moves two-phase commit up into business APIs

Classic 2PC typically coordinates databases and message brokers via the XA protocol. A transaction manager invokes each resource manager’s Prepare, Commit, and Rollback hooks, which works well when every participating resource implements the XA contract. Microservices, on the other hand, mostly compose business logic over RPC, so the coordinator can’t directly control each service’s internal database transaction. TCC responds by turning prepare, commit, and rollback into explicit business APIs.

TCC stands for Try, Confirm, and Cancel:

  • Try validates business preconditions and reserves resources, such as freezing a credit limit or holding inventory, without completing final consumption.
  • Confirm finalizes use of those reserved resources once every Try succeeds.
  • Cancel releases the reserved resources if any Try fails or the global transaction aborts, returning the service to a clean business state.
1
2
3
4
5
Try(A) ─┐
Try(B) ─┼→ All succeed → Confirm(A, B, C)
Try(C) ─┘

Any fails → Cancel(branches whose Try succeeded)

Structurally, TCC is an application-layer two-phase protocol. It doesn’t require XA support from underlying stores, and it lets you define resource-reservation granularity in business terms. The trade-off is that transaction semantics move straight into service code. Every participating service has to implement all three operations and handle idempotency, retries, and recovery for Confirm and Cancel.

Real implementations also have to guard against two classic timing anomalies. The first is an empty rollback (or null cancel): the coordinator never confirmed that Try succeeded, yet sends Cancel after a timeout. The service has to safely record that the branch was canceled without causing bogus side effects for a reservation that never happened. The second is a hanging Try: Cancel has already run, and then a delayed Try finally arrives. The service must recognize the transaction is already closed and refuse to reserve resources all over again.

Phase two in TCC is normally driven by persistent coordinator retries, yet “keep retrying” still needs an operational exit hatch. Branches that cannot finish automatically must surface into alerts, reconciliation jobs, or manual repair flows. TCC turns cross-service transactions into compensatable, recoverable business workflows, but it does not give you database-level isolation for free. What Try reserves, and what other requests are allowed to see, must be explicitly modeled in the business logic.

These models don’t operate at the same layer

Approach Primary target Main advantage Cost or boundary you accept
XA / 2PC Databases, message brokers, and other XA-capable resources Transaction manager makes a unified commit/abort decision Prepared state can hold resources; blocks when coordinator state is unavailable
3PC Atomic commit under specific failure and timing assumptions PreCommit reduces blocking in certain crash scenarios Extra round trip; still cannot guarantee both safety and non-blocking under network partitions
TCC Cross-service business resources No XA dependency; business-controlled reservation granularity Heavy code intrusion; must handle idempotency, empty rollbacks, hanging Tries, and manual recovery
Async Replication / Quorum Multi-replica reads and writes of the same data Tunable trade-off among consistency, latency, and availability Not cross-resource atomic commit; guarantees depend on read/write thresholds and conflict resolution

Before picking a mechanism, clarify whether your problem is “multiple resources must commit atomically” or “one dataset needs fault tolerance across replicas.” The first is about global transaction decisions; the second is about replica consistency and service behavior during partitions. Mixing the two up leads people to mistake eventually consistent replication for a transaction commit, or to expect 2PC to stay available across a network partition.

Every distributed transaction runs into the same constraint in the end: a node can only act on its local state and the messages it has received. What protocols can do is persist richer recoverable state, define legal actions after timeouts, and route the genuinely undecidable cases to retries, reconciliation, and human operators. Which model fits a given system starts with the capabilities of the participants, the inconsistency window you can tolerate, how long resources can stay locked, and how you plan to recover when things break.