Better reporting for DB corruption errors
This commit is contained in:
parent
092c2fd0d7
commit
1b1ed2cd05
|
@ -80,7 +80,7 @@
|
||||||
"array-move": "2.1.0",
|
"array-move": "2.1.0",
|
||||||
"axe-core": "4.1.4",
|
"axe-core": "4.1.4",
|
||||||
"backbone": "1.4.0",
|
"backbone": "1.4.0",
|
||||||
"better-sqlite3": "https://github.com/signalapp/better-sqlite3#2fa02d2484e9f9a10df5ac7ea4617fb2dff30006",
|
"better-sqlite3": "https://github.com/signalapp/better-sqlite3#32828e03be0489572ab334239c5768c86697989f",
|
||||||
"bezier-easing": "2.1.0",
|
"bezier-easing": "2.1.0",
|
||||||
"blob-util": "2.0.2",
|
"blob-util": "2.0.2",
|
||||||
"blueimp-load-image": "5.14.0",
|
"blueimp-load-image": "5.14.0",
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
diff --git a/node_modules/@types/better-sqlite3/index.d.ts b/node_modules/@types/better-sqlite3/index.d.ts
|
||||||
|
index d6e4309..5948fd0 100755
|
||||||
|
--- a/node_modules/@types/better-sqlite3/index.d.ts
|
||||||
|
+++ b/node_modules/@types/better-sqlite3/index.d.ts
|
||||||
|
@@ -84,6 +84,7 @@ declare namespace BetterSqlite3 {
|
||||||
|
prototype: Database;
|
||||||
|
|
||||||
|
SqliteError: typeof SqliteError;
|
||||||
|
+ setCorruptionLogger(fn: (message: string) => void): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -573,7 +573,10 @@ function makeChannel(fnName: string) {
|
||||||
'Detected sql corruption in renderer process. ' +
|
'Detected sql corruption in renderer process. ' +
|
||||||
`Restarting the application immediately. Error: ${error.message}`
|
`Restarting the application immediately. Error: ${error.message}`
|
||||||
);
|
);
|
||||||
ipc?.send('database-error', error.stack);
|
ipc?.send(
|
||||||
|
'database-error',
|
||||||
|
`${error.stack}\n${Server.getCorruptionLog()}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
log.error(
|
log.error(
|
||||||
`Renderer SQL channel job (${fnName}) error ${error.message}`
|
`Renderer SQL channel job (${fnName}) error ${error.message}`
|
||||||
|
|
|
@ -550,6 +550,8 @@ export type ServerInterface = DataInterface & {
|
||||||
|
|
||||||
// Server-only
|
// Server-only
|
||||||
|
|
||||||
|
getCorruptionLog: () => string;
|
||||||
|
|
||||||
initialize: (options: {
|
initialize: (options: {
|
||||||
configDir: string;
|
configDir: string;
|
||||||
key: string;
|
key: string;
|
||||||
|
|
|
@ -276,6 +276,7 @@ const dataInterface: ServerInterface = {
|
||||||
|
|
||||||
// Server-only
|
// Server-only
|
||||||
|
|
||||||
|
getCorruptionLog,
|
||||||
initialize,
|
initialize,
|
||||||
initializeRenderer,
|
initializeRenderer,
|
||||||
|
|
||||||
|
@ -2695,6 +2696,19 @@ let globalInstanceRenderer: Database | undefined;
|
||||||
let databaseFilePath: string | undefined;
|
let databaseFilePath: string | undefined;
|
||||||
let indexedDBPath: string | undefined;
|
let indexedDBPath: string | undefined;
|
||||||
|
|
||||||
|
let corruptionLog = new Array<string>();
|
||||||
|
|
||||||
|
SQL.setCorruptionLogger(line => {
|
||||||
|
logger.error(`SQL corruption: ${line}`);
|
||||||
|
corruptionLog.push(line);
|
||||||
|
});
|
||||||
|
|
||||||
|
function getCorruptionLog(): string {
|
||||||
|
const result = corruptionLog.join('\n');
|
||||||
|
corruptionLog = [];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
async function initialize({
|
async function initialize({
|
||||||
configDir,
|
configDir,
|
||||||
key,
|
key,
|
||||||
|
|
|
@ -19,10 +19,17 @@ const port = parentPort;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function respond(seq: number, error: Error | undefined, response?: any) {
|
function respond(seq: number, error: Error | undefined, response?: any) {
|
||||||
|
const corruptionLog = db.getCorruptionLog();
|
||||||
|
|
||||||
|
const errorMessage = [
|
||||||
|
...(error ? [error.stack] : []),
|
||||||
|
...(corruptionLog ? [corruptionLog] : []),
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
const wrappedResponse: WrappedWorkerResponse = {
|
const wrappedResponse: WrappedWorkerResponse = {
|
||||||
type: 'response',
|
type: 'response',
|
||||||
seq,
|
seq,
|
||||||
error: error ? error.stack : undefined,
|
error: errorMessage,
|
||||||
response,
|
response,
|
||||||
};
|
};
|
||||||
port.postMessage(wrappedResponse);
|
port.postMessage(wrappedResponse);
|
||||||
|
|
|
@ -4794,9 +4794,9 @@ bcrypt-pbkdf@^1.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
tweetnacl "^0.14.3"
|
tweetnacl "^0.14.3"
|
||||||
|
|
||||||
"better-sqlite3@https://github.com/signalapp/better-sqlite3#2fa02d2484e9f9a10df5ac7ea4617fb2dff30006":
|
"better-sqlite3@https://github.com/signalapp/better-sqlite3#32828e03be0489572ab334239c5768c86697989f":
|
||||||
version "7.1.4"
|
version "7.1.4"
|
||||||
resolved "https://github.com/signalapp/better-sqlite3#2fa02d2484e9f9a10df5ac7ea4617fb2dff30006"
|
resolved "https://github.com/signalapp/better-sqlite3#32828e03be0489572ab334239c5768c86697989f"
|
||||||
dependencies:
|
dependencies:
|
||||||
bindings "^1.5.0"
|
bindings "^1.5.0"
|
||||||
tar "^6.1.0"
|
tar "^6.1.0"
|
||||||
|
|
Loading…
Reference in New Issue