level for MySQL, which ensures that multiple instances of the same transaction will see the same data row when concurrently reading data (MySQL solves the problem with a snapshot). In theory, however, this can lead to another tricky problem: Phantom Reading (Phantom read). To put it simply, Phantom reading refers to when a user reads a range of data rows, anothe
Profile:Four characteristics of a transaction: atomicity, consistency, isolation, persistenceIssues caused by transaction non-isolation: dirty read, non-repeatable read, virtual read (Phantom Read)Level of Transaction Isolation: Serialization (111), Repeatable Read (110), Read committed (100), read UNCOMMITTED (000)1. Four features of the transactionIf a database claims to support transactional operations, then the database must have the following fou
modified transaction is suspended until the modified transaction commits, but the data that caused the conflict is not read, that is, the Phantom read For example: Table T has a unique key UK, transaction a first to T insert uk=x but not commit, transaction B again to T insert Uk=x, at this time transaction B will be suspended, if transaction a commits, at this time transaction B will be due to the unique key conflict error; If transaction a deletes
levels.First you need to explain a few conceptual definitions related to isolation:(1) Dirty read: Refers to the transaction read dirty data, the so-called dirty data, refers to the incorrect data, such as a transaction during the execution of a record modified, and then rollback, if other transactions read the record's intermediate modified value, then dirty read.(2) Non-repeatable read: During the execution of a transaction, the same existing record is read multiple times, and the values of e
, qirou, Xia Qing, Yi Yao, Miao, and zilan
Magic Bai, Yuan Feng, ice Feng, xingrui, Zhi Rui, Fan lei, Fan Rou, An Lei, Tian He, Hua Yu, Shu LAN, yaqin, Shu
Yao, Cong an, Xia Huai, Nian Qin, Dai man, phantom Shan, Gu Si, Qiu Cui, Bai Qing, Hai Lu, Dai he, Hua Yu, Shu lei,
Listening to Bai, Ling Yan, Xue qing, leyao, Han Yan, Han Shuang, Ping die, yarui, ao Zhi, Ling Wei, Han Lei, Cong Meng, Cong Rong
And Chu Dan. Listen to Lan, listen to Rong, Yufu
, the transaction that executes the modification will be suspended until the transaction that executes the modification is committed, but the conflicting data cannot be read, that is, phantom read.
For example, if table T has A unique key UK, transaction A first inserts UK = x into T, but does not commit, and transaction B inserts UK = x into transaction T. In this case, transaction B is suspended; if transaction A commits, transaction B will report a
because the original data updated by a transaction is inserted in the middle of the two queries, the reason is that the transaction can see the results of other transaction submissions.
4th isolation level Serializable
This is the highest isolation level. It forces transaction sorting to make it impossible to conflict with each other, thus solving the phantom read problem. In short, it adds a shared lock to each read data row. At this level, there
Implementation principle of MySQL transaction isolation level, mysql transaction isolation levelReview
Among the many storage engines of MySQL, only InnoDB supports transactions. The transaction isolation level mentioned here refers to the transaction isolation level under InnoDB.
Read not committed: one transaction can read the uncommitted changes of another transaction. This may cause dirty reading, phantom reading, and non-repeated reading. (Useles
(Unrepeatableread): refers to reading the same data multiple times within a transaction. When the transaction has not ended, another transaction accesses the data. So, between the two read data in the first transaction,Because the modification of the second transaction causes the first transaction to read two times, the data may not be the same. This occurs when the data that is read two times within a transaction is not the same, and therefore is called non-repeatable read.
Database Transaction ISOLATION LEVELThere are 4 isolation levels for database transactions, from low to high, READ UNCOMMITTED,Read Committed,Repeatable read, andSerializable, which can be resolved individually by each of the four levels Problems such as dirty reading, non-repetition reading, and Phantom reading. √: May appear x: does not appear
Dirty Read
Non-REPEATABLE READ
Phanto
, the physical log records the details of the modified page, and the logical log records the action statement. Physical log recovery is faster than logical logs.
2. How transactions are implementedThe role of a transaction: A transaction transforms a database from a consistent state into another consistent state.The mechanism of a transaction is generally summarized as the "ACID" principle i.e. atomicity (A), consistency (C), Isolation (I), and Persistence (D).
Atomicity: All ope
Intent table lock:before adding a lock, you should first add a table-level intent Lock:Intent Shared Lock (IS): indicates that a transaction is ready to join a shared lock on a data row, which means that a data row is locked before a shared lock must be obtained for that table. Intent Exclusive Lock (IX): Similar to the above, the transaction is prepared to add an exclusive lock to the data row, stating that the transaction must obtain an IX lock on the table before a data row is added to the e
between transactions, with four isolation levels.
First you need to explain a few conceptual definitions related to isolation:
(1) Dirty reading: Refers to the transaction read dirty data, the so-called dirty data, refers to the incorrect data, such as the transaction during the execution of the modification of a record, and then rollback, if the other transaction read the record in the middle of the modified value, dirty read.
(2) Non-repeatable reads: A transaction reads the same existing rec
-repeatable read (nonrepeatable Read): When a transaction reads the data it has read before, the discovery data has been modified or deleted by other committed transactions.there is no read (Phantom Read): short for "phantom read". When a transaction is re-queried by a previous condition, the returned result set contains new data that satisfies the conditions that were inserted by other committed transactio
ReviewOf the many storage engines in MySQL, only InnoDB supports transactions, and all of the transaction isolation levels described here refer to the transaction isolation level under InnoDB.READ UNCOMMITTED: One transaction can read uncommitted modifications to another transaction. This can lead to dirty reading, phantom reading, non-repeatable reading problems. (Basic useless)Read committed: One transaction can read only the modifications that have
two query process to update the original data, so the same select might return different results.Repeatable Read (can be reread)This is the default transaction isolation level for MySQL, which ensures that multiple instances of the same transaction will see the same rows of data while concurrently reading the data. In theory, however, this can lead to another tricky problem: Phantom Reading (Phantom read).
levels (snapshot of the read-committed isolation level based on the row version).Different isolation levels to control dirty read, non-repeatable read, Phantom Reading has a certain degree of control, also can have a certain extent of influence,The lower the isolation level, the higher the concurrency, but the more likely it is to produce dirty reads, non-repeatable reads, and Phantom reads; With the submi
solve the database transaction concurrency problem. Copyright Notice and Acknowledgements: This article original nerd RicoAuthor Blog address: http://blog.csdn.net/justloveyou_/ Examples of the explanations for dirty reads, non-repeatable reads, and Phantom reads are from the blog post, "Database transaction isolation level."I. Overview of transactionsIn general, each request of a user corresponds to a business logic method, and each business logic m
transfer money to the card before A's withdrawal.
4. Durability: after the transaction is completed, all updates to the database by the transaction will be saved to the database and cannot be rolled back.
Conclusion: Atomicity is the foundation of transaction isolation, isolation and persistence are the means, and the ultimate goal is to maintain data consistency.
Ii. Transaction concurrency
1. Dirty read: Transaction A reads the data updated by transaction B, and then B rolls back, then the da
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.