分布式事务
Distributed Systems · 13 notes
- 2. Distributed Transactionshistorical
Distributed transactions span multiple database nodes and may involve other data sources such as Redis or MongoDB. These notes organize coordination approaches for cross-node operations.
- 2.1 Distributed Transaction Solution: 2PChistorical
Two-phase commit asks databases to prepare, then commits or rolls back according to the participants' responses. These notes also discuss its use cases and problems.
- 2.2 Distributed Transaction Solution: TCChistorical
TCC first uses Try to check a business operation and reserve resources, then invokes Confirm or Cancel according to the outcome.
- 2.3 Distributed Transaction Solution: Reliable-Message Eventual Consistencyhistorical
Reliable messaging coordinates local transactions across services toward eventual consistency. These notes introduce local message tables and transactional messages through the process diagram.
- 2.4 Distributed Transaction Solution: Best-Effort Notificationhistorical
Best-effort notification is an eventual-consistency transaction approach. These notes use process diagrams to examine notifications, queries, retries, and usage scenarios.
- 2.5 Distributed Transaction Solution: Sagahistorical
Saga gives each participant a forward operation and a compensating operation. If a step fails, compensation handles operations already completed.
- 2.6 Distributed Transaction Solution: 3PChistorical
Three-phase commit splits the preparation process into CanCommit, PreCommit, and DoCommit stages as an extension of two-phase commit.
- 2.7 Distributed Transaction Solution: Two Phaseshistorical
A two-phase transaction separates preparation from commit or rollback. These notes organize database-level 2PC and application-level TCC approaches.
- 2.8 Reliable-Message Eventual-Consistency Implementation: Local Message Tablehistorical
Using points awarded after an order as an example, the service creates the order and writes a message within a local transaction, then uses messaging to drive the points service.
- 2.9 Two-Phase Implementation: 2PChistorical
Two-phase commit first sends prepare requests to participating databases, then uses their responses to decide whether to commit or roll back.
- 2.10 Two-Phase Implementation: TCChistorical
TCC divides an application-level transaction into two phases: Try checks the business operation and reserves resources, followed by Confirm or Cancel according to the result.
- 2.11 Best-Effort Notification Implementation: MQhistorical
After a local transaction, the producer sends a message to MQ. The consumer acknowledges success, requeues on failure, and can query the producer for message status.
- 2.12 RocketMQ Transaction Messageshistorical
RocketMQ transactional messages encapsulate the local-message-table approach in the message queue to coordinate message sending with local transaction execution.