当前位置:网站首页>Yyds dry inventory MySQL RC transaction isolation level implementation
Yyds dry inventory MySQL RC transaction isolation level implementation
2022-07-01 16:58:00 【Official account javaedge】
Read Committed, During the transaction , As long as other transactions modify the data and submit , You can read the data modified by others , So there will be non repeatable 、 The problem of unreal reading .
ReadView The mechanism is based on undo log A set of view reading mechanism implemented by version chain , The transaction generates a ReadView:
- If the data is updated for the transaction itself , I can read
- Or when you generate ReadView The value modified by the previously submitted transaction , Also readable
- But if you generate ReadView when , It's already active , But if it's in your generation ReadView Then modified the data and submitted , You can't read
- Or you generate ReadView The transaction started later modifies the data , Also submitted , I can't read
So the above mechanism is ReadView How a principle of is based on ReadView Realization RC? Core design : When a transaction is set RC, Every time he makes a query , Regenerate a ReadView!
There is a row of data in the database , It's a business id=50 A business of , Inserted a long time ago , Currently active transactions :
- Business A(id=60)
- Business B(id=70)
Now business B launch update, Update this data to b, So at this time, the data trx_id Will become a business B Of id=70, At the same time, a undo log:
At this time , Business A To initiate a query operation , It will generate a ReadView
When the transaction A Initiate a query , Find the current data trx_id=70. Belong to ReadView The business of id Between ranges , It means that he generated ReadView There was this active business before , It is this transaction that modifies the value of this data , But at this point the business B It hasn't been submitted yet , therefore ReadView Of m_ids In the active transaction list , Yes [60, 70] Two id, At this point, according to ReadView Mechanism , Business A Cannot find transaction B Modified value b.
Then follow it undo log Look down the version chain , You'll find an original value , Found that the trx_id yes 50, Less than the present ReadView Inside min_trx_id, It means that he generated ReadView Before , There is a transaction that inserts this value and has already committed , So you can find the original value .
next , What if B Submit , When submitted, the transaction will be explained B Will not be active in the database . Business A Check again next time , You can read the transaction B The modified value . How on earth does that make things A Be able to read the submitted transaction B The modified value ?
Make the transaction A Next time you initiate a query , Regenerate into one ReadView, The only active transactions in the database are transactions A, therefore :
- min_trx_id yes 60
- mac_trx_id yes 71
- m_ids=60, Business B Of id=70 Will not appear in m_ids Active transaction list
At this point, the transaction A Again, based on this ReadView Go to query , You'll find this data trx_id=70, Although in ReadView Of min_trx_id and max_trx_id Between ranges , But not at this time m_ids In the list , Explain the business B When generating this ReadView Submitted before . Explain that you can find the transaction this time B The modified value , At this point, the transaction A You'll find the value B.
边栏推荐
- 中国氮化硅陶瓷基板行业研究与投资前景报告(2022版)
- 中国冰淇淋市场深度评估及发展趋势预测报告(2022版)
- C語言輸入/輸出流和文件操作
- Rhcsa Road
- Redis Distributed Lock
- China sorbitol Market Forecast and investment strategy report (2022 Edition)
- 嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!
- Report on Market Research and investment prospects of ammonium dihydrogen phosphate industry in China (2022 Edition)
- ACM MM 2022视频理解挑战赛视频分类赛道冠军AutoX团队技术分享
- Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
猜你喜欢
Flux d'entrées / sorties et opérations de fichiers en langage C
英特尔开源深度学习工具库 OpenVINO,将加大与本土软硬件方合作,持续开放
How wild are hackers' ways of making money? CTF reverse entry Guide
Building blocks for domestic databases, stonedb integrated real-time HTAP database is officially open source!
美国国家安全局(NSA)“酸狐狸”漏洞攻击武器平台技术分析报告
[live broadcast appointment] database obcp certification comprehensive upgrade open class
如何使用 etcd 实现分布式 /etc 目录
How to repair the laptop that cannot connect to the wireless network
Bugku's file contains
Activity的生命周期和启动模式详解
随机推荐
[nodemon] app crashed - waiting for file changes before starting... resolvent
求求你们,别再刷 Star 了!这跟“爱国”没关系!
如何使用 etcd 实现分布式 /etc 目录
Redis6.0 new features
Building blocks for domestic databases, stonedb integrated real-time HTAP database is officially open source!
嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!
Research and investment strategy report of hydroxypropyl beta cyclodextrin industry in China (2022 Edition)
重磅披露!上百个重要信息系统被入侵,主机成为重点攻击目标
C language input / output stream and file operation
Transition technology from IPv4 to IPv6
[Supplément linguistique c] déterminer quel jour est demain (date de demain)
【C语言补充】判断明天是哪一天(明天的日期)
Rhcsa Road
Ring iron pronunciation, dynamic and noiseless, strong and brilliant, magic wave hifiair Bluetooth headset evaluation
Sword finger offer II 015 All modifiers in the string
[kotlin] Introduction to higher-order functions
免费抽奖 | 《阿巴豆》探索未来系列盲盒数字版权作品全网首发!
sql刷题584. 寻找用户推荐人
Redis Distributed Lock
The amazing open source animation library is not only awesome, but also small