mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01:00
Increase postgres read timeout and make it configurable
This commit is contained in:
parent
7cb58b946a
commit
c3d30b18e2
3 changed files with 4 additions and 3 deletions
|
@ -87,7 +87,8 @@ addDefaults(config, {
|
|||
user: "",
|
||||
host: "",
|
||||
password: "",
|
||||
port: 5432
|
||||
port: 5432,
|
||||
readTimeout: 250
|
||||
},
|
||||
dumpDatabase: {
|
||||
enabled: false,
|
||||
|
|
|
@ -32,7 +32,6 @@ export class Postgres implements IDatabase {
|
|||
|
||||
private poolRead: Pool;
|
||||
private lastPoolReadFail = 0;
|
||||
private readTimeout = 150;
|
||||
|
||||
private maxTries = 3;
|
||||
|
||||
|
@ -116,7 +115,7 @@ export class Postgres implements IDatabase {
|
|||
|
||||
pendingQueries.push(savePromiseState(lastPool.query({ text: query, values: params })));
|
||||
const currentPromises = [...pendingQueries];
|
||||
if (options.useReplica) currentPromises.push(savePromiseState(timeoutPomise(this.readTimeout)));
|
||||
if (options.useReplica) currentPromises.push(savePromiseState(timeoutPomise(this.config.postgresReadOnly.readTimeout)));
|
||||
const queryResult = await nextFulfilment(currentPromises);
|
||||
|
||||
switch (type) {
|
||||
|
|
|
@ -11,6 +11,7 @@ export interface CustomPostgresConfig extends PoolConfig {
|
|||
|
||||
export interface CustomPostgresReadOnlyConfig extends CustomPostgresConfig {
|
||||
weight: number;
|
||||
readTimeout: number;
|
||||
}
|
||||
|
||||
export interface SBSConfig {
|
||||
|
|
Loading…
Reference in a new issue