felanios / murlock

MurLock: A distributed locking solution for NestJS, providing a decorator for critical sections with Redis-based synchronization. Ideal for microservices and scalable applications.
https://www.npmjs.com/package/murlock
MIT License
73 stars 3 forks source link

V3.3, node V.20.13.1 - No active store found #46

Closed boardmain closed 5 months ago

boardmain commented 6 months ago

Hi i have the error

Error acquiring lock: AsyncStorageManagerException: No active store found

{
    "error": "No active store found"
}

im using node v 20.13.1 redis is connected

im trying to use it in service example:


@Injectable()
export class StatusService {
    constructor(
        private murLockService: MurLockService,
        private redisService: RedisService
    ) {}

    async performTaskWithLock() {
        const lockKey = 'unique_lock_key';
        const lockTime = 5000; // Duration for which the lock should be held in milliseconds

        try {
            console.log('Acquiring lock');
            await this.murLockService.lock(lockKey, lockTime)
            console.log('Lock acquired successfully');  
            let status = await this.redisService.getStatus();
            status.index++;
            console.log('Setting status: ', status, ' for PID:', process.pid);
            await this.redisService.setStatus(status);
            return status;
        } catch (error) {
            console.log('Error acquiring lock:', error);
            throw error;
        } finally {
            // Make sure to release the lock
            console.log('Releasing lock');
            await this.murLockService.unlock(lockKey);
        }
  }

}

but i have the error when i try to acquire the lock

felanios commented 6 months ago

Hi @boardmain, I'll publish new version the solve this issue but probably It's required breaking changes needs. In two or three days I'll inform you

AhmadWaheedQadri commented 5 months ago

Any Update on this. @felanios. Facing the exact same issue. Murlock version : 3.3.0 Node : 20.10

rob-tt commented 5 months ago

We just had the same issue, @felanios pls update on fix:

Murlock: 3.0.2 Node: 20.10

felanios commented 5 months ago

Hi @rob-tt @boardmain, I released new version to handle this fix, https://github.com/felanios/murlock/pull/55. It includes breaking changes to use because of that you should check the version 4.0.0 readme to new usage. https://www.npmjs.com/package/murlock/v/4.0.0