Skip to content

Atomic

atomic = all or nothing distributed transactions

  • transaction - an operation
  • distributed - one operation made up of many operations on multiple decoupled systems transactional = atomic = all or nothing

example: transactions to withdraw from bank A and save to bank B (either all are complete, or non complete), shouldn’t be a case where half is complete when reading.

Distributed transactions (atomic)

a way to determine should a transaction commit across all participants (ensuring all participants agree and are on the same page)

  • 2-phase commit (strong atomicity)
  • 3-phase commit (strong atomicity)
    • 3 steps
      • prepare / vote
      • pre-commit
      • commit
    • solves problem of 2-phase commit, middle step of pre-commit, where coordinator will broadcast to all participants on the decision. so participants know safe to commit
      • Adds a pre-commit phase to reduce blocking if the coordinator crashes
        • participants can coordinate with each other to recognize theyve all reached pre-commit and can finish commit without coordinator
      • This allows participants to use timeouts and their known protocol states to recover
  • SAGA (eventual atomicity)
    • Multiple commits sequentially (and rolling back each step upon failure)
    • Simulates distributed transactions by having the programming model simulate consistency
    • Need a state field in the db usually (to say it’s done)