当前位置:网站首页>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.
边栏推荐
猜你喜欢

实例030:回文数

2022.07.31(LC_6132_使数组中所有元素都等于零)

海缆探测仪TSS350(二)

Mysql报错2003 解决办法 Can‘t connect to MySQL server on ‘localhost‘ (10061)

实例027:递归输出

MQ带来的一些问题、及解决方案

21 days learning challenge 】 【 sequential search

【图像隐藏】基于matlab混合DWT-HD-SVD数字图像水印方法技术【含Matlab源码 2007期】

PWA 踩坑 - 第一次加载页面后无法获取CacheStorage某些资源

主流定时任务解决方案全横评
随机推荐
暑假第五周总结
【故障诊断分析】基于matlab FFT轴承故障诊断(包络谱)【含Matlab源码 2002期】
OC-NSString
CollectionUtil:一个函数式风格的集合工具
SQL server 2014 怎么一次性导出多个查询结果?
mysql操作入门(四)-----数据排序(升序、降序、多字段排序)
spark架构
ADS通信--倍福PLC和C#TextBox控件实现数据绑定的方法
LeetCode刷题(7)
2022夏暑假每日一题(六)
Splunk Filed extraction 字段截取
WebGPU 导入[2] - 核心概念与重要机制解读
获取间隔的日期列表工具类
【红队】ATT&CK - 创建或修改系统进程实现持久化(更新ing)
OC-范畴
View port number occupancy
飞桨paddle技术点整理
2022年数据泄露平均成本高达435万美元,创历史新高!
MQ带来的一些问题、及解决方案
入门opencv,欢笑快乐每一天