MySQL回滚不删除新记录-续集

MySQL回滚不删除新记录-续集,mysql,node.js,sequelize.js,mysql-5.7,Mysql,Node.js,Sequelize.js,Mysql 5.7,我正在使用sequelizev5.1.0在MySQL5.7.25-0ubuntu0.18.04.2中创建一个事务。它似乎正在根据执行正确的命令,但是,插入并回滚的记录随后仍存在于数据库中 javascript let promises = [] models.sequelize.transaction(function (t) { promises.push(models.alert.create(setter, { transaction: t })) promises.push(ne

我正在使用sequelize
v5.1.0
在MySQL
5.7.25-0ubuntu0.18.04.2
中创建一个事务。它似乎正在根据执行正确的命令,但是,插入并回滚的记录随后仍存在于数据库中

javascript

let promises = []
models.sequelize.transaction(function (t) {
  promises.push(models.alert.create(setter, { transaction: t }))
  promises.push(new Promise((resolve, reject) => {
    reject(new Error('roll it back yall'))
  }))
  return Promise.all(promises)
}).then(function () {
  console.log('SUCCESS!!! (will commit)')
}).catch(function (err) {
  console.log('FAILURE !!! (will rollback)')
  next(err)
})
SQL查询日志

| 2019-03-21 12:55:17.798200 | root[root] @  [10.211.55.2] |      2151 |         0 | Query        | START TRANSACTION                                                                                                                                                                                                                                                                         |
| 2019-03-21 12:55:19.597304 | root[root] @  [10.211.55.2] |      2151 |         0 | Prepare      | INSERT INTO `alerts` (`id`,`user_id`,`alert_name`,`reading_type`,`reading_condition`,`reading_value`,`always_active`,`sensors_global`,`enabled`,`last_updated`,`updated`) VALUES (DEFAULT,?,?,?,?,?,?,?,?,?,?)                                                                            |
| 2019-03-21 12:55:19.616278 | root[root] @  [10.211.55.2] |      2151 |         0 | Execute      | INSERT INTO `alerts` (`id`,`user_id`,`alert_name`,`reading_type`,`reading_condition`,`reading_value`,`always_active`,`sensors_global`,`enabled`,`last_updated`,`updated`) VALUES (DEFAULT,21,'Test Alert','temperature','below',60,1,0,1,'2019-03-21 12:55:17.781','2019-03-21 12:55:17') |
| 2019-03-21 12:55:19.619249 | root[root] @  [10.211.55.2] |      2151 |         0 | Query        | ROLLBACK
之后在数据库中记录

mysql> select * from alerts where alert_name='Test Alert';
+-------+---------+------------+--------------+-------------------+---------------+---------------+---------------+----------------+---------+---------------------+---------------------+
| id    | user_id | alert_name | reading_type | reading_condition | reading_value | alert_message | always_active | sensors_global | enabled | updated             | last_updated        |
+-------+---------+------------+--------------+-------------------+---------------+---------------+---------------+----------------+---------+---------------------+---------------------+
| 48689 |      21 | Test Alert | temperature  | below             |         60.00 | NULL          |             1 |              0 |       1 | 2019-03-21 06:55:17 | 2019-03-21 12:55:18 |
+-------+---------+------------+--------------+-------------------+---------------+---------------+---------------+----------------+---------+---------------------+---------------------+
1 row in set (0.00 sec)
更新: 在
MySQL
CLI中四处搜索会发出警告:

mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into contacts ( user_id, contact_name ) values (21, 'Some Person' );
Query OK, 1 row affected (0.00 sec)

mysql> rollback;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+---------------------------------------------------------------+
| Level   | Code | Message                                                       |
+---------+------+---------------------------------------------------------------+
| Warning | 1196 | Some non-transactional changed tables couldn't be rolled back |
+---------+------+---------------------------------------------------------------+
1 row in set (0.00 sec)

是什么使某些表成为非事务性的?

似乎
警报
表正在使用
MyISAM
引擎,该引擎:

要更改db引擎,请遵循指南和:


mysql>ALTER TABLE alerts ENGINE=InnoDB

似乎
警报表正在使用
MyISAM
引擎,该引擎:

要更改db引擎,请遵循指南和:

mysql>ALTER TABLE alerts ENGINE=InnoDB

mysql> show table status like 'alerts';
+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| Name   | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time         | Check_time | Collation       | Checksum | Create_options | Comment |
+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| alerts | MyISAM |      10 | Dynamic    |   18 |            136 |        2712 | 281474976710655 |         2048 |       256 |          48690 | 2019-03-19 10:38:39 | 2019-03-21 06:55:19 | NULL       | utf8_general_ci |     NULL |                |         |
+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
1 row in set (0.00 sec)