You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing an issue where Redlock appears to get stuck when trying to acquire a lock in a Redis cluster environment. This problem does not occur when using a single independent Redis node.
Environment:
Redlock Version: 3.1.2 (also tested with 5.0.0-beta.2)
Redis Version: 7.0.4
ioredis Version: 5.3.2
Redis Setup: Cluster with 6 nodes, created using Docker Compose
Issue Details:
When using a Redis cluster setup, the Redlock implementation gets stuck during the lock acquisition process.
This issue does not occur when using a single standalone Redis node.
I am experiencing an issue where Redlock appears to get stuck when trying to acquire a lock in a Redis cluster environment. This problem does not occur when using a single independent Redis node.
Environment:
Redlock Version: 3.1.2 (also tested with 5.0.0-beta.2)
Redis Version: 7.0.4
ioredis Version: 5.3.2
Redis Setup: Cluster with 6 nodes, created using Docker Compose
Issue Details:
When using a Redis cluster setup, the Redlock implementation gets stuck during the lock acquisition process.
This issue does not occur when using a single standalone Redis node.
Code Snippet for Redis Provider:
`export const redisProvider: Provider = {
provide: 'REDIS_CLIENT',
useFactory: (configService: ConfigService): Redis | Cluster => {
const clusterNodes = configService.get<string[]>('redis.clusterNodes');
},
inject: [ConfigService],
};`
Code Snippet for Redlock Usage:
`@Injectable()
export class OptioRedlockService implements OnModuleInit {
protected readonly logger = new Logger(this.constructor.name);
private redlock: Redlock;
constructor(
@Inject(redisConfig.KEY)
private config: ConfigType,
@InjectRedisClient() private client: Cluster,
) {}
onModuleInit() {
const nodes = this.config.clusterNodes.map((uri) => {
const url = new URL(uri);
return new Client({ port: parseInt(url.port, 10), host: url.hostname });
});
}
async executeWithLock(
key: string,
operation: () => Promise,
delay: number = 0,
lockTtl: number = 60_000,
): Promise {
const lock = await this.acquireLock([
lock:${key}
], lockTtl);}
async acquireLock(
resources: string[],
duration: number,
retries: number = 3,
): Promise {
let attempt = 0;
}
async releaseLock(lock: Lock, key: string) {
let attempts = 0;
const maxAttempts = 3;
let released = false;
}
}
`
Questions:
The text was updated successfully, but these errors were encountered: