Finish all renderer SQL queries switching to main
Don't switch to main process until all renderer SQL queries are completed. If we switch while some of them are still running - we can get SQL_BUSY from concurrent writes in main and renderer processes.
This commit is contained in:
parent
eb97c1194a
commit
cf50550936
2 changed files with 10 additions and 2 deletions
|
@ -2094,7 +2094,7 @@ export async function startApp(): Promise<void> {
|
|||
);
|
||||
}
|
||||
|
||||
window.sqlInitializer.goBackToMainProcess();
|
||||
await window.sqlInitializer.goBackToMainProcess();
|
||||
window.Signal.Util.setBatchingStrategy(false);
|
||||
|
||||
const attachmentDownloadQueue = window.attachmentDownloadQueue || [];
|
||||
|
|
|
@ -242,7 +242,15 @@ const dataInterface: ClientInterface = {
|
|||
|
||||
export default dataInterface;
|
||||
|
||||
function goBackToMainProcess() {
|
||||
async function goBackToMainProcess(): Promise<void> {
|
||||
window.log.info('data.goBackToMainProcess: waiting for pending queries');
|
||||
|
||||
// Let pending queries finish before we'll give write access to main process.
|
||||
// We don't want to be writing from two processes at the same time!
|
||||
await waitForPendingQueries();
|
||||
|
||||
window.log.info('data.goBackToMainProcess: switching to main process');
|
||||
|
||||
shouldUseRendererProcess = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue