Distributed -Two-Phase Commit

> (Data|State) Management and Processing > Distributed - Database / Application

1 - About

The Two-Phase Commit is fairly standard for synchronous processing in order to avoid inconsistent state in a distributed environment.

Advertising

3 - Phases

1) User wants to Update; 2) Prepare; 3) Write to Log; 4) Ready; 5) Commit

First the User wants to Update, then the update is prepared, written to log, set to a ready state, and finally committed to the database.

3.1 - Phase 1

  • Coordinator Sends “Prepare to Commit”
  • Subordinates make sure they can do so no matter what
  • Write the action to a log to tolerate failure
  • Subordinates Reply “Ready to Commit”

3.2 - Phase 2

  • If all subordinates ready, send “Commit”
  • If anyone failed, send “Abort”

4 - Documentation / Reference