当前位置:网站首页>Is the transaction in mysql45 isolated or not?
Is the transaction in mysql45 isolated or not?
2022-07-26 05:52:00 【lingengy】

Business id
InnoDB Each transaction has a unique transaction ID, called transaction id. It is at the beginning of the transaction to InnoDB Of the transaction system , It is strictly increasing in the order of application .
And each row of data has multiple versions . Every time a transaction updates data , Will generate a new data version , And the transaction id The transaction assigned to this data version ID, Write it down as row trx_id. meanwhile , Keep the old data version , And in the new data version , You can get information directly .
in other words , A row in a data table , There may be multiple versions (row), Each version has its own row trx_id.
Snapshots and views
stay MySQL in , There are two “ View ” The concept of :
- One is view. It is a virtual table defined by a query statement , Execute the query statement at the time of the call and generate the result . The syntax for creating a view is create view … , And its query method is the same as the table .
- The other is InnoDB In the realization of MVCC Consistent read view used in , namely consistent read view, Used to support RC(Read Committed, Read the submission ) and RR(Repeatable Read, Repeatable ) Implementation of isolation level .
View has no physical structure , It is used to define during the execution of a transaction “ What data can I see ”.
At repeatable read isolation level , When the transaction starts “ Took a snapshot ”. Be careful , This snapshot is based on the entire library .

On the implementation , InnoDB An array is constructed for each transaction , Used to save the transaction startup moment , Right now “ active ” All the business of ID.“ active ” Refers to , Launched but not yet submitted .
A data version , For a transaction view , Except that your updates are always visible , There are three situations :
- Version not submitted , invisible ;
- Version submitted , But it was submitted after the view was created , invisible ;
- Version submitted , And it was submitted before the view was created , so .
Update logic
The updated data is read first and then written , And this read , Can only read the current value , be called “ The current reading ”(current read).
therefore , In the execution of the transaction B When querying statements , Take a look at their own version number is 101, The version number of the latest data is also 101, It's your own update , You can use it directly , So the query results in k The value of is 3.
Here we mention a concept , It's called current reading . Actually , except update Out of statement ,select If the statement is locked , It's also the current reading .
therefore , If the business A Query statement select * from t where id=1 Revise it , add lock in share mode or for update, You can also read that the version number is 101 The data of , Back to k The value of is 3. The next two select sentence , That is to add the read lock respectively (S lock , Shared lock ) And write lock (X lock , Exclusive lock ).
mysql> select k from t where id=1 lock in share mode;
mysql> select k from t where id=1 for update;
边栏推荐
- Debugging sharp weapon! A lightweight log library log.c
- Unity Profiler
- [MySQL must know and know] time function number function string function condition judgment
- 一招教你轻松看懂波特图
- Use latex to typeset multiple-choice test paper
- Solve vagrant's error b:48:in `join ': incompatible character encodings: GBK and UTF-8 (encoding:: Compatib
- Rocbossphp free open source light community system
- 软件测试面试题全网独家没有之一的资深测试工程师面试题集锦
- Kingbasees SQL language reference manual of Jincang database (6. Expression)
- L. Link with Level Editor I dp
猜你喜欢

漫谈软件缺陷管理的实践

520送什么?DIY一个高颜值RGB时钟,女生看了都想要

unity 像素画导入模糊问题

Solution to slow download speed of vagrant

The idea YML file code does not prompt the solution

对接微信支付(二)统一下单API
![ERROR: Could not open requirements file: [Errno 2] No such file or directory: ‘requirments.txt’](/img/15/25ff1e544565e18319ecca85e614a2.png)
ERROR: Could not open requirements file: [Errno 2] No such file or directory: ‘requirments.txt’

中文文本纠错任务简介

JDBC streaming query and cursor query

芯片的翻新和造假,人被坑麻了
随机推荐
金仓数据库 KingbaseES SQL 语言参考手册 (9. 常见DDL子句)
Two auxiliary functions of integral Mall for business user operation
Detailed explanation of the whole process of coding's pressure measurement operation
漫谈软件缺陷管理的实践
Establishment of log collection and analysis platform-1-environment preparation
520送什么?DIY一个高颜值RGB时钟,女生看了都想要
卸载手机自带APP的操作步骤
Day110.尚医通:Gateway集成、医院排班管理:科室列表、根据日期统计数据、排班详情
A trick to teach you to easily understand Potter's map
Autumn move - Preparation Plan
How to understand "array name is essentially an address" from the perspective of memory parsing?
金仓数据库 KingbaseES SQL 语言参考手册 (8. 函数(十))
Application of canoe XML in test modules
Hack the box - Web requests module detailed Chinese tutorial
Processing method of CDC in SDC
Jupiter notebook shortcut key
Can you make a JS to get the verification code?
光量子里程碑:6分钟内解决3854个变量问题
调试利器!一款轻量级日志库 log.c
Benji Bananas 开启第二季边玩边赚奖励活动,支持使用多张 Benji 通行证!