LogoRobo.js
Framework

MigrationLockManager

Class: MigrationLockManager

Manager for migration lock acquisition and release.

Uses compare-and-swap (CAS) or setIfNotExists when available for safe concurrent access. Falls back to check-then-set with a small race window for adapters without atomic support.

Constructors

new MigrationLockManager()

new MigrationLockManager(adapter, options?): MigrationLockManager

Parameters

ParameterType
adapterFlashcoreAdapter<string, unknown>
options?MigrationLockOptions

Returns

MigrationLockManager

Methods

acquire()

acquire(): Promise<LockAcquisitionResult>

Attempt to acquire the migration lock.

Algorithm:

  1. Check for existing lock
  2. If locked and not stale, return false
  3. If stale, try atomic override (CAS if available)
  4. If no lock, use setIfNotExists if available, else check-then-set

Returns

Promise<LockAcquisitionResult>

Lock acquisition result with lock ID if successful


extend()

extend(lockId): Promise<boolean>

Extend the lock timeout (heartbeat).

Call periodically during long-running migrations to prevent the lock from appearing stale.

Parameters

ParameterTypeDescription
lockIdstringLock ID to extend

Returns

Promise<boolean>

True if extended successfully


forceRelease()

forceRelease(): Promise<void>

Force release the migration lock regardless of holder.

Use with caution - only for stuck locks or CLI force-unlock.

Returns

Promise<void>


isLocked()

isLocked(): Promise<LockStatus>

Check the current lock status.

Returns

Promise<LockStatus>

Lock status information


release()

release(lockId): Promise<boolean>

Release the migration lock.

Only releases if the lock is held by the given lockId.

Parameters

ParameterTypeDescription
lockIdstringLock ID returned from acquire()

Returns

Promise<boolean>

True if the lock was released

On this page