Spring-The isolation level of things

Source: Internet
Author: User

The different transaction isolation levels in 5 are defined in spring:

1.Isolation_default(This configuration can be used in general); This is a Platfromtransactionmanager default isolation level that uses the default transaction isolation level of the database.
2.isolation_read_uncommitted(uncommitted) This is the lowest level of isolation for transactions, and it allows a transaction to see uncommitted data for that transaction.
This isolation level produces dirty reads, non-repeatable reads, and Phantom reads. This is not the case with most database default object isolation Levels)
3.isolation_read_committed(committed) guarantees that a transaction modified data is committed before it can be read by another transaction. Another transaction cannot read uncommitted data for the transaction. This level of transaction isolation avoids dirty reads, but non-repeatable reads and phantom reads can occur.
What is dirty reading? (Modified and not submitted)For example: Zhang San's salary is 5000 and transaction a changes his salary to 8000, but transaction a has not yet been submitted. At the same time, transaction B is reading Zhang San's salary and reading to Zhang San's salary is 8000. Then, transaction A has an exception, and the transaction is rolled back. Zhang San's wages were rolled back to 5000. Finally, the data that transaction B reads to the Zhang San payroll of 8000 is dirty data, and transaction B does a dirty reading. (This is not the case with most database default object isolation levels); 4.Isolation_repeatable_read(Repeatable Read) This level of transaction isolation prevents dirty reads and cannot be read repeatedly. However, Phantom reads may occur.

What is non-repeatable reading? (Modification caused)
For example: In transaction A, the salary read to Zhang San is 5000, the operation is not completed, and the transaction is not committed.
At the same time, transaction B changed the salary of Zhang San to 8000 and submitted the transaction. Then, in transaction A, the salary of the Zhang San is read again, at which time the salary becomes 8000. The result of two reads in a transaction does not cause a non-repeatable read.
(This is not the case with most database default object isolation Levels)

5.isolation_serializable(can be read serially)
This is the most cost-effective, but most reliable, transaction isolation level. Transactions are processed for sequential execution. In addition to preventing dirty reading, non-repeatable reading, but also avoids the phantom reading.
What is Phantom reading? (caused by adding a new record)
For example:
A currently employs 10 people with a salary of 5000, and transaction a reads all salaries at 5000 of 10 people. At this point, transaction B inserts a record with a salary of 5000. This is, transaction a reads the employee with a payroll of 5000 again, and records 11 people. This creates a phantom read.
This is the case with most database default object isolation levels, which will result in table-level locks.

Description:The Default object isolation level for Oracle database has been guaranteed to avoid dirty reads and non-repeatable reads. However, it is possible to read the Phantom, avoid the need to add table-level lock, Oracle default row-level lock. It is important to use Isolation_serializable's isolation level carefully in the spring-based thing configuration. This configuration uses table-level locks and has significant performance implications. In general, there is no special need, configured to use the database default thing isolation level can be

Spring-The isolation level of things

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.