您的位置:首页 > 数据库 > MySQL

MYSQL集群与INNODB事务处理的对比总结

2008-02-19 18:36 1181 查看
举个例子吧。自己实验了一下。
对MYSQL的innodb 和 ndb 引擎对事务的处理
对于NDB
mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into foo values(1);
Query OK, 1 row affected (0.01 sec)

mysql> insert into foo values(1);
ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
mysql> commit;
ERROR 1296 (HY000): Got error 4350 'Transaction already aborted' from NDBCLUSTER
mysql> show errors;
+-------+------+--------------------------------------------------------------+
| Level | Code | Message |
+-------+------+--------------------------------------------------------------+
| Error | 1296 | Got error 4350 'Transaction already aborted' from NDB |
| Error | 1296 | Got error 4350 'Transaction already aborted' from NDBCLUSTER |
| Error | 1180 | Got error 4350 during COMMIT |
+-------+------+--------------------------------------------------------------+
3 rows in set (0.00 sec)

mysql> select * from foo;
Empty set (0.00 sec)
对于INNODB
mysql> create table foo2 (i int not null primary key) engine innodb;
Query OK, 0 rows affected (0.00 sec)
mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into foo2 values(1);
Query OK, 1 row affected (0.00 sec)

mysql> insert into foo2 values(1);
ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from foo2;
+---+
| i |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
NDB遇到错误就终止了,回滚到最初的状态。
而INNODB遇到错误还是继续执行已经成功事务。

其他的等待测试。。。

本文出自 “上帝,咱们不见不散!” 博客,转载请与作者联系!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: