|
舉個(gè)例子吧。自己實(shí)驗(yàn)了一下。 對MYSQL的innodb 和 ndb 引擎對事務(wù)的處理 對于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遇到錯(cuò)誤就終止了,回滾到最初的狀態(tài)。 而INNODB遇到錯(cuò)誤還是繼續(xù)執(zhí)行已經(jīng)成功事務(wù)。 其他的等待測試。。。 |
|
|