不要怂,就是干,撸起袖子干!

Commit 5766526b by Mark Kornblum

Execute promises sequentially rather than parallel

Promise.map allows promises to execute in parallel, which can cause
deadlocks when cascading truncates. Promise.each executes promises
sequentially, which should ensure that we don't have two or more
TRUNCATE operations getting in each others' way.
1 parent 7d5dce9d
Showing with 8 additions and 2 deletions
......@@ -1009,9 +1009,15 @@ Sequelize.prototype.truncate = function(options) {
}
}, { reverse: false });
return Promise.map(models, function(model) {
var truncateModel = function(model) {
return model.truncate(options);
});
};
if (options && options.cascade) {
return Promise.each(models, truncateModel);
} else {
return Promise.map(models, truncateModel);
}
};
/**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!