The database has four isolation levels, namely:
Solation_read_uncommitted: Allows reading of changed uncommitted data, which can result in dirty reads, non-repeatable reads, and Phantom reads.
Isolation_read COMMITTED: Allows concurrent transactions to be read after committing, avoiding dirty reads, which can result in repeated reads and Phantom reads.
Isolation_repeatable_read: Consistent with multiple reads of the same field, which can result in phantom reads.
Isolation_serializable: The principle of complete compliance with acid, ensuring that no dirty reads, non-repeatable reads, and phantom reads occur.
Four different isolation levels represent the granularity of a database lock on a resource.
Dirty reads: Indicates that the database transaction does not add an exclusive lock when modifying a record, causing other transactions to be queried.
Non-repeatable READ: Indicates that a transaction adds an exclusive lock to a row of records when modifying a database record, which causes other transactions to not be queried and updated, but does not have an exclusive lock on the records of the query until a transaction is complete, and if a transaction queries the same record two times, between two queries, the other transaction may change the current record. The workaround is to lock the records of the query before a transaction is completed, and no other transaction modifications are allowed.
Phantom read: Similar to dirty read, but locked resource granularity is different, dirty read is the same transaction two times query the same record, return different results, and Phantom Read is conditionally query a range of data, such as SELECT * from the users where ID <=20, the first query is 20 records, The second query 19 records, a transaction between two queries, the other transaction deleted a record, resulting in a different two query results. Phantom reading should be a lock table to avoid, that is, lock a transaction query process all tables, can not be updated.
The above is a personal understanding, if there is a mistake, look correct.
Understanding of dirty reads, non-repeatable reads, and Phantom reads in database transactions