1

I am new to distributed transaction thing, studying how two-phase commit works across a distributed transaction in micro-services architecture. As per my understanding, in the last part of the phase the transaction coordinator asks each node whether it is ready to commit. If everyone agreed, then it tells them to go ahead and commit.

But what prevents the following failure?

All nodes respond that they are ready to commit The transaction coordinator tells them to "go ahead and commit" but one of the nodes fails at commit (say due to some database constraint or connection timeout)

All other nodes commit successfully, but now the distributed transaction is corrupt

In short, what does it mean when the nodes say that they are ready to commit?

I am assuming each node is running a normal database that doesn't know anything about distributed transactions.

PIYUSH PASARI
  • 401
  • 4
  • 6
  • All the behaviour after the failure depends on the implementation of the transaction manager. Normally there is some recovery mechanism which ensures that failed resources are checked periodically if they are started again. When they are ready to serve requests the transaction manager finishes the work which was interrupted with the failure. Take a look at my article at jboss wiki about two phase commit https://developer.jboss.org/wiki/TwoPhaseCommit2PC . – chalda Sep 19 '18 at 07:54
  • As a side note - your question starts with note on the micro-service architecture. It depends on your use case but distributed transactions should be used in micro service architecture with care - aka. with understanding that they couple your services together. – chalda Sep 19 '18 at 07:56
  • @chalda Thanks for sharing the article. This provides an apt answer to my query. – PIYUSH PASARI Sep 19 '18 at 14:13

0 Answers0