Transaction Management
Transaction ):
1. A set of operations that constitute a single logical unit of work
User Programs in DBMS
Executable programs outside DBMS
Database read/write operation sequence
2. Read
Read data from the database. First, read the memory (buffer pool) from the disk and assign it to the variable.
3. Write
First, data in the memory is copied and then written to the disk.
Transaction Features-acid:
Atomicity)
Consistency)
Isolation)
Durability)
Transaction Features-atomicity:
The operations in the transaction are either completely done or not done.
Transactions cannot be split.
The transaction must end with commit/rollback
Transaction Features-Consistency:
To run a transaction separately, you must ensure that the database remains consistent.
Migrate from one consistent state to another consistent state
Atomicity-related
Transaction Features-isolation:
Multiple concurrent transactions cannot interfere with each other.
Concurrency does not affect transaction execution
Transaction Features-Persistence:
Once the transaction is successfully completed (COMMIT), it should be persistent for database updates.
Even before writing data to a disk, the system fails.
After the next startup, ensure that data updates are effective.
Transaction and Transaction Manager:
Recovery and concurrency control are an important part of transaction management.
The recovery management component is responsible for ensuring the atomicity and durability of transactions.
The concurrency control component is responsible for the transaction concurrency control mechanism to achieve transaction isolation and consistency.
Transaction Manager implements acid of transactions
Commit and rollback of transactions:
Submit (commit
Notifies the Transaction Manager that a logical unit of work has been completed, and the update operation can be committed or permanently retained.
Indicates that the transaction has ended successfully.
Perform effectiveness test
Rollback)
The transaction manager is notified that the transaction fails to be completed normally, and the database may be in an inconsistent state. All update operations performed by the current transaction must be undone.
Indicates that the transaction ends successfully.
Transaction Status:
Active
Partial commit status, after the last statement of the transaction is executed
Failed status, after the normal operation is found to be unable to continue
Stop status, transaction rollback, and database recovery to the starting state of the transaction
Restart transaction-not a fault caused by internal logic errors
Killing transactions
Commit status. The transaction is successfully completed.
Transaction concurrency:
Multiple transactions may run in the system at the same time (crossover ).
Improves utilization of processors and disks
Reduce wait time
Multiple transactions run concurrently and are scheduled by the Transaction Manager.
Serializable Scheduling
The result of concurrent running is equivalent to the result of a transaction running in a serial order.