Skip to content

fix(locks): fix kv locks#5760

Merged
rossmcewan merged 8 commits intomasterfrom
ross/20260401/fix-kv-locks
Apr 8, 2026
Merged

fix(locks): fix kv locks#5760
rossmcewan merged 8 commits intomasterfrom
ross/20260401/fix-kv-locks

Conversation

@rossmcewan
Copy link
Copy Markdown
Contributor

@rossmcewan rossmcewan commented Apr 1, 2026


Fix KVLocks race conditions with atomic KVStore compare-and-mutate operations

This PR is a significant lock correctness update focused on preventing stale-owner races in KVLocks. The lock implementation in packages/runner/lib/sdk/locks.ts is rewritten to use KVStore directly (instead of Locking), with stable logical lock keys (runner:lock: + hash of logical key), owner value checks, and companion owner-index keys to support safe acquire/refresh/release/release-all behavior.

To support this, the KVStore interface is extended with atomic compare-and-mutate APIs (including companion-key variants), implemented in both packages/kvstore/lib/InMemoryStore.ts and packages/kvstore/lib/RedisStore.ts (Redis via Lua EVAL scripts). Runtime wiring in packages/lambda-runner/lib/index.ts now passes KVStore to KVLocks, and tests were substantially expanded across lock/store unit and integration suites to validate concurrency and race regressions.


This summary was automatically generated by @propel-code-bot

propel-code-bot[bot]

This comment was marked as outdated.

@rossmcewan rossmcewan requested a review from a team April 1, 2026 15:06
propel-code-bot[bot]

This comment was marked as low quality.

Comment thread packages/runner/lib/sdk/locks.ts Outdated
Comment thread packages/runner/lib/sdk/locks.ts Outdated
propel-code-bot[bot]

This comment was marked as low quality.

Comment thread packages/kvstore/lib/RedisStore.ts
Comment thread packages/kvstore/lib/RedisStore.ts Outdated
Comment thread packages/kvstore/lib/InMemoryStore.ts Outdated
Comment thread packages/kvstore/lib/RedisStore.ts Outdated
Comment thread packages/runner/lib/sdk/locks.ts Outdated
Copy link
Copy Markdown
Contributor

@propel-code-bot propel-code-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review found no issues; lock race-condition fixes and atomic KV operations look sound.

Status: No Issues Found | Risk: Low

Review Details

📁 9 files reviewed | 💬 0 comments

Instruction Files
└── .claude/
    ├── agents/
    │   └── nango-docs-migrator.md
    └── skills

Comment thread packages/runner/lib/sdk/locks.ts Outdated
Comment thread packages/kvstore/lib/RedisStore.ts Outdated
Comment thread packages/kvstore/lib/InMemoryStore.ts
Comment thread packages/kvstore/lib/InMemoryStore.ts Outdated
@rossmcewan rossmcewan added this pull request to the merge queue Apr 8, 2026
Merged via the queue into master with commit df24312 Apr 8, 2026
35 checks passed
@rossmcewan rossmcewan deleted the ross/20260401/fix-kv-locks branch April 8, 2026 17:27
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.

2 participants