Skip to content

Commit 8f3ae3d

Browse files
Simon Stoneachrinza
Simon Stone
authored andcommitted
fix(*): run autoupdate in serial to avoid conflicts
Signed-off-by: Simon Stone <[email protected]>
1 parent 06b7239 commit 8f3ae3d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/mongodb.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,8 @@ MongoDB.prototype.autoupdate = function(models, cb) {
18701870

18711871
const enableGeoIndexing = this.settings.enableGeoIndexing === true;
18721872

1873-
async.each(
1873+
// Make it serial as multiple models might map to the same collection
1874+
async.eachSeries(
18741875
models,
18751876
function(modelName, modelCallback) {
18761877
const indexes = self._models[modelName].settings.indexes || [];
@@ -1954,7 +1955,8 @@ MongoDB.prototype.autoupdate = function(models, cb) {
19541955
debug('create indexes: ', indexList);
19551956
}
19561957

1957-
async.each(
1958+
// Make it serial as multiple indexes may try to create the same collection at once
1959+
async.eachSeries(
19581960
indexList,
19591961
function(index, indexCallback) {
19601962
if (self.debug) {

0 commit comments

Comments
 (0)