mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-11 22:17:14 +03:00
Add statement timeout for read
This commit is contained in:
@@ -50,7 +50,10 @@ export class Postgres implements IDatabase {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this.config.postgresReadOnly && this.config.postgresReadOnly.enabled) {
|
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) => {
|
this.poolRead.on("error", (err, client) => {
|
||||||
Logger.error(err.stack);
|
Logger.error(err.stack);
|
||||||
this.lastPoolReadFail = Date.now();
|
this.lastPoolReadFail = Date.now();
|
||||||
@@ -119,9 +122,7 @@ export class Postgres implements IDatabase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} 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}`);
|
Logger.error(`prepare (postgres) try ${tries}: ${err}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user