What is the core concept of transaction processing?
- A transaction is a mechanism that treats a group of operations as an operation.
- In transaction processing, either all operations are executed, or all operations are not executed.
- The operations involved in transactions may depend on many different databases and servers.
Acid attribute of Transaction Processing
- A transaction is defined by the acid attribute of a series of acronyms.
- Acid stands:
- Atomic atomicity
- Consistent consistency
- Isolated independence
- Durable persistence
Let's take an example: the funds transfer process without transactions:
Successful transfer:
Failed Transfer Process:
We can see the failed transfer process: the total amount is reduced, and the account status is inconsistent.
Let's take a look at the successful transaction Transfer Process:
A. The transaction changes will be buffered.
If the transfer is successful, changes will be submitted (for permanent changes)
What is distributed transaction?
- A resource, such as a database, is controlled by software called Resource Manager (RM.
- A local transaction is a transaction that processes a single resource manager.
- Distributed transactions are transactions that collaborate or span multiple resource managers.
- The collaboration between multiple resource managers is completed by the Transaction Manager.
- A transaction usually refers to the transaction context ).
Two-phase submission Protocol
- 2 PC (two-phase commit) protocol uses two steps to Commit Changes to a distributed transaction
- Phase 1 Requests all resource managers to prepare for implementation changes. If any of them is not ready, the transaction will be unexpectedly interrupted.
- Phase 2 Requests all resource managers to actually submit and implement permanent changes
- The global transaction ID (Xid) is used to track all changes related to distributed transactions.
XA (Extended Architecture)
XA:
- Is the interface used between WebLogic Server and Resource Manager
- Implement two-phase submission Protocol
- Allow programming to control the resource manager involved by a distributed firm
Transaction and Resource Manager
- A transaction Manager works with several resource managers
- The two-phase commit protocol is used for collaborative transactions.
Let's take a look at the successful two-phase submission:
We can easily see that:
Phase 1: Preparation
Phase 2: Implement submission
This section mainly describes the core concepts and acid attributes of transactions.