Fix paging queries in the worker system

This commit is contained in:
Fedor Indutny 2024-07-24 13:06:32 -07:00 committed by GitHub
parent 16864e381a
commit c619a7b6fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,6 +19,13 @@ const MIN_TRACE_DURATION = 40;
const WORKER_COUNT = 4;
const PAGING_QUERIES = new Set<keyof ServerReadableDirectInterface>([
'pageMessages',
'finishPageMessages',
'getKnownMessageAttachments',
'finishGetKnownMessageAttachments',
]);
export type InitializeOptions = Readonly<{
appVersion: string;
configDir: string;
@ -216,7 +223,7 @@ export class MainSQL {
// pageMessages runs over several queries and needs to have access to
// the same temporary table.
const isPaging = method === 'pageMessages';
const isPaging = PAGING_QUERIES.has(method);
const entry = isPaging ? this.pool.at(-1) : this.getWorker();
strictAssert(entry != null, 'Must have a pool entry');