diff --git a/src/databases/Postgres.ts b/src/databases/Postgres.ts index 1fa910d..fab0fb1 100644 --- a/src/databases/Postgres.ts +++ b/src/databases/Postgres.ts @@ -138,8 +138,12 @@ export class Postgres implements IDatabase { if (lastPool === this.pool) { // Only applies if it is get or all request options.forceReplica = true; - } else if (lastPool === this.poolRead && maxTries() - tries <= 1) { - options.useReplica = false; + } else if (lastPool === this.poolRead) { + this.lastPoolReadFail = Date.now(); + + if (maxTries() - tries <= 1) { + options.useReplica = false; + } } Logger.error(`prepare (postgres) try ${tries}: ${err}`);