当前位置:网站首页>Characteristics of transactions -- atomicity (implementation principle)
Characteristics of transactions -- atomicity (implementation principle)
2022-06-13 00:56:00 【-LM-】
The nature of transactions —— Atomicity ( Realization principle )
Atomicity of a transaction means that all operations in a transaction are indivisible , Must be a logical unit , It can only be all successful or all failed .( A typical example : Transfer accounts ). So how to guarantee the atomicity of transactions ? Before that, we need to say MySQL Medium WAL Mechanism .
WAL Mechanism
WAL Its full name is Write-Ahead Logging, Pre write log system . It mainly refers to MySQL When performing a write operation, it is not immediately updated to the disk , But first record it in the log , Then update to disk at the right time . Logs are mainly divided into undo log、redo log、binlog.
How transaction atomicity is guaranteed ?
MySQL The atomicity of a transaction is through ***undo log*** To achieve . Disk data is stored randomly , This makes it necessary not only to record the stored data value when storing data , You also need to record the address where the data is stored , The storage speed is relatively slow . Log storage is continuous storage , Therefore, when saving data, you only need to record the first address , The remaining data record offset , Can further improve performance .
Every write transaction , Will be modified BufferPool, And the corresponding Redo/Undo journal , These log information will be recorded in the log file . stay MySQL in , whatever BufferPool Before the pages in are flushed to disk , Will be written to the log file first , If BufferPool Data submission in , At this point, the database is down , So after the database starts again , You can go through Redo Log to recover it , To ensure that the data will not be lost . If the data is not submitted , At this point, the database is down , It needs to pass Undo Log to achieve .
Every piece of data changes (insert/update/delete) The operation is accompanied by a undo log Generation , And the rollback log must be persisted to the disk before the data . The so-called rollback is to do the reverse operation according to the rollback log , such as delete The reverse operation of is insert,insert The reverse operation of is delete,update The reverse is update etc. .
边栏推荐
猜你喜欢

Traditional machine learning classification model predicts the rise and fall of stock prices under more than 40 indicators

三栏简约typecho主题Lanstar/蓝星typecho主题

Hard (magnetic) disk (II)

kotlin 协程withContext切换线程

Canvas random bubbling background
![[buglist] serial port programming does not read data](/img/bf/8e63f679bf139fbbf222878792ae21.jpg)
[buglist] serial port programming does not read data

Comparison of disk partition modes (MBR and GPT)

MySQL exception: com mysql. jdbc. PacketTooBigException: Packet for query is too large(4223215 > 4194304)

(01).NET MAUI实战 建项目
![[imx6ull] video monitoring project (USB camera +ffmepeg)](/img/f9/1a7b68083b52c973336db9044b52c2.jpg)
[imx6ull] video monitoring project (USB camera +ffmepeg)
随机推荐
[JS component] customize the right-click menu
Et5.0 simply transform referencecollectorieditor
Biological unlocking - Fingerprint entry process
[imx6ull] video monitoring project (USB camera +ffmepeg)
Deep learning model pruning
Expression tree - medium order printout
With a market value of more than trillion yuan and a sales volume of more than 100000 yuan for three consecutive months, will BYD become the strongest domestic brand?
Blinker FAQs
Android Weather
Quick power explanation
Canvas random bubbling background
How many steps are appropriate for each cycle of deep learning?
[Latex] 插入图片
深度学习训练多少轮?迭代多少次?
生物解锁--指纹录入流程
Four startup modes of kotlin collaboration
什么是 dummy change?
MCU serial port interrupt and message receiving and sending processing -- judge and control the received information
Key point detection data preparation and model design based on u-net Network -- detection model of four key points of industrial components
Dynamic planning - good article link