Classic dirty reads, non-repeatable read read fantasy

1. Dirty read:

Dirty read refers to when a transaction is accessing data, and the data has been modified, and this modification has not been submitted to the database, then, another transaction also access the data, and then use this data.

2. A non-repeatable read:

It refers to a transaction, reading the same data multiple times. When this transaction is not over, another transaction also access the same data. So, between the two read data in the first transaction, due to the modification of the second transaction, then the first two transactions read data may be different. This occurs in a transaction the two read data are not the same, so called non-repeatable read. For example, an editor who read the same document twice, but between the two readings, the authors rewrite the document. When the second editorial staff read the document, the document has changed. Original reading can not be repeated. If only the author completed the preparation of the editorial staff can read the document, you can avoid this problem.

3. The phantom read:

Means that when the transaction is not a phenomenon that occurs when executed independently, for example, the first transaction data in a table is modified, this modification involves all the data rows in the table. At the same time, also the second transaction to modify the data in this table, this modification is to insert a new row to the table. Then, the user operates the first transaction will occur after the discovery of the table there is no modification of the data lines, as if the same happened hallucinations. For example, a change document authors to submit editorial staff, but when the production department will change its content merged into the master copy of the document, the authors have found that the addition of new unedited material into the document. If before the completion of processing of the original document in the editing and production department, no one can add new material to your document, you can avoid this problem.

supplement: 

Metadata-based Spring declarative transaction:

Isolation property supports five total transaction settings, are detailed below:

         DEFAULT database isolation level setting (default), the isolation level is determined by the DBA default settings.

         READ_UNCOMMITTED will appear dirty reads, non-repeatable read, phantom read (the lowest level of isolation, high concurrency)

         READ_COMMITTED will be non-repeatable read, phantom read problems (lock being read lines)

         REPEATABLE_READ will be out (read lock all rows) Magic Reading

         SERIALIZABLE ensure that all cases (lock table) does not occur

Non-repeatable read focus is modified: 
the same conditions, you had to read the data, read out value is not the same again found 
the magic of reading focuses on new or deleted 
the same conditions, read out the 1st and 2nd the record number is not the same.

Guess you like

Origin www.cnblogs.com/mjtabu/p/12669811.html