From ac703f2170595e856e973d4db484ec2e4c5eb6a7 Mon Sep 17 00:00:00 2001 From: Jonathan Fallon Date: Mon, 8 Nov 2021 11:58:37 +0100 Subject: [PATCH 1/2] pass maxRetriesPerRequest and enableReadyCheck to default config --- api/ilos/connection-redis/src/RedisConnection.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api/ilos/connection-redis/src/RedisConnection.ts b/api/ilos/connection-redis/src/RedisConnection.ts index a66654ab7d..564eda9fd8 100644 --- a/api/ilos/connection-redis/src/RedisConnection.ts +++ b/api/ilos/connection-redis/src/RedisConnection.ts @@ -32,16 +32,22 @@ export class RedisConnection implements ConnectionInterface { } protected buildClient(): RedisInterface { + const defaultConfig = { + maxRetriesPerRequest: null, + enableReadyCheck: false, + // lazyConnect: true, + }; + if (this.config.connectionString) { const { connectionString, ...other } = this.config; return new Redis(connectionString, { + ...defaultConfig, ...other, - // lazyConnect: true, }); } return new Redis({ + ...defaultConfig, ...this.config, - // lazyConnect: true, }); } } From af36512526891c84b073ef120679b57a760a9335 Mon Sep 17 00:00:00 2001 From: Jonathan Fallon Date: Mon, 8 Nov 2021 12:41:15 +0100 Subject: [PATCH 2/2] stop sharing redis connections between queues --- api/ilos/connection-redis/src/RedisConnection.ts | 2 +- api/ilos/transport-redis/src/QueueTransport.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/ilos/connection-redis/src/RedisConnection.ts b/api/ilos/connection-redis/src/RedisConnection.ts index 564eda9fd8..b22af81db8 100644 --- a/api/ilos/connection-redis/src/RedisConnection.ts +++ b/api/ilos/connection-redis/src/RedisConnection.ts @@ -19,7 +19,7 @@ export class RedisConnection implements ConnectionInterface { async down() { if (this.connected) { - await this.getClient().disconnect(); + this.getClient().disconnect(); this.connected = false; } } diff --git a/api/ilos/transport-redis/src/QueueTransport.ts b/api/ilos/transport-redis/src/QueueTransport.ts index 018d1dd22e..cbf689a2ba 100644 --- a/api/ilos/transport-redis/src/QueueTransport.ts +++ b/api/ilos/transport-redis/src/QueueTransport.ts @@ -18,7 +18,7 @@ interface WorkerWithScheduler { export class QueueTransport implements TransportInterface { queues: WorkerWithScheduler[] = []; kernel: KernelInterface; - connection: RedisConnection; + connections: RedisConnection[] = []; constructor(kernel: KernelInterface) { this.kernel = kernel; @@ -33,11 +33,10 @@ export class QueueTransport implements TransportInterface } protected async getRedisConnection(connectionString: string): Promise { - if (!this.connection) { - this.connection = new RedisConnection({ connectionString }); - await this.connection.up(); - } - return this.connection.getClient(); + const connection = new RedisConnection({ connectionString }); + await connection.up(); + this.connections.push(connection); + return connection.getClient(); } protected getWorker(connection: RedisInterface, name: string, processor: Processor): Worker { @@ -100,7 +99,8 @@ export class QueueTransport implements TransportInterface promises.push(scheduler.close()); } await Promise.all(promises); - await this.connection.down(); + await Promise.all(this.connections.map((c: RedisConnection) => c.down())); + this.connections = []; } protected errorHandler(_error: Error, _job?: Job) {