File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,8 @@ addDefaults(config, {
88
88
readTimeout : 250 ,
89
89
max : 10 ,
90
90
idleTimeoutMillis : 10000 ,
91
- maxTries : 3
91
+ maxTries : 3 ,
92
+ fallbackOnFail : true
92
93
} ,
93
94
dumpDatabase : {
94
95
enabled : false ,
Original file line number Diff line number Diff line change @@ -148,8 +148,10 @@ export class Postgres implements IDatabase {
148
148
149
149
private getPool ( type : string , options : QueryOption ) : Pool {
150
150
const readAvailable = this . poolRead && options . useReplica && this . isReadQuery ( type ) ;
151
- const ignroreReadDueToFailure = this . lastPoolReadFail > Date . now ( ) - 1000 * 30 ;
152
- const readDueToFailure = this . lastPoolFail > Date . now ( ) - 1000 * 30 ;
151
+ const ignroreReadDueToFailure = this . config . postgresReadOnly . fallbackOnFail
152
+ && this . lastPoolReadFail > Date . now ( ) - 1000 * 30 ;
153
+ const readDueToFailure = this . config . postgresReadOnly . fallbackOnFail
154
+ && this . lastPoolFail > Date . now ( ) - 1000 * 30 ;
153
155
if ( readAvailable && ! ignroreReadDueToFailure && ( options . forceReplica || readDueToFailure ||
154
156
Math . random ( ) > 1 / ( this . config . postgresReadOnly . weight + 1 ) ) ) {
155
157
return this . poolRead ;
You can’t perform that action at this time.
0 commit comments