Skip to content

Commit 76846b7

Browse files
committed
Remove upsert on bucket_state, to avoid unique index failures.
1 parent 8e99e24 commit 76846b7

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

modules/module-mongodb-storage/src/storage/implementation/MongoCompactor.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,11 @@ export class MongoCompactor {
329329
count: 0,
330330
bytes: 0
331331
}
332-
},
333-
$setOnInsert: {
334-
// Only set this if we're creating the document.
335-
// In all other cases, the replication process will have a set a more accurate id.
336-
last_op: this.maxOpId
337332
}
338333
},
339-
// We generally expect this to have been created before, but do handle cases of old unchanged buckets
340-
upsert: true
334+
// We generally expect this to have been created before.
335+
// We don't create new ones here, to avoid issues with the unique index on bucket_updates.
336+
upsert: false
341337
}
342338
});
343339
}
@@ -551,15 +547,11 @@ export class MongoCompactor {
551547
checksum: BigInt(bucketChecksum.checksum),
552548
bytes: null
553549
}
554-
},
555-
$setOnInsert: {
556-
// Only set this if we're creating the document.
557-
// In all other cases, the replication process will have a set a more accurate id.
558-
last_op: this.maxOpId
559550
}
560551
},
561-
// We generally expect this to have been created before, but do handle cases of old unchanged buckets
562-
upsert: true
552+
// We don't create new ones here - it gets tricky to get the last_op right with the unique index on:
553+
// bucket_updates: {'id.g': 1, 'last_op': 1}
554+
upsert: false
563555
}
564556
});
565557
}

0 commit comments

Comments
 (0)