当前位置:网站首页>MySQL-Multiversion Concurrency Control
MySQL-Multiversion Concurrency Control
2022-08-02 07:50:00 【kk_lina】
I. Concept
mvcc implements database concurrency control through multiple version management of data rows.This technology ensures that consistent read operations are performed under the transaction isolation level of innoDB.It is to query some rows that are being updated by another transaction, and you can see the values before they are updated, so that you do not have to wait for another transaction to release the lock when doing the query.
Second, snapshot read and current read
mvcc is implemented in MySQL InnoDB mainly to improve the concurrent performance of the database, to better handle read-write conflicts, so that even if there are read-write conflicts, no locks can be added, and non-blocking concurrencyRead, this read refers to snapshot read, not current read.The current read is actually a locking operation, the realization of pessimistic locking, and the essence of mvcc is the realization of optimistic locking.
1. Snapshot read (consistent read)
Reads are snapshot data. Simple selects without locks belong to snapshot reads. They may not be the latest data, but may be historical versions. The premise is that the isolation level is not serial.A snapshot read at the row level may degenerate into a current read.
2. Current reading
The current version is read. When reading, it needs to be locked to ensure that the data under a certain transaction will not be modified by other transactions.
Third, MVCC implementation principle of ReadView
1. What is ReadView
Transactions are used to query the historical snapshots stored in the undo log and provide row visibility. Innodb constructs an array for each transaction to record and maintain the ID of the current active transaction in the system (started but stillnot submitted)
2. Design ideas
- Using READ UNCOMMITED isolation level transactions, you can read uncommitted transactions, so MVCC is not used, so the latest data is read without reading historical data;
- Use the SERIALIZABLE isolation level transaction, innodb stipulates the use of locking to access records;
- Transactions using the READ COMMITTED and REPEATABLE READ isolation levels must ensure that the records modified by the committed transaction are read.Adding another transaction has modified the record but has not yet submitted it, so the latest version of the record cannot be directly read. The core problem is to determine which version in the version chain is visible to the current transaction. This is the main problem to be solved by ReadView.
- cread_trx_id: The transaction id that created this read view;
- trx_ids: A list of transaction ids representing the active read and write transactions in the current system when the read view was generated;
- up_limit_id: The smallest transaction id in active transactions;
- low_limit_id: Indicates the id value that should be assigned to the next transaction in the system when the read view is generated.Is the system's largest transaction id.
边栏推荐
猜你喜欢
随机推荐
Ask a question, my Flinkcdc has run through, I can monitor the binlog of msql, and I can also send kafk
【请教】SQL语句按列1去重来计算列2之和
Splunk Filed Alias field name
Splunk Field Caculated Calculated Field
2022夏暑假每日一题(六)
optional
_2_顺序表
【云原生】如何快速部署Kubernetes
海缆探测仪TSS350(二)
【CNN回归预测】基于matlab卷积神经网络CNN数据回归预测【含Matlab源码 2003期】
【CV】OpenVINO安装教程
【ROS基础】map、odom、base_link、laser 的理解 及其 tf 树的理解
问个问题,我的Flinkcdc已经跑通了,可以监听msql的binlog了,也能发送kafk
CSRF-跨站请求伪造-相关知识
2020美亚团队赛复盘
主流定时任务解决方案全横评
CollectionUtil:一个函数式风格的集合工具
【ROS基础】rosbag 的使用方法
自然语言处理 文本预处理(下)(张量表示、文本数据分析、文本特征处理等)
飞桨paddle技术点整理









