MySQL transaction isolation level details

MySQL transaction isolation level details

serializable serialization (no problem)

Transactions must be executed in a sequential manner. The subsequent transactions cannot be committed before the previous transaction is committed. This is the safest method, but concurrent operations are not possible, resulting in low efficiency.

repeatab read repeatable read (default isolation level) (phantom read)

Before a transaction is committed, no matter how many queries are executed, the query results are the same (even if the record has been modified by other transactions), but phantom reads may occur.

read committed committed (non-repeatable, phantom read)

In the current transaction, data submitted by other transactions can be seen, which may lead to non-repeatable read (after another thread submits data, the current thread can see it, and then the results of the same SQL query twice before and after will be different (compared to repeatable read)).

Phantom reading may also occur
User1 queries wangwu and finds that it does not exist. Then user2 starts a transaction and inserts wangwu but does not commit the data. User1 queries again and still finds that it does not exist. The operation of inserting wangwu is executed, but the operation fails. Obviously, wangwu does not exist but cannot be inserted, resulting in phantom read.

read uncommitted uncommitted (phantom read, non-repeatable read, dirty read)

  • Dirty read: The current transaction will read data that is not committed by other transactions. If other transactions are rolled back, the data read by the current transaction is illegal, which is called dirty read.
  • Non-repeatable read occurs: modifications submitted by other transactions will be perceived by the current transaction, so the query results are different.
  • Phantom read occurs: First, user 1 queries wangwu and it does not exist. User 2 starts a transaction and inserts wangwu but does not commit the transaction. At this time, user1 queries wangwu and finds that it exists.

The deletewangwu operation failed. wangwu was found but could not be deleted?

This is the end of this article about the details of MySQL transaction isolation levels. For more information about MySQL transaction isolation levels, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • In-depth understanding of Mysql transaction isolation level and locking mechanism issues
  • MySQL Series 10 MySQL Transaction Isolation to Implement Concurrency Control
  • Mysql transaction isolation level principle example analysis
  • Detailed explanation of Mysql transaction isolation level read commit
  • In-depth understanding of the four isolation levels of MySQL transactions

<<:  How to turn off eslint detection in vue (multiple methods)

>>:  Detailed explanation of html download function

Recommend

Advanced Usage Examples of mv Command in Linux

Preface The mv command is the abbreviation of mov...

Solution to garbled display of Linux SecureCRT

Let's take a look at the situation where Secu...

How to simply configure multiple servers in nginx

1: I won’t go into the details of how to install ...

Example code for implementing hexagonal borders with CSS3

The outermost boxF rotates 120 degrees, the secon...

Implementing the preview function of multiple image uploads based on HTML

I recently wrote a script for uploading multiple ...

When backing up files in Centos7, add the backup date to the backup file

Linux uses files as the basis to manage the devic...

Mysql backup multiple database code examples

This article mainly introduces the Mysql backup m...

An article to quickly understand Angular and Ionic life cycle and hook functions

Table of contents Angular accomplish Calling orde...

Tutorial on installing MYSQL8.X on Centos

MySQL installation (4, 5, 6 can be omitted) State...

Sample code for installing ASPNET.Core3.0 runtime in Linux

# The following examples are for x64-bit runtime ...

CSS animation property usage and example code (transition/transform/animation)

During development, a good user interface will al...