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

Detailed explanation of Nginx's rewrite module

The rewrite module is the ngx_http_rewrite_module...

Three steps to solve the IE address bar ICON display problem

<br />This web page production skills tutori...

How to implement distributed transactions in MySQL XA

Table of contents Preface XA Protocol How to impl...

Oracle deployment tutorial in Linux environment

1. Environment and related software Virtual Machi...

MySQL uses find_in_set() function to implement where in() order sorting

This article introduces a tutorial about how to u...

Vue.js implements the code of clicking the icon to zoom in and leaving

The previous article introduced how Vue can reali...

Have you really learned MySQL connection query?

1. Inner Join Query Overview Inner join is a very...

Example of how to create a database name with special characters in MySQL

Preface This article explains how to create a dat...

Two ways to completely delete users under Linux

Linux Operation Experimental environment: Centos7...

Solution to input cursor misalignment in Chrome, Firefox, and IE

Detailed explanation of the misplacement of the in...

Steps to repair grub.cfg file corruption in Linux system

Table of contents 1. Introduction to grub.cfg fil...

Reasons why MySQL queries are slow

Table of contents 1. Where is the slowness? 2. Ha...

Tutorial on installing nginx in Linux environment

Table of contents 1. Install the required environ...