Improve termination condition
This commit is contained in:
parent
5b1a0c45df
commit
38ac9972e8
1 changed files with 3 additions and 2 deletions
|
@ -192,11 +192,12 @@ const _processBatch = async ({ connection, upgradeMessageSchema } = {}) => {
|
|||
const lastProcessedIndex =
|
||||
await settings.getAttachmentMigrationLastProcessedIndex(connection);
|
||||
|
||||
const count = NUM_MESSAGES_PER_BATCH;
|
||||
const fetchUnprocessedMessagesStartTime = Date.now();
|
||||
const unprocessedMessages =
|
||||
await _dangerouslyFetchMessagesRequiringSchemaUpgradeWithoutIndex({
|
||||
connection,
|
||||
count: NUM_MESSAGES_PER_BATCH,
|
||||
count,
|
||||
lastIndex: lastProcessedIndex,
|
||||
});
|
||||
const fetchDuration = Date.now() - fetchUnprocessedMessagesStartTime;
|
||||
|
@ -214,7 +215,7 @@ const _processBatch = async ({ connection, upgradeMessageSchema } = {}) => {
|
|||
const saveDuration = Date.now() - saveMessagesStartTime;
|
||||
|
||||
const numMessagesProcessed = upgradedMessages.length;
|
||||
const done = numMessagesProcessed === 0;
|
||||
const done = numMessagesProcessed < count;
|
||||
const lastMessage = last(upgradedMessages);
|
||||
const newLastProcessedIndex = lastMessage ? lastMessage.id : null;
|
||||
if (!done) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue