Increase postgres read timeout and make it configurable

This commit is contained in:
Ajay 2022-08-15 17:32:07 -04:00
parent 7cb58b946a
commit c3d30b18e2
3 changed files with 4 additions and 3 deletions

View file

@ -87,7 +87,8 @@ addDefaults(config, {
user: "",
host: "",
password: "",
port: 5432
port: 5432,
readTimeout: 250
},
dumpDatabase: {
enabled: false,

View file

@ -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) {

View file

@ -11,6 +11,7 @@ export interface CustomPostgresConfig extends PoolConfig {
export interface CustomPostgresReadOnlyConfig extends CustomPostgresConfig {
weight: number;
readTimeout: number;
}
export interface SBSConfig {