Reject on dump failure to trigger a retry

This commit is contained in:
Ajay 2023-12-28 18:23:41 -05:00
parent 134e89af00
commit 211ecf700b

View file

@ -234,11 +234,11 @@ async function queueDump(): Promise<void> {
const fileName = `${table.name}_${startTime}.csv`; const fileName = `${table.name}_${startTime}.csv`;
const file = `${appExportPath}/${fileName}`; const file = `${appExportPath}/${fileName}`;
await new Promise<string>((resolve) => { await new Promise<string>((resolve, reject) => {
exec(`psql -c "\\copy (SELECT * FROM \\"${table.name}\\"${table.order ? ` ORDER BY \\"${table.order}\\"` : ``})` exec(`psql -c "\\copy (SELECT * FROM \\"${table.name}\\"${table.order ? ` ORDER BY \\"${table.order}\\"` : ``})`
+ ` TO '${file}' WITH (FORMAT CSV, HEADER true);"`, credentials, (error, stdout, stderr) => { + ` TO '${file}' WITH (FORMAT CSV, HEADER true);"`, credentials, (error, stdout, stderr) => {
if (error) { if (error) {
Logger.error(`[dumpDatabase] Failed to dump ${table.name} to ${file} due to ${stderr}`); reject(`[dumpDatabase] Failed to dump ${table.name} to ${file} due to ${stderr}`);
} }
resolve(error ? stderr : stdout); resolve(error ? stderr : stdout);
@ -253,10 +253,10 @@ async function queueDump(): Promise<void> {
latestDumpFiles = [...dumpFiles]; latestDumpFiles = [...dumpFiles];
lastUpdate = startTime; lastUpdate = startTime;
updateQueued = false;
} catch(e) { } catch(e) {
Logger.error(e as string); Logger.error(e as string);
} finally { } finally {
updateQueued = false;
updateRunning = false; updateRunning = false;
} }
} }