From 4567c29493a1710bd052bc2b81410aef9a3b38fe Mon Sep 17 00:00:00 2001 From: Ian He Date: Thu, 12 Oct 2023 12:03:24 +1300 Subject: [PATCH 1/5] skip managing connection pool for single endpoint --- .../node-core/src/indexer/connectionPoolState.manager.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/node-core/src/indexer/connectionPoolState.manager.ts b/packages/node-core/src/indexer/connectionPoolState.manager.ts index 087b82fcd5..d1c7657fcb 100644 --- a/packages/node-core/src/indexer/connectionPoolState.manager.ts +++ b/packages/node-core/src/indexer/connectionPoolState.manager.ts @@ -187,6 +187,9 @@ export class ConnectionPoolStateManager { delete this.pool[endpoint]; + if (Object.keys(this.pool).length === 0) { + process.exit(1); + } } //eslint-disable-next-line @typescript-eslint/require-await @@ -198,7 +201,7 @@ export class ConnectionPoolStateManager { - if (this.pool[endpoint].failed || this.pool[endpoint].rateLimited) { + if (Object.keys(this.pool).length === 1 || this.pool[endpoint].failed || this.pool[endpoint].rateLimited) { //if this api was used again then it must be in the same batch of blocks return; } From 910a375122580492b501125a3be838e886a4230e Mon Sep 17 00:00:00 2001 From: Ian He Date: Thu, 12 Oct 2023 12:07:55 +1300 Subject: [PATCH 2/5] code comment --- packages/node-core/src/indexer/connectionPoolState.manager.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/node-core/src/indexer/connectionPoolState.manager.ts b/packages/node-core/src/indexer/connectionPoolState.manager.ts index d1c7657fcb..24b50e0dad 100644 --- a/packages/node-core/src/indexer/connectionPoolState.manager.ts +++ b/packages/node-core/src/indexer/connectionPoolState.manager.ts @@ -91,6 +91,7 @@ export class ConnectionPoolStateManager Date: Thu, 12 Oct 2023 12:14:06 +1300 Subject: [PATCH 3/5] delay() accept seconds --- packages/node-core/src/indexer/connectionPoolState.manager.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/node-core/src/indexer/connectionPoolState.manager.ts b/packages/node-core/src/indexer/connectionPoolState.manager.ts index 24b50e0dad..5855c89b7e 100644 --- a/packages/node-core/src/indexer/connectionPoolState.manager.ts +++ b/packages/node-core/src/indexer/connectionPoolState.manager.ts @@ -3,13 +3,12 @@ import {OnApplicationShutdown} from '@nestjs/common'; import chalk from 'chalk'; -import {toNumber} from 'lodash'; import {ApiErrorType} from '../api.connection.error'; import {IApiConnectionSpecific} from '../api.service'; import {getLogger} from '../logger'; import {errorTypeToScoreAdjustment} from './connectionPool.service'; -const RETRY_DELAY = 60 * 1000; +const RETRY_DELAY = 60; // second const MAX_FAILURES = 5; const RESPONSE_TIME_WEIGHT = 0.7; const FAILURE_WEIGHT = 0.3; From b30fbca4f53cca5263fc1b73e66f2950742963a2 Mon Sep 17 00:00:00 2001 From: Ian He Date: Thu, 12 Oct 2023 12:21:32 +1300 Subject: [PATCH 4/5] * rollback RETRY_DELAY to ms * reduce it to 10 sec * convert it back to sec before passing to delay() --- packages/node-core/src/indexer/connectionPool.service.ts | 2 +- packages/node-core/src/indexer/connectionPoolState.manager.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/node-core/src/indexer/connectionPool.service.ts b/packages/node-core/src/indexer/connectionPool.service.ts index 95f7316f9a..b1203bb32d 100644 --- a/packages/node-core/src/indexer/connectionPool.service.ts +++ b/packages/node-core/src/indexer/connectionPool.service.ts @@ -99,7 +99,7 @@ export class ConnectionPoolService Date: Thu, 12 Oct 2023 12:23:00 +1300 Subject: [PATCH 5/5] * rollback to 60 sec --- packages/node-core/src/indexer/connectionPoolState.manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node-core/src/indexer/connectionPoolState.manager.ts b/packages/node-core/src/indexer/connectionPoolState.manager.ts index 373cd8cb78..976bd933a3 100644 --- a/packages/node-core/src/indexer/connectionPoolState.manager.ts +++ b/packages/node-core/src/indexer/connectionPoolState.manager.ts @@ -8,7 +8,7 @@ import {IApiConnectionSpecific} from '../api.service'; import {getLogger} from '../logger'; import {errorTypeToScoreAdjustment} from './connectionPool.service'; -const RETRY_DELAY = 10 * 1000; +const RETRY_DELAY = 60 * 1000; const MAX_FAILURES = 5; const RESPONSE_TIME_WEIGHT = 0.7; const FAILURE_WEIGHT = 0.3;