NOTE
2.10 Two-Phase Implementation: TCC
1. What Is TCC - 2PC is a two-phase approach at the database layer, while TCC is a two-phase approach at the application layer. - TCC: Try: attempt to execute the transaction; Confirm: confirm execution of the transaction; Cancel: cancel execution of the transaction. - In essence, it is also a two-phase transaction.
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is TCC?
- 2PC is a two-phase approach at the database layer, while TCC is a two-phase approach at the application layer.
- TCC:
- Try: attempt to execute the transaction.
- Confirm: confirm execution of the transaction.
- Cancel: cancel execution of the transaction.
- In essence, it is also a two-phase transaction.
- In the first phase, execute Try to perform business checks and reserve resources.
- The second phase depends on the result of the first phase. If successful, execute Confirm to perform business confirmation; if it fails, execute Cancel to perform the opposite of Try, similar to a manual rollback.

2. Why Is TCC Needed?
- TCC solves several shortcomings of 2PC:
- Single-point problem: the business activity manager becomes multi-point.
- Synchronous blocking: commit directly during Try, without needing to block and wait; Cancel…
3. Problems with TCC
- Code intrusion: developers need to manually write code to implement Try, Confirm, and Cancel.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub