標籤:image -- ble efault variable nsis action snapshot default
Server version: 5.6.21-log MySQL Community Server (GPL)
前提提要:
我們知道MySQL的RR(repeatable read)隔離等級下,事務無法看到正在活躍的事務所做的操作包括提交後的。
一般手動開啟事務的命令是begin或start transaction;我以前的理解是一旦執行這條語句就已經開啟了事務,也就是事務id已經產生(可用於MVCC版本比較),事務A和事務B一起執行begin,事務A的所有操作的提交事務B都看不到;
事實是否定的;
環境:
mysql> show variables like ‘tx_iso%‘;+---------------+-----------------+| Variable_name | Value |+---------------+-----------------+| tx_isolation | REPEATABLE-READ |+---------------+-----------------+1 row in set (0.00 sec)mysql> show variables like ‘auto%‘;+--------------------------+-------+| Variable_name | Value |+--------------------------+-------+| auto_increment_increment | 1 || auto_increment_offset | 1 || autocommit | ON || automatic_sp_privileges | ON |+--------------------------+-------+4 rows in set (0.00 sec)mysql> show create table t12;+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Table | Create Table |+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| t12 | CREATE TABLE `t12` ( `a` int(10) unsigned NOT NULL AUTO_INCREMENT, `b` varchar(766) DEFAULT NULL, `c` int(11) DEFAULT NULL, PRIMARY KEY (`a`), KEY `b` (`b`)) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1 |+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+1 row in set (0.00 sec)
實驗結果是:事務B在未提交和為復原的情況下,看到了事務A提交的資料;
一旦begin;之後緊跟著select語句就開啟了事務;或者以start transaction with consistent snapshot開始事務,就無法看到事務A提交的資料;
也就是實現了非鎖定一致性讀;
結論:begin;start transaction;語句實際上並沒有真正開啟事務;
[原創]MySQL下關於begin或start transaction是否真正開啟新事務的探索?