Sequelize.js sequelize事务-只能在LoggedIn状态下发出请求,而不能在SentClientRequest状态下发出请求

Sequelize.js sequelize事务-只能在LoggedIn状态下发出请求,而不能在SentClientRequest状态下发出请求,sequelize.js,sequelize-cli,Sequelize.js,Sequelize Cli,如果我使用Sequelize return models.UnitPlant.findOne( { where: { id: unitPlantToUpdate.id }, include: [ { model: models.ProductType }, { model: models.V

如果我使用
Sequelize

return models.UnitPlant.findOne(
        {
            where:
            {
                id: unitPlantToUpdate.id
            },
            include: [
                { model: models.ProductType },
                { model: models.VehiclePlant, as: 'Customers' }
            ]
        })
        .then(function (unitPlantFromDb) {
            return models
                .sequelize
                .transaction(
                {
                    isolationLevel: models.sequelize.Transaction.ISOLATION_LEVELS.READ_COMMITTED
                },
                function (t) {
                    return unitPlantFromDb.update(unitPlantToUpdate, { transaction: t })
                        .then(function (unitPlantFromDb) {
                            return unitPlantFromDb.setProductType(unitPlant.ProductType.id, { transaction: t })
                        })
                        .then(function (unitPlantFromDb) {
                            return unitPlantFromDb.setCustomers(unitPlant.customerIds, { transaction: t });
                        });
                })
                .then(function (result) {
                    return output.getSuccessResult(titles.SUCCESS, validationMessages.SUCCESS_ON_UPDATE, UNIT_PLANT)
                })
                .catch(function (error) {
                    console.log(error);
                    return output.getErrorResult(titles.ERROR_ON_UPDATE, validationMessages.ERROR_ON_UPDATE, error.message);
                });
        });
注意,我在
Unitplant
Customer
之间存在一对多关系。 以上代码工作良好,但仅限于-更新时-I或仅删除或仅插入
customers

无论何时发生这两种情况,我都会遇到以下错误:

未处理的拒绝SequelizeDatabaseError:只能在LoggedIn状态下发出请求,而不能在SentClientRequest状态下发出请求

在控制台中会发生以下情况:

Executing (783e1de2-5013-43b9-80e9-248dca6d83e1): BEGIN TRANSACTION;
Executing (783e1de2-5013-43b9-80e9-248dca6d83e1): SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
Executing (783e1de2-5013-43b9-80e9-248dca6d83e1): UPDATE [UnitPlants] SET [expiresAt]='2016-06-22',[updatedAt]='2016-06-03 12:57:50.000 +00:00' OUTPUT INSERTED.* WHERE [id] = 15
Executing (783e1de2-5013-43b9-80e9-248dca6d83e1): UPDATE [UnitPlants] SET [ProductTypeId]=1,[updatedAt]='2016-06-03 12:57:50.000 +00:00' OUTPUT INSERTED.* WHERE [id] = 15
Executing (783e1de2-5013-43b9-80e9-248dca6d83e1): SELECT [VehiclePlant].[id], [VehiclePlant].[code], [VehiclePlant].[name], [VehiclePlant].[expiresAt], [VehiclePlant].[createdAt], [VehiclePlant].[upoCustomer], [VehiclePlant].[isExport], [VehiclePlant].[updatedAt], [UnitPlantCustomers].[createdAt] AS [UnitPlantCustomers.createdAt], [UnitPlantCustomers].[updatedAt] AS [UnitPlantCustomers.updatedAt], [UnitPlantCustomers].[UnitPlantId] AS [UnitPlantCustomers.UnitPlantId], [UnitPlantCustomers].[VehiclePlantId] AS [UnitPlantCustomers.VehiclePlantId] FROM [VehiclePlants] AS [VehiclePlant] INNER JOIN [UnitPlantCustomers] AS [UnitPlantCustomers] ON [VehiclePlant].[id] = [UnitPlantCustomers].[VehiclePlantId] AND [UnitPlantCustomers].[UnitPlantId] = 15;
Executing (783e1de2-5013-43b9-80e9-248dca6d83e1): DELETE FROM [UnitPlantCustomers] WHERE [UnitPlantId] = 15 AND [VehiclePlantId] IN (4); SELECT @@ROWCOUNT AS AFFECTEDROWS;
Executing (783e1de2-5013-43b9-80e9-248dca6d83e1): INSERT INTO [UnitPlantCustomers] ([createdAt],[updatedAt],[UnitPlantId],[VehiclePlantId]) VALUES ('2016-06-03 12:57:50.000 +00:00','2016-06-03 12:57:50.000 +00:00',15,3);
Executing (783e1de2-5013-43b9-80e9-248dca6d83e1): ROLLBACK TRANSACTION;
请注意此处的插入和删除

为什么只有当我两者都有的时候才会发生这种情况?我如何解决这个问题

作为旁注,当我不使用事务时,整个事情都会起作用,这让我怀疑我是否选择了错误的隔离级别,或者事务的整个设置都是错误的。

默认情况下,冗长乏味(节点mssql驱动程序)只支持一个并发请求,而其他数据库库则自动管理查询队列。应在sequelize版本3.22中修复


当前的稳定版本是什么?我正在使用的2.0.0v3是当前稳定的版本,4.0正在开发中。这确实做到了,事务正在运行。谢谢