What is ACID guaranteed by?
atomicity
- Atomicity is
undolog
preserved by the log, which records the log information that needs to be rolled back. - What does it mean to undo the successfully executed SQL statement when the transaction is rolled back?
- When we do some SQL operations such as adding, deleting, and modifying, it has already retained a historical version of data before, and this historical version of data will exist in the undolog
- When we write one
insert
, we will record onedelete
- When we write one
- So when you roll back, it will find your corresponding historical version data
- Then write back to undo the SQL statement that was successfully executed before. At this time, the most basic rollback operation is completed, which is a guarantee for atomicity.
Persistence
- Persistence is guaranteed by what? Persistence is guaranteed
redolog
by - When we want to modify the data, MySQL first finds the "page" (that is, the leaf node on the B+ tree) where this record is located, then loads the page into memory, and modifies it in memory.
- A redo log will also be written, which records what modifications were made on a certain page and what SQL was executed this time.
- Even if MySQL hangs up in the middle, we can still restore the data according to the redo log.
isolation
- What is isolation?
- We need to ensure that our transactions will not be disturbed by each other, and each transaction is isolated from each other.
- Therefore, this time needs to be realized through MVCC technology .
- MVCC is Multi-Version Concurrency Control , a technique that is cumbersome and contains a lot of information.
- Isolation is guaranteed by MVCC -> RR and RC isolation occurs
consistency
- Consistency is what transactions are for
- The previous guarantees of atomicity, persistence, and isolation are all to ensure consistency