Detailed explanation of ACID features and acid features

Source: Internet
Author: User

Detailed explanation of ACID features and acid features

ACID is: Atomicity, Consistency, Isolation and Durabilily ).

1. atomicity

The atomic attribute is used to identify whether the transaction is completely completed. Any update of a transaction must be completely completed on the system. If an error occurs for some reason, the transaction cannot complete all its tasks, the system returns the status before the start of the transaction.

Let's take a look at the bank transfer example. If an error occurs during the transfer, the entire transaction will be rolled back. Only when all parts of the transaction are successfully executed can the transaction be written to the disk and the change will be made permanent.

To provide the ability to roll back or cancel uncommitted changes, many data sources adopt the log mechanism. For example, SQL Server uses a pre-write transaction log, which is written in the transaction log before applying data to (or committing to) the actual data page. However, some other data sources are not relational database management systems (RDBMS). They manage uncommitted transactions in completely different ways. This technique can be used to manage transactions as long as the data source can cancel all uncommitted changes during transaction rollback.

2. Consistency

Transaction consistency is implemented in system integrity, which is achieved by ensuring that any transaction in the system is in a valid state at last. If the transaction is successfully completed, all changes in the system will be correctly applied and the system is in a valid state. If an error occurs in the transaction, all changes in the system are automatically rolled back, and the system returns to the original state. Because the transaction is opened

At the beginning, the system is in the consistent state, so the system is still in the consistent state.

Let's look back at the bank transfer example. Before account transfer and fund transfer, the account is in a valid state. If the transaction is successfully completed and the transaction is committed, the account is in a new valid state. If a transaction error occurs, after the transaction is terminated, the account returns to the original valid state.

Remember, transactions are not responsible for implementing data integrity, but are only responsible for ensuring that data is returned to a consistent state after the transaction is committed or terminated. Understanding data integrity rules and writing code to achieve integrity usually falls on the shoulders of developers who design based on business requirements.

When many users use and modify the same data at the same time, the transaction must maintain its data integrity and consistency. Therefore, we further study the next feature of a c I D: isolation.

3. Isolation

Execute transactions in the isolation status, making them as if they are the only operations performed by the system within a given time. If two transactions run at the same time and perform the same functions, the isolation of the transaction will ensure that each transaction is considered to be only the transaction in the system.

This type of attribute is sometimes called serialization. To prevent confusion between transaction operations, requests must be serialized or serialized so that only one request at a time can be used for the same data.

It is important that the state of the system may be inconsistent when the transaction is executed in an isolated state. before the transaction is terminated, ensure that the system is in a consistent state. However, in each individual transaction, the system status may change. If a transaction is not running in an isolated state, it may access data from the system, and the system may be in an inconsistent state. By providing information

Service Isolation can prevent such events.

In the banking example, this means that in this system, other processes and transactions do not see any changes caused by our transactions before our transactions are completed, which is very important for termination. If another process is processed based on the account balance, and the change is visible before the transaction is completed, the decision-making of this process may

It is built on the wrong data because our transaction may be terminated. This explains why the transaction changes are visible to other parts of the system until the transaction is completed.

Isolation not only ensures that multiple transactions cannot modify the same data at the same time, but also ensures that changes produced by transaction operations can be visible to another transaction until the changes are committed or terminated, concurrent transactions have no impact on each other. This means that all data that requires modification or reading has been locked in the transaction and can be released only after the transaction is completed. Most databases, such as SQL Server and other RDBMS, are isolated by locking. Various data items or datasets involved in transactions are locked to prevent concurrent access.

4. Durability

Durability means that once the transaction is successfully executed, all changes generated in the system will be permanent. Check Points should exist to prevent information loss when the system fails. Even if the hardware itself fails, the system status can still be re-built by recording the tasks completed by the transaction in the log. The concept of durability allows developers to consider that the completed transactions are permanent parts of the system no matter what changes have taken place in the future.

Related Article

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.