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?): MigrationLockManagerParameters
| Parameter | Type |
|---|---|
adapter | FlashcoreAdapter<string, unknown> |
options? | MigrationLockOptions |
Returns
Methods
acquire()
acquire(): Promise<LockAcquisitionResult>Attempt to acquire the migration lock.
Algorithm:
- Check for existing lock
- If locked and not stale, return false
- If stale, try atomic override (CAS if available)
- 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
| Parameter | Type | Description |
|---|---|---|
lockId | string | Lock 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
| Parameter | Type | Description |
|---|---|---|
lockId | string | Lock ID returned from acquire() |
Returns
Promise<boolean>
True if the lock was released
