mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01:00
Add statement timeout for read
This commit is contained in:
parent
603bad4967
commit
b616ac990b
1 changed files with 5 additions and 4 deletions
|
@ -50,7 +50,10 @@ export class Postgres implements IDatabase {
|
|||
});
|
||||
|
||||
if (this.config.postgresReadOnly && this.config.postgresReadOnly.enabled) {
|
||||
this.poolRead = new Pool(this.config.postgresReadOnly);
|
||||
this.poolRead = new Pool({
|
||||
...this.config.postgresReadOnly,
|
||||
statement_timeout: 120
|
||||
});
|
||||
this.poolRead.on("error", (err, client) => {
|
||||
Logger.error(err.stack);
|
||||
this.lastPoolReadFail = Date.now();
|
||||
|
@ -119,9 +122,7 @@ export class Postgres implements IDatabase {
|
|||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof Error && err.message.includes("terminating connection due to conflict with recovery")) {
|
||||
options.useReplica = false;
|
||||
}
|
||||
options.useReplica = false;
|
||||
|
||||
Logger.error(`prepare (postgres) try ${tries}: ${err}`);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue