Skip to content

Commit ee56a8d

Browse files
committed
Last pool fail when timeout
1 parent 94eb37c commit ee56a8d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/databases/Postgres.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,12 @@ export class Postgres implements IDatabase {
138138
if (lastPool === this.pool) {
139139
// Only applies if it is get or all request
140140
options.forceReplica = true;
141-
} else if (lastPool === this.poolRead && maxTries() - tries <= 1) {
142-
options.useReplica = false;
141+
} else if (lastPool === this.poolRead) {
142+
this.lastPoolReadFail = Date.now();
143+
144+
if (maxTries() - tries <= 1) {
145+
options.useReplica = false;
146+
}
143147
}
144148

145149
Logger.error(`prepare (postgres) try ${tries}: ${err}`);

0 commit comments

Comments
 (0)