亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

mvcc中的read_view

發布時間:2020-08-04 12:39:12 來源:ITPUB博客 閱讀:244 作者:lff1530983327 欄目:MySQL數據庫
innodb的mvcc和read view
最近讀High Performance MySQL,里面提到了innodb事務隔離級別是REPEATABLE-READ時,有這樣一段話
引用

SELECT
InnoDB must examine each row to ensure that it meets two criteria:
a. InnoDB must find a version of the row that is at least as old as the transaction
(i.e., its version must be less than or equal to the transaction’s version). This
ensures that either the row existed before the transaction began, or the trans-
action created or altered the row.
b. The row’s deletion version must be undefined or greater than the transaction’s
version. This ensures that the row wasn’t deleted before the transaction began.
Rows that pass both tests may be returned as the query’s result.

來驗證一下
show create table 20130302t1;

 CREATE TABLE `20130302t1` (
  `id` int(11) NOT NULL,
  `b` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB

表中有數據(1,1)
autocommit為false, tx_isolation 是REPEATABLE-READ
考慮以下兩種情況
情況1
session A session B
start transaction;(A)
start transaction
update 20130302t1 set b=2 where id=1;
commit;
select * from 20130302t1;(B)

B處結果為(1,2),似乎不符合那段話里的a條件,A事務看到了transaction version更大的B事務

情況2
session A     session B
                           start transaction
                          update 20130302t1 set b=2 where id=1;
start transaction
select * from 20130302t1;
                            commit;
select * from 20130302t1;(C)


C處結果為(1,1),也就是說,A事務沒有看到transaction version更小的B事務

是不是那段話有問題呢,后來終于找到了官方的文檔,innodb通過read view來確定一致性讀時的數據庫snapshot,innodb的read view確定一條記錄能否看到,有兩條法則
1 看不到read view創建時刻以后啟動的事務
2 看不到read view創建時活躍的事務

引用
Rule 1: When the read view object is created it notes down the smallest transaction identifier that is not yet used as a transaction identifier (trx_sys_t::max_trx_id).   The read view calls it the low limit. So the transaction using the read view must not see any transaction with identifier greater than or equal to this low limit.

Rule 2: The transaction using the read view must not see a transaction that was active when the read view was created.


在情況1中,代碼A處并沒有創建read view,read view是在代碼B處創建的.
如果把A處代碼改為 START TRANSACTION WITH CONSISTENT SNAPSHOT;
才會創建read view,使得代碼B返回(1,1)

在情況2中,B事務在A事務創建read view時處于ACTIVE狀態,所以B事務不會被A事務看到.


這篇文章還提到了mysql5.6 在read only事務的優化,值得一看
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

南澳县| 长宁县| 公安县| 宁城县| 桐梓县| 阆中市| 平邑县| 水富县| 盐山县| 曲周县| 上犹县| 驻马店市| 乐山市| 万年县| 白河县| 泰宁县| 华安县| 渭源县| 长沙县| 钟祥市| 绥江县| 惠州市| 若尔盖县| 吴江市| 淄博市| 彭泽县| 寻乌县| 宣城市| 喀喇沁旗| 威宁| 天水市| 澳门| 阳信县| 和林格尔县| 巴彦淖尔市| 嘉兴市| 庄河市| 眉山市| 金山区| 胶南市| 佛教|