1. Dirty read: Dirty read means that when a transaction is accessing data and modifying the data has not been committed to the database, another transaction also accesses the data, then the data is used.
2. Repeated read is not allowed.: Refers to reading the same data multiple times in a transaction. When the transaction is not completed, another transaction also accesses the same data. Therefore, the data read twice in the first transaction may be different because of the modification of the second transaction. In this way, the data read twice in a transaction is different, so it is called non-repeated read. For example, an editor reads the same document twice, but the author overwrites the document between the two reads. The document has been changed when the editor reads the document for the second time. The original reads cannot be repeated. This issue can be avoided if the editor can read the document only after the author has completed writing.
3. Phantom read: Refers to a phenomenon that occurs when a transaction is not executed independently. For example, the first transaction modifies the data in a table, which involves all the data rows in the table. At the same time, the second transaction also modifies the data in this table. This modification inserts a new row of data into the table. In the future, the user who operates the first transaction will find that there are still data rows in the table that have not been modified, just like an illusion. For example, an editor changes the document submitted by the author, but when the production department merges the changes into the primary copy of the document, the author has added unedited new materials to this document. This issue can be avoided if no one can add new materials to the document before the editors and production departments process the original document.
Supplement:Metadata-based Spring declarative transactions:
The isolation attribute supports five transaction settings as follows:
L default uses the isolation level set by the database (default), which is determined by the DBA's default settings.
L read_uncommitted will show dirty reads, non-repeated reads, and Phantom reads (lowest isolation level, high concurrency performance)
L read_committed: unrepeatable read and phantom read (locking the row being read)
L repeatable_read will trigger phantom read (Lock all rows read)
L serializable ensures that all situations will not occur (Lock table)
Repeatable reading focuses on modification:
In the same condition, the data you read is read again and the value is different.
Phantom read focuses on adding or deleting
Under the same condition, the number of records read for 1st and 2nd times is different.