mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 20:17:02 +03:00
Increase postgres read timeout and make it configurable
This commit is contained in:
@@ -87,7 +87,8 @@ addDefaults(config, {
|
|||||||
user: "",
|
user: "",
|
||||||
host: "",
|
host: "",
|
||||||
password: "",
|
password: "",
|
||||||
port: 5432
|
port: 5432,
|
||||||
|
readTimeout: 250
|
||||||
},
|
},
|
||||||
dumpDatabase: {
|
dumpDatabase: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export class Postgres implements IDatabase {
|
|||||||
|
|
||||||
private poolRead: Pool;
|
private poolRead: Pool;
|
||||||
private lastPoolReadFail = 0;
|
private lastPoolReadFail = 0;
|
||||||
private readTimeout = 150;
|
|
||||||
|
|
||||||
private maxTries = 3;
|
private maxTries = 3;
|
||||||
|
|
||||||
@@ -116,7 +115,7 @@ export class Postgres implements IDatabase {
|
|||||||
|
|
||||||
pendingQueries.push(savePromiseState(lastPool.query({ text: query, values: params })));
|
pendingQueries.push(savePromiseState(lastPool.query({ text: query, values: params })));
|
||||||
const currentPromises = [...pendingQueries];
|
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);
|
const queryResult = await nextFulfilment(currentPromises);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface CustomPostgresConfig extends PoolConfig {
|
|||||||
|
|
||||||
export interface CustomPostgresReadOnlyConfig extends CustomPostgresConfig {
|
export interface CustomPostgresReadOnlyConfig extends CustomPostgresConfig {
|
||||||
weight: number;
|
weight: number;
|
||||||
|
readTimeout: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SBSConfig {
|
export interface SBSConfig {
|
||||||
|
|||||||
Reference in New Issue
Block a user