mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 12:07:07 +03:00
Increase postgres read timeout and make it configurable
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user