Skip to content

feat(lock): add distributed lock primitive#118

Merged
slow2342 merged 1 commit into
mainfrom
feat/distributed-lock
Jun 12, 2026
Merged

feat(lock): add distributed lock primitive#118
slow2342 merged 1 commit into
mainfrom
feat/distributed-lock

Conversation

@slow2342

Copy link
Copy Markdown
Owner

Summary

  • Implement distributed lock primitive with lease association and automatic release
  • Add AetherLock gRPC service with Lock, Unlock, LockQuery RPCs
  • Lock state is persisted in KV store and restored on startup/snapshot

Changes

  • proto/lock.proto — Lock service definition with request/response messages
  • src/lock/mod.rsLockManager with reverse indexes for O(1) lookup by key and lease
  • src/api/lock.rsAetherLock gRPC service implementation
  • src/raft/mod.rsLockAcquire/LockRelease Raft request/response types
  • src/raft/state_machine.rs — Lock handling in state machine apply path, snapshot restore, and lease revoke

Testing

  • Unit tests for LockManager (acquire, release, lease association, snapshot restore)
  • Integration tests for lease revoke releasing associated locks
  • 118 tests passed, clippy clean

How to verify

cargo build
cargo test --lib
cargo clippy -- -D warnings

Refs #89

@slow2342
slow2342 force-pushed the feat/distributed-lock branch from fc756c6 to 10b4815 Compare June 12, 2026 10:29
Implement distributed lock with lease association, snapshot persistence,
and automatic release on lease expiry/revoke.

- Add LockManager with reverse indexes for O(1) lookup by key and lease
- Add AetherLock gRPC service (Lock, Unlock, LockQuery)
- Persist lock state with lease_id in KV store value
- Restore lock state on startup and snapshot restore
- Release associated locks when lease is revoked
- Validate lock name (length, null bytes, reserved prefix)
@slow2342
slow2342 force-pushed the feat/distributed-lock branch from 10b4815 to ec833a1 Compare June 12, 2026 10:37
@slow2342
slow2342 merged commit 326ab0e into main Jun 12, 2026
6 of 8 checks passed
@slow2342
slow2342 deleted the feat/distributed-lock branch June 13, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant