ITPub博客

首页 > 数据库 > MySQL > mysql ndbcluster引擎不支持可重复读(ndb-7.3.3)

mysql ndbcluster引擎不支持可重复读(ndb-7.3.3)

原创 MySQL 作者:denglt 时间:2014-02-13 11:57:45 0 删除 编辑

mysql ndbcluster引擎不支持可重复读

MySQL在事务隔离级别为Repeatable read时是可以支持可重复读的。
如innodb。http://www.cnblogs.com/zhoujinyi/p/3437475.html

但在ndbcluster下并不是如此,见如下实验:

mysql> select @@version;
+------------------+
| @@version        |
+------------------+
| 5.6.14-ndb-7.3.3 |
+------------------+
1 row in set (0.00 sec)

mysql> select @@tx_isolation;
+-----------------+
| @@tx_isolation  |
+-----------------+
| REPEATABLE-READ |
+-----------------+
1 row in set (0.00 sec)

在session1执行:

mysql> set autocommit =0;
Query OK, 0 rows affected (0.00 sec)

mysql> show create table t1;
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `id` int(11) NOT NULL,
  `name` varchar(100) DEFAULT NULL,
  `age` int(11) DEFAULT NULL,
  `age2` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8 |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from t1;
+----+--------+------+------+
| id | name   | age  | age2 |
+----+--------+------+------+
|  1 | denglt |   33 | NULL |
|  2 | denglt |   33 | NULL |
+----+--------+------+------+
2 rows in set (0.00 sec)


在session2执行:
mysql> begin;
Query OK, 0 rows affected (0.01 sec)

mysql> update t1 set age=36;
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> commit;
Query OK, 0 rows affected (0.01 sec)

mysql> select * from t1;
+----+--------+------+------+
| id | name   | age  | age2 |
+----+--------+------+------+
|  1 | denglt |   36 | NULL |
|  2 | denglt |   36 | NULL |
+----+--------+------+------+
2 rows in set (0.00 sec)

回到session1执行:
mysql> select * from t1;
+----+--------+------+------+
| id | name   | age  | age2 |
+----+--------+------+------+
|  1 | denglt |   36 | NULL |
|  2 | denglt |   36 | NULL |
+----+--------+------+------+
2 rows in set (0.00 sec)


数据age例变为了36,session1在Repeatable read隔离级别没有可重复读。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/195110/viewspace-1080730/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-11-04

  • 博文量
    118
  • 访问量
    719348