Add maximum wait in updateGroup, log with queue size in profile service

This commit is contained in:
Scott Nonnenberg 2023-09-25 06:43:54 -07:00 committed by GitHub
parent 1cfc396d65
commit 5c3b866883
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -23,7 +23,7 @@ import dataInterface from './sql/Client';
import { toWebSafeBase64, fromWebSafeBase64 } from './util/webSafeBase64';
import { assertDev, strictAssert } from './util/assert';
import { isMoreRecentThan } from './util/timestamp';
import { MINUTE, DurationInSeconds } from './util/durations';
import { MINUTE, DurationInSeconds, SECOND } from './util/durations';
import { dropNull } from './util/dropNull';
import type {
ConversationAttributesType,
@ -93,6 +93,7 @@ import {
import { ReadStatus } from './messages/MessageReadStatus';
import { SeenStatus } from './MessageSeenStatus';
import { incrementMessageCounter } from './util/incrementMessageCounter';
import { sleep } from './util/sleep';
type AccessRequiredEnum = Proto.AccessControl.AccessRequired;
@ -3135,7 +3136,12 @@ async function updateGroup(
if (changeMessagesToSave.length > 0) {
try {
await profileFetches;
if (contactsWithoutProfileKey && contactsWithoutProfileKey.length > 0) {
await Promise.race([profileFetches, sleep(30 * SECOND)]);
log.info(
`updateGroup/${logId}: timed out or finished fetching ${contactsWithoutProfileKey.length} profiles`
);
}
} catch (error) {
log.error(
`updateGroup/${logId}: failed to fetch missing profiles`,

View file

@ -141,6 +141,12 @@ export class ProfileService {
`ProfileServices.get: Job for ${conversation.idForLogging()} finished ${delta}ms after queue`
);
}
const remainingItems = this.jobQueue.size;
if (remainingItems && remainingItems % 10 === 0) {
log.info(
`ProfileServices.get: ${remainingItems} jobs remaining in the queue`
);
}
}
};