0

I'm trying to understand what is the difference between 1 and 2-phase commit and why 1phase commited does not make sense distributed systems. From my understanding here they are:

  1. In 1 phase commit the coordinator commits the transaction on all nodes independently so if the transaction fails on one node it won't be rolled back on those where it's been committed already.

  2. In 2 phase commit the coordinator on the 1st phase asks all nodes to prepare data to be committed on the 2nd phase. If some node are not able to prepare the data the transaction is rolled back. So after the phase 1 the node remains in the "locked" state until the transaction is actually committed.

Is the 2 points are the primary differences between the 1 and 2-phase commits or I got them wrong?

user4157124
  • 2,809
  • 13
  • 27
  • 42
St.Antario
  • 26,175
  • 41
  • 130
  • 318
  • 1
    It seems you've answered your own question in your 1st point. The problem with 1-phase commit is that when only some nodes are rolled back, you end up with an inconsistent or undefined state in your system as a whole. – Josh Bothun May 11 '22 at 10:44
  • Looks like you got it right. 1-phase commit is still used in distributed system, we just call it "asynchronous messaging". – root May 30 '22 at 08:41

0 Answers0