Mvcc principle and unreal reading of [MySQL] transaction

Program ape Owen 2021-02-23 12:07:46
mvcc principle unreal reading mysql


First of all, understand MVCC,MVCC It's called multi version concurrency control , It's actually Save a snapshot of the data at a certain time node .

We actually hide two columns per row , Create version number , Be overdue ( Delete ) Version number , Every time you start a new business , The version number will increase automatically .

 

take user For example , Suppose we insert two pieces of data , They should actually look like this , The creation version number is incremented .

id name create_version delete_version
1 Zhang San 1  
2 Li Si 2  

At this time, let's assume that Xiao Ming performs the query , At this time, too A transaction will be opened by default The current version is current_version=3

select * from user where id<=3;

 

meanwhile , At this time, Xiaohong opens the transaction to modify id=1 The record of , Xiaohong transaction version is current_version=4

update user set name=' Zhang Sansan ' where id=1;

The result of Xiaohong's successful execution is like this

id name create_version delete_version
1 Zhang San 1  
2 Li Si 2  
1 Zhang Sansan 4  

 

meanwhile ,  And black is deleting id=2 The data of , Xiaohei's version is current_version=5, This is the result of Xiaohei's execution .

id name create_version delete_version
1 Zhang San 1  .........
版权声明
本文为[Program ape Owen]所创,转载请带上原文链接,感谢
https://javamana.com/2021/02/20210223120506586p.html

  1. springboot中的定时任务
  2. Summary of common commands in Linux operating system
  3. Linux - Linux developer's own media
  4. Linux - Linux developer's own media
  5. Linux system service control (detailed)
  6. Summary of Linux common commands (continuous update)
  7. Construction of Kafka cluster
  8. Construction of Kafka cluster
  9. Format of string in Java -- format
  10. Mybatis源码与Spring源码中设计模式的应用总结
  11. Introduction and advance of default text editor VIM in Linux
  12. Common linux commands
  13. CEPH docking k8s storage class
  14. Crawler series | 2, HTTP request and response, write crawler these contents must master
  15. Bitwise operators in JavaScript
  16. Four magic functions of mybatis, don't step on the pit!
  17. Linux diff command
  18. javascript当中delTRTDIEFF的用法
  19. The usage of deltrtdieff in JavaScript
  20. Truth and misunderstanding of Linux kernel maintainer!
  21. Mysql 解法(通解任意连续n问题)
  22. C connection and use of MySQL database detailed tutorial
  23. MySQL solution (general solution to any continuous n problem)
  24. [Linux] learn operation and maintenance step by step - Basic chapter - Linux system directory
  25. Cloud native project practice Devops (gitops) + k8s + BPF + SRE, using golang to develop production level mahjong game server from 0 to 1
  26. Introduction to Linux
  27. Easy understanding of MySQL mvcc implementation mechanism
  28. Linux foundation 3 (regular expression)
  29. Linux file directory management -- creating
  30. Java makes user easy excel import and export Excel
  31. Java makes user easy excel import and export Excel
  32. Using quickjs JavaScript engine in Android
  33. Using quickjs JavaScript engine in Android
  34. Kafka source code analysis (3) - server - message storage
  35. Linux shell string operation (length, find, replace) detailed explanation
  36. Linux tools for handling binary files
  37. Dubbo interview: what design patterns are used in Dubbo?
  38. Regular expression in MySQL database
  39. Java series course column "100 +"
  40. Linux learning notes for basic skills training of big data development engineers (2)
  41. Maven summary
  42. 190 spark vs storm
  43. Mybatis (I): detailed explanation of mybatis configuration file config.xml
  44. The most complete linux learning notes in the history of basic skills cultivation of big data development engineers (recommended Collection)
  45. The most complete linux learning notes in the history of basic skills cultivation of big data development engineers (recommended Collection)
  46. Mysql to view and modify system parameters