Parallelize SQL queries
This commit is contained in:
parent
86b4da1ec2
commit
c64762858e
178 changed files with 3377 additions and 3618 deletions
36
ts/groups.ts
36
ts/groups.ts
|
@ -19,7 +19,7 @@ import {
|
|||
maybeFetchNewCredentials,
|
||||
} from './services/groupCredentialFetcher';
|
||||
import { storageServiceUploadJob } from './services/storage';
|
||||
import dataInterface from './sql/Client';
|
||||
import { DataReader, DataWriter } from './sql/Client';
|
||||
import { toWebSafeBase64, fromWebSafeBase64 } from './util/webSafeBase64';
|
||||
import { assertDev, strictAssert } from './util/assert';
|
||||
import { isMoreRecentThan } from './util/timestamp';
|
||||
|
@ -263,7 +263,7 @@ const groupFieldsCache = new LRU<string, GroupFields>({
|
|||
max: MAX_CACHED_GROUP_FIELDS,
|
||||
});
|
||||
|
||||
const { updateConversation } = dataInterface;
|
||||
const { updateConversation } = DataWriter;
|
||||
|
||||
if (!isNumber(MAX_MESSAGE_SCHEMA)) {
|
||||
throw new Error(
|
||||
|
@ -1602,9 +1602,7 @@ export async function modifyGroupV2({
|
|||
groupMembersV2: membersV2,
|
||||
});
|
||||
|
||||
await dataInterface.replaceAllEndorsementsForGroup(
|
||||
groupEndorsementData
|
||||
);
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1921,7 +1919,7 @@ export async function createGroupV2(
|
|||
groupMembersV2: membersV2,
|
||||
});
|
||||
|
||||
await dataInterface.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
} catch (error) {
|
||||
if (!(error instanceof HTTPError)) {
|
||||
throw error;
|
||||
|
@ -2023,7 +2021,7 @@ export async function createGroupV2(
|
|||
details: [{ type: 'create' }],
|
||||
},
|
||||
};
|
||||
await dataInterface.saveMessages([createdTheGroupMessage], {
|
||||
await DataWriter.saveMessages([createdTheGroupMessage], {
|
||||
forceSave: true,
|
||||
ourAci,
|
||||
});
|
||||
|
@ -2482,7 +2480,7 @@ export async function initiateMigrationToGroupV2(
|
|||
}
|
||||
|
||||
// Save these most recent updates to conversation
|
||||
updateConversation(conversation.attributes);
|
||||
await updateConversation(conversation.attributes);
|
||||
|
||||
strictAssert(
|
||||
Bytes.isNotEmpty(groupSendEndorsementResponse),
|
||||
|
@ -2496,7 +2494,7 @@ export async function initiateMigrationToGroupV2(
|
|||
groupMembersV2: membersV2,
|
||||
});
|
||||
|
||||
await dataInterface.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
});
|
||||
} catch (error) {
|
||||
const logId = conversation.idForLogging();
|
||||
|
@ -2960,7 +2958,7 @@ export async function respondToGroupV2Migration({
|
|||
}
|
||||
|
||||
// Save these most recent updates to conversation
|
||||
updateConversation(conversation.attributes);
|
||||
await updateConversation(conversation.attributes);
|
||||
|
||||
// Finally, check for any changes to the group since its initial creation using normal
|
||||
// group update codepaths.
|
||||
|
@ -2983,7 +2981,7 @@ export async function respondToGroupV2Migration({
|
|||
groupMembersV2: membersV2,
|
||||
});
|
||||
|
||||
await dataInterface.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3364,7 +3362,7 @@ async function appendChangeMessages(
|
|||
|
||||
const ourAci = window.textsecure.storage.user.getCheckedAci();
|
||||
|
||||
let lastMessage = await dataInterface.getLastConversationMessage({
|
||||
let lastMessage = await DataReader.getLastConversationMessage({
|
||||
conversationId: conversation.id,
|
||||
});
|
||||
|
||||
|
@ -3400,7 +3398,7 @@ async function appendChangeMessages(
|
|||
strictAssert(first !== undefined, 'First message must be there');
|
||||
|
||||
log.info(`appendChangeMessages/${logId}: updating ${first.id}`);
|
||||
await dataInterface.saveMessage(first, {
|
||||
await DataWriter.saveMessage(first, {
|
||||
ourAci,
|
||||
|
||||
// We don't use forceSave here because this is an update of existing
|
||||
|
@ -3410,7 +3408,7 @@ async function appendChangeMessages(
|
|||
log.info(
|
||||
`appendChangeMessages/${logId}: saving ${rest.length} new messages`
|
||||
);
|
||||
await dataInterface.saveMessages(rest, {
|
||||
await DataWriter.saveMessages(rest, {
|
||||
ourAci,
|
||||
forceSave: true,
|
||||
});
|
||||
|
@ -3418,7 +3416,7 @@ async function appendChangeMessages(
|
|||
log.info(
|
||||
`appendChangeMessages/${logId}: saving ${mergedMessages.length} new messages`
|
||||
);
|
||||
await dataInterface.saveMessages(mergedMessages, {
|
||||
await DataWriter.saveMessages(mergedMessages, {
|
||||
ourAci,
|
||||
forceSave: true,
|
||||
});
|
||||
|
@ -3766,7 +3764,7 @@ async function updateGroupViaState({
|
|||
groupMembersV2: membersV2,
|
||||
});
|
||||
|
||||
await dataInterface.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -3890,7 +3888,7 @@ async function updateGroupViaLogs({
|
|||
strictAssert(groupId != null, 'Group must have groupId');
|
||||
|
||||
let cachedEndorsementsExpiration =
|
||||
await dataInterface.getGroupSendCombinedEndorsementExpiration(groupId);
|
||||
await DataReader.getGroupSendCombinedEndorsementExpiration(groupId);
|
||||
|
||||
let response: GroupLogResponseType;
|
||||
let groupSendEndorsementResponse: Uint8Array | null = null;
|
||||
|
@ -3925,7 +3923,7 @@ async function updateGroupViaLogs({
|
|||
'updateGroupViaLogs: Received paginated response, deleting group endorsements'
|
||||
);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await dataInterface.deleteAllEndorsementsForGroup(groupId);
|
||||
await DataWriter.deleteAllEndorsementsForGroup(groupId);
|
||||
cachedEndorsementsExpiration = null; // gets sent as 0 in header
|
||||
}
|
||||
|
||||
|
@ -3971,7 +3969,7 @@ async function updateGroupViaLogs({
|
|||
groupSecretParamsBase64: secretParams,
|
||||
});
|
||||
|
||||
await dataInterface.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
}
|
||||
|
||||
return updates;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue