Release RedLock from different server

35 Views Asked by At

Assume two server resources (A and B) processing a process with two steps. Client submits transaction request for RESOURCE_1 to A. Server A handles the first step Then via a job queue, B starts processing. I need to lock RESOURCE_1 at Server A and release lock from Server B.

  1. Can RedLock accommodate this requirement?
  2. If yes, how to release lock from Server B? Assume the lock key is known.

Current implementation is,

// server A
const lock = await redlock.lock(`LOCK:TX:RESOURCE_1 `, 999999);
await doLotOfStuff();
lock.unlock();

My expectation is,

// server A
const lock = await redlock.lock(`LOCK:TX:RESOURCE_1 `, 999999);
await doLotOfStuff();
await addToJobQueue(txRequest);

// server B
await doMoreStuff();
const lock = await redlock.find(`LOCK:TX:RESOURCE_1 `);
lock.unlock();
0

There are 0 best solutions below