舉個(gè)例子吧。自己實(shí)驗(yàn)了一下。
對(duì)MYSQL的innodb 和 ndb 引擎對(duì)事務(wù)的處理
對(duì)于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)
對(duì)于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ù)。
其他的等待測(cè)試。。。
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。