What problems can result from two-phase errors?

I read several times recently that biphasic fixations are bad, but always as a side note. Therefore, there was never a good explanation with him.

For example, in CQRS Journey Chapter 5 :

Secondly, we try to avoid two-phase commits, because they always cause problems in the long run.

Or in Implementing Domain Management on page 563:

The second ReadRecorts () is used by the infrastructure to replicate events, to publish them without the need for two-phase commit, ...

I thought that two-phase commits are implemented to ensure consistency between multiple database servers.

What problems can arise when using two-phase commits? Why is it better to avoid them?

+8
database commit transactions cqrs 2phase-commit
source share
1 answer

The biggest problem is scalability due to the blocking nature of the 2-phase commit protocol.

2PC requires careful coordination between the parties involved: in particular, each side must recognize the preparation phase and fixation. As soon as the participant confirms that he is ready to commit, he must block until the transaction coordinator sends a commit or rollback message. If either side is on the network, network latency causes a bottleneck for communication between nodes.

In addition, as soon as the party recognizes that it is ready for fixation, it should actually be able to complete the transaction subsequently, even if it crashed between them. This requires a breakpoint for persistence (even when the transaction rolls back later), and also possibly limits bandwidth.

+8
source share

All Articles