Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redlock release key method #204

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "3.1.3",
"version": "3.1.4",
"packages": [
"packages/*"
],
"npmClient": "npm"
}
}
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-auth",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs auth package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -46,4 +46,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-cache",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs cache package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -49,4 +49,4 @@
"publishConfig": {
"access": "public"
}
}
}
9 changes: 5 additions & 4 deletions packages/cache/src/redlock/redlock.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export class RedlockService {
private readonly metricsService: MetricsService,
) { }

async release(key: string): Promise<void> {
const promise = async (redis: Redis) => await redis.del(key);
async release(type: string, key: string): Promise<void> {
const lockKey = `${type}:${key}`;
const promise = async (redis: Redis) => await redis.del(lockKey);
await Promise.allSettled(this.redisArray.map(promise));
}

Expand Down Expand Up @@ -76,7 +77,7 @@ export class RedlockService {
return lockResult;
}

const releasePromise = async (redis: Redis) => await redis.del(key);
const releasePromise = async (redis: Redis) => await redis.del(lockKey);
await Promise.allSettled(successInstances.map(releasePromise));

await this.sleep(config.retryInterval);
Expand Down Expand Up @@ -127,7 +128,7 @@ export class RedlockService {
clearTimeout(extensionId);
}

this.release(lockKey).catch(error => {
this.release(type, key).catch(error => {
this.logError(`Failed to release lock for resource '${lockKey}': ${error.message}`);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-common",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs common package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/elastic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-elastic",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs elastic package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -37,4 +37,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-http",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs http package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -46,4 +46,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/monitoring/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-monitoring",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs monitoring package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -41,4 +41,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/rabbitmq/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-rabbitmq",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs rabbitmq client package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -43,4 +43,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/redis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-redis",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs redis client package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -40,4 +40,4 @@
"publishConfig": {
"access": "public"
}
}
}
Loading