mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-09 13:07:02 +03:00
Stop postgres retries when over a threshold
This commit is contained in:
@@ -89,7 +89,8 @@ addDefaults(config, {
|
|||||||
max: 10,
|
max: 10,
|
||||||
idleTimeoutMillis: 10000,
|
idleTimeoutMillis: 10000,
|
||||||
maxTries: 3,
|
maxTries: 3,
|
||||||
fallbackOnFail: true
|
fallbackOnFail: true,
|
||||||
|
stopRetryThreshold: 800
|
||||||
},
|
},
|
||||||
dumpDatabase: {
|
dumpDatabase: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|||||||
@@ -148,7 +148,8 @@ export class Postgres implements IDatabase {
|
|||||||
|
|
||||||
Logger.error(`prepare (postgres) try ${tries}: ${err}`);
|
Logger.error(`prepare (postgres) try ${tries}: ${err}`);
|
||||||
}
|
}
|
||||||
} while (this.isReadQuery(type) && tries < maxTries());
|
} while (this.isReadQuery(type) && tries < maxTries()
|
||||||
|
&& this.activePostgresRequests < this.config.postgresReadOnly.stopRetryThreshold);
|
||||||
|
|
||||||
this.activePostgresRequests--;
|
this.activePostgresRequests--;
|
||||||
throw new Error(`prepare (postgres): ${type} ${query} failed after ${tries} tries`);
|
throw new Error(`prepare (postgres): ${type} ${query} failed after ${tries} tries`);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export interface CustomPostgresReadOnlyConfig extends CustomPostgresConfig {
|
|||||||
weight: number;
|
weight: number;
|
||||||
readTimeout: number;
|
readTimeout: number;
|
||||||
fallbackOnFail: boolean;
|
fallbackOnFail: boolean;
|
||||||
|
stopRetryThreshold: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SBSConfig {
|
export interface SBSConfig {
|
||||||
|
|||||||
Reference in New Issue
Block a user