Transaction management

Overview

A transaction is a sequence of reading and writing a database. There are two obvious characteristics: atomicity and serialization in traditional database (RDB): atomicity and serialization. Atomic means that read and write operations in transactions can be seen as a single atomic operation for the database. Seriebial means that the effect of multiple transactions concurrent execution is the same as one of the execution of these transactions. Thus, the task of transaction management is to ensure the atomicity and seriality of the transaction, which consists of two parts: concurrency control and recovery. Concurrent control involves automatic control of multiple transactions for simultaneous access to a common part of the database. Recovery involves the state that has existed before the database is restored to the transaction failure.

Configuration of Transaction Management

Transaction system consists of Transaction Manager, Recovery Manager, Lock Manager, Deadlock Manager, Cache Manager.

Transaction Manager

Transaction Manager is responsible for generating transactions and assigning a transaction identifier, which should be able to generate sufficient sub-transactions and assign enough transaction ID as needed. When the submit is submitted, the transaction manager needs to know its parent business identity and perform a series of operations, and if it can directly get its parent business identity directly, it will greatly improve the efficiency of transaction processing.

Recovery Manager

In the nested transaction model, child transactions can be submitted independently relative to parent transactions and brother affairs, and the volume of sub-transactions will not cause Parenting and brother affairs roll back. If any level (child) is rolled back, all of its sub-transactions have fallen, regardless of whether they have implemented local submission. Therefore, when submit is submitted, the recovery manager needs to connect its log link to the log of parent transactions, which requires the Recovery Manager to know the parent business identity. Then, if you can directly get its parent business identity directly from the sub-transaction marking, it will greatly improve the work efficiency of the recovery manager.

Transaction management

Lock Manager

In the nested transaction model, once the child transaction is submitted, the parent transaction can observe all changes it makes. The change of the sub-transaction in the start of the child's transaction is visible. When the child matters runs concurrently, the change does not display the brothers' affairs; otherwise, the child is submitted, and its change is displayed to the brothers. Therefore, when submit is submitted, it converts the owned lock to the parent. When the transaction is applied, the lock manager is responsible for judging the compatibility of the lock: if it is, assign it to the transaction corresponding lock; otherwise, it is determined whether the transaction of the application lock is the descendant of the locked transaction, if it can be Assign the corresponding lock, otherwise it cannot meet its application requirements. Then, if you can directly determine whether there is a ancestral relationship between the two transactions, it will greatly improve the work efficiency of the lock manager.

Defense lock Manager

The new application requires the largest parallelism in the transaction structure, including parallelism between parallel and parent-based transactions between brothers. These lead to the diversification of the waiting relationship between the transactions, and further cause diversification of deadlock types, which undoubtedly increases the difficulty of deadlock detection. In order to improve the efficiency of deadlock detection, the "hidden" dead lock is found as soon as possible, we must first effectively represent various waiting relationships. Under the nested transaction model, the deadlock manager mainly handles three waiting relationships:

(1) The transaction of the application lock is waiting to have a lock transaction;

(2) Parent transaction Waiting for all sub-transactions;

(3) Application Locks Wait for a lock-locked business to meet the highest level of the following conditions: it is not a ancestor of the business of the business.

The effective representation of the third waiting relationship can avoid a lot of meaningless work, but this needs to find the highest level of non-common ancestors of the two transactions. In order to achieve the purpose, you need to make a constant search and comparison of the transaction hierarchy, which is a great job. Then, if you can directly find out the non-common ancestors of their highest layers from the identity of the two transactions, it will avoid a lot of overhead, which greatly improves the work efficiency of the deadlock manager.

Cache Manager

Based on the consideration of the cache efficient use, the cache manager requires the storage structure of the transaction to provide flexible and effective support for short identification and long identity, obvious, static The structure is inappropriate and requires a flexible dynamic structure.

All, transactional demand for transaction logo is:

(1) can directly identify the identity of its parent transaction directly from sub-transactions;

( 2) The transaction logo provides good support for the width and breadth of the transaction hierarchical structure (ie: no limit on the width and breadth);

(3) Transaction Identifier storage structure provides sufficient transaction ID (ie : There is no limit to the number of transaction logo);

(4) can judge whether the two transactions have ancestral relationship according to the transaction;

(5) can be found according to the transaction logo The highest level of non-common ancestors of two transactions;

(6) The transaction identifier should be flexible and variable length, which can make full use of storage space to effectively store long identification and short identification.

Related Articles
TOP