Four basic elements for correct execution of ACID database transactions

Source: Internet
Author: User
ACID refers to the four basic elements of the correct execution of ACID database transactions. Includes: Atomicity, Consistency, Isolation, and Durability ). A database system that supports transactions must have these four features.

ACID refers to the four basic elements of the correct execution of ACID database transactions. Includes: Atomicity, Consistency, Isolation, and Durability ). A database system that supports transactions must have these four features.

ACID: four basic elements for correct execution of database transactions

ACID refers to the abbreviation of four basic elements for correct execution of database transactions. Includes: Atomicity, Consistency, Isolation, and Durability ). A database system that supports transactions must have these four features.

Atomicity: all operations in a transaction are either completed or not completed. When a transaction encounters an error during execution, it will be rolled back to the state before the start of the transaction, just as this transaction has never been executed.

Consistency: the integrity of the database is not damaged before and after the transaction starts. This indicates that the written data must fully comply with all the default rules, including the data accuracy, concatenation, and the ability of subsequent databases to automatically complete the reservation.

Isolation: the relationship between two or more concurrent transactions when accessing the same data of the database (the access here refers to the query and modification operations. Transaction isolation is divided into different levels, including Read uncommitted, read committed, repeatable read, and Serializable ).

Durability: after the transaction is completed, the changes made to the database by the transaction will be permanently stored in the database and will be complete.

Because an operation usually contains many sub-operations, these sub-operations may cause problems due to hardware damage or other factors, it is not easy to implement ACID correctly. ACID recommends that the database complete all the data to be updated and modified at one time, but it is not feasible.

At present, there are two main ways to implement ACID: the first is Write ahead logging, that is, the log method. The second type is Shadow paging.

Write ahead logging (pre-Write log ):

1. All changes caused by the transaction must be recorded in the log. before the transaction is committed, all these records must be written to the hard disk;

2. A buffer page of a database cannot be modified until it is recorded in the log. The buffer page will not be saved to the disk until the log corresponding to the buffer page is written to the disk;

3. When the buffer page is modified and the log is updated, A mutex lock must also be added to ensure that the order in which the changes are recorded is the same as that in which they occur.

Result of the preceding rule:

1. If a log record is not saved to the hard disk, it can be ignored because the changes contained in the log must belong to uncommitted transactions. In addition, such logs do not reflect changes that have been persisted in the database;

2. log records system changes in sequence. The latch protocol ensures that if two log records are modified on the same page, the order of the two records reflects the order of page changes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.