Collection
zero Useful+1
zero

transaction management

Management field terms
Transaction management is about data base Operation management, one transaction contains one or more SQL Statement is the work unit (atomic unit) of logical management.
Chinese name
transaction management
Foreign name
transactionmanagement
Definition
Manage database operations

Basic Introduction

Announce
edit
A transaction is data base A sequence for reading and writing. Traditional database (RDB) transactions have two obvious characteristics: atomicity and serializability. Atomicity means that read and write operations in a transaction can be viewed as a single atomic operation on the database. Serializability means that the effect of concurrent execution of multiple transactions is the same as that of executing one of these transactions at a time. Therefore, the task of transaction management is to ensure the atomicity and serializability of transactions. It consists of two parts: concurrency control and recovery. Concurrency control involves the automatic control of multiple transactions accessing a common part of the database at the same time. Recovery involves restoring the database to the state that existed before the transaction failure. [1]

Composition of transaction management

Announce
edit
Transaction processing system is composed of transaction manager, recovery manager, lock manager, deadlock manager and cache manager.

Transaction Manager

The transaction manager is responsible for generating transactions and allocating transaction IDs to them. It should be able to generate enough sub transactions and allocate enough transaction IDs as needed. When a child transaction is committed, the transaction manager needs to know its parent transaction ID and perform a series of operations. If the parent transaction ID can be obtained directly from the child transaction ID, the efficiency of transaction processing will be greatly improved.

Recovery Manager

In the nested transaction model, compared with the parent transaction and sibling transaction, the child transaction can be committed independently, and the rollback of the child transaction will not cause the rollback of the parent transaction and sibling transaction. If the (sub) transactions at any level fall back, all its sub transactions fall back, regardless of whether they have implemented local commit. Therefore, when a child transaction is committed, the recovery manager needs to link its log to the log of the parent transaction, which requires the recovery manager to know the parent transaction ID. Then, if the parent transaction ID can be obtained directly from the child transaction ID, the work efficiency of the recovery manager will be greatly improved.

Lock Manager

In the nested transaction model, once a child transaction is committed, the parent transaction can observe all the changes it makes. Changes made by the parent transaction before the start of the child transaction are visible to the child transaction. When sub transactions run concurrently, changes are not displayed to brother transactions; Otherwise, once the sub transaction is committed, its changes will be displayed to the sibling transaction. Therefore, when a child transaction commits, it transfers its own lock to the parent transaction. When a transaction applies for a lock, the lock manager is responsible for judging the compatibility of the lock: if it is compatible, it will be allocated to the corresponding lock of the transaction; Otherwise, judge whether the transaction that applies for the lock is the descendant of the transaction that owns the lock. If so, allocate the corresponding lock to it, otherwise it cannot meet its application requirements. Then, if we can directly determine whether there is an ancestor descendant relationship between two transactions from their identifications, it will greatly improve the efficiency of the lock manager.

Deadlock Manager

New applications require maximum parallelism in transaction structures, including parallelism between sibling transactions and between parent and child transactions. These lead to the diversification of waiting relationships between transactions, and further lead to the diversification of deadlock types, which undoubtedly increases the difficulty of deadlock detection. In order to improve the efficiency of deadlock detection and find "hidden" deadlocks as early as possible, we must first effectively represent various waiting relationships. Under the nested transaction model, the deadlock manager mainly handles three kinds of waiting relationships:
(1) The lock application transaction waits for the lock owning transaction;
(2) The parent transaction waits for the submission of all child transactions;
(3) The transaction applying for the lock waits for the highest ancestor of the transaction owning the lock that meets the following conditions: it is not the ancestor of the transaction applying for the lock.
The effective representation of the third kind of waiting relationship can avoid a lot of meaningless work, but it needs to find out the non common ancestor at the highest level of the two transactions. In order to achieve the purpose, the transaction hierarchical structure It is an expensive job to carry out continuous upward search and comparison. Then, if we can directly find the non common ancestor at the highest level of two transactions from their identifications, we will avoid an expensive task, thus greatly improving the efficiency of the deadlock manager.

Cache Manager

Based on the consideration of the effective use of cache, the cache manager requires the storage structure of transaction ID to provide flexible and effective support for short ID and long ID. Obviously, the static structure is not suitable, and flexible dynamic structure needs to be used.
To sum up, the requirements of transaction processing for transaction identification are:
(1) The parent transaction ID can be obtained directly from the child transaction ID;
(2) The transaction ID provides good support for the width and breadth of the transaction hierarchy (that is, there is no limit on the width and breadth);
(3) The transaction ID storage structure can provide enough transaction IDs (that is, there is no limit on the number of transaction IDs);
(4) According to the transaction ID, it can be determined whether two transactions have an ancestor offspring relationship;
(5) The highest level non common ancestor of two transactions can be found according to the transaction ID;
(6) The transaction ID storage structure should be flexible and variable in length, and can make full use of the storage space to effectively store long and short IDs. [2]