Brash Apps

Get2pc

Imagine booking a flight + hotel package via get2pc:

Phase 1 (Prepare)

Phase 2 (Commit)

If the Hotel Service had replied "No" (room already booked), the Coordinator would send ABORT to the Flight Service, releasing seat 12A without charging the customer. get2pc

  • RIP-relative addressing on x86_64 reduces need for get2pc in many cases, but the CALL/POP idiom remains useful in position-independent trampolines or when generating data pointers.
  • ARM / AArch64:
  • ARM32 (Thumb/ARM):
  • PowerPC / MIPS / other RISC:
  • Language/compiler intrinsics:
  • Runtime helpers:
  • In the golden age of monolithic databases, maintaining consistency was easy. You hit BEGIN TRANSACTION, performed your updates, and hit COMMIT. The database handled the rest.

    Fast forward to microservices. Your payment service talks to inventory, which talks to shipping, which talks to analytics. Suddenly, that single database transaction is a relic. How do you ensure that money isn’t deducted without an item being reserved?

    Enter get2pc—a practical implementation of the Two-Phase Commit (2PC) protocol, adapted for distributed systems and often seen in saga orchestrators and transactional outbox patterns. Imagine booking a flight + hotel package via

    get2pc is a lightweight command-line utility and library that orchestrates two-phase commit (2PC) protocols across distributed resources (databases, message queues, or custom transactional systems). It ensures atomicity in environments where multiple independent services must either all commit or all abort a transaction.

    The name get2pc reflects its primary interaction model:

    “Get me a consistent, atomic outcome across distributed participants.” Phase 2 (Commit)

    Store transaction state (begin, prepare, commit) in a durable log.
    On crash, replay log to complete or abort pending transactions.

    get2pc abort --txid tx-001

    With Get2PC, a transaction is a single, indivisible unit. Either 100% of the value moves from A to B, or 0% moves. There is no scenario where you "see the money leave your account but never arrive." This is critical for high-value trades and large B2B settlements.

    The coordinator (not the database) asks every participating service: "Can you commit to this change?"

    During this phase, each service writes a "promise" to its own local database but does not release the change to the outside world. The data is in a pending or locked state.