Skip to content

Commit 415bb31

Browse files
committed
Revert "Add concurrent request limit"
1 parent eb3d733 commit 415bb31

File tree

3 files changed

+2
-36
lines changed

3 files changed

+2
-36
lines changed

src/config.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ addDefaults(config, {
7676
port: 5432,
7777
max: 10,
7878
idleTimeoutMillis: 10000,
79-
maxTries: 3,
80-
maxConcurrentRequests: 3500
79+
maxTries: 3
8180
},
8281
postgresReadOnly: {
8382
enabled: false,
@@ -90,8 +89,7 @@ addDefaults(config, {
9089
max: 10,
9190
idleTimeoutMillis: 10000,
9291
maxTries: 3,
93-
fallbackOnFail: true,
94-
maxConcurrentRequests: 3500
92+
fallbackOnFail: true
9593
},
9694
dumpDatabase: {
9795
enabled: false,

src/databases/Postgres.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ export class Postgres implements IDatabase {
3333
private poolRead: Pool;
3434
private lastPoolReadFail = 0;
3535

36-
private concurrentRequests = 0;
37-
private concurrentReadRequests = 0;
38-
3936
constructor(private config: DatabaseConfig) {}
4037

4138
async init(): Promise<void> {
@@ -102,22 +99,6 @@ export class Postgres implements IDatabase {
10299

103100
Logger.debug(`prepare (postgres): type: ${type}, query: ${query}, params: ${params}`);
104101

105-
if (this.config.readOnly) {
106-
if (this.concurrentReadRequests > this.config.postgresReadOnly?.maxConcurrentRequests) {
107-
Logger.error(`prepare (postgres): cancelling read query because too many concurrent requests, query: ${query}`);
108-
throw new Error("Too many concurrent requests");
109-
}
110-
111-
this.concurrentReadRequests++;
112-
} else {
113-
if (this.concurrentRequests > this.config.postgres.maxConcurrentRequests) {
114-
Logger.error(`prepare (postgres): cancelling query because too many concurrent requests, query: ${query}`);
115-
throw new Error("Too many concurrent requests");
116-
}
117-
118-
this.concurrentRequests++;
119-
}
120-
121102
const pendingQueries: PromiseWithState<QueryResult<any>>[] = [];
122103
let tries = 0;
123104
let lastPool: Pool = null;
@@ -134,12 +115,6 @@ export class Postgres implements IDatabase {
134115
if (options.useReplica && maxTries() - tries > 1) currentPromises.push(savePromiseState(timeoutPomise(this.config.postgresReadOnly.readTimeout)));
135116
const queryResult = await nextFulfilment(currentPromises);
136117

137-
if (this.config.readOnly) {
138-
this.concurrentReadRequests--;
139-
} else {
140-
this.concurrentRequests--;
141-
}
142-
143118
switch (type) {
144119
case "get": {
145120
const value = queryResult.rows[0];
@@ -167,12 +142,6 @@ export class Postgres implements IDatabase {
167142
}
168143
} while (this.isReadQuery(type) && tries < maxTries());
169144

170-
if (this.config.readOnly) {
171-
this.concurrentReadRequests--;
172-
} else {
173-
this.concurrentRequests--;
174-
}
175-
176145
throw new Error(`prepare (postgres): ${type} ${query} failed after ${tries} tries`);
177146
}
178147

src/types/config.model.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ interface RedisReadOnlyConfig extends redis.RedisClientOptions {
1515
export interface CustomPostgresConfig extends PoolConfig {
1616
enabled: boolean;
1717
maxTries: number;
18-
maxConcurrentRequests: number;
1918
}
2019

2120
export interface CustomPostgresReadOnlyConfig extends CustomPostgresConfig {

0 commit comments

Comments
 (0)