feat: add Redis lock backend - #101
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There are confirmed correctness issues in the new concurrent writer test and Redis wait-loop timer handling that can cause nondeterministic behavior and busy looping, plus an empty-key cleanup issue in the Lua script that can lead to unbounded key buildup.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a Redis-backed implementation for the lock plugin so multiple RoadRunner instances can share exclusive/read locks via the existing RPC API, while keeping in-memory locks as the default when no lock config section is provided.
Changes:
- Introduces a Redis backend using
go-redis/v9plus an embedded Lua script for atomic lock state transitions and TTL handling. - Implements wait/notification behavior using Redis Pub/Sub and client-side timers.
- Expands documentation and adds Redis-focused integration tests; updates CI to run the full
./tests/...module with a Redis service.
File summaries
| File | Description |
|---|---|
redis.go |
Implements Redis backend operations, waiting via Pub/Sub + timers. |
redis.lua |
Atomic Lua script for lock/read/exists/release/ttl/force operations. |
config.go |
Adds lock/Redis configuration structs with mapstructure tags. |
plugin.go |
Selects memory vs Redis backend based on config; wires backend into plugin lifecycle. |
memory.go |
Wraps existing in-memory locker behind the new backend interface (preserves default behavior). |
rpc.go |
Routes RPC methods through the backend interface and propagates backend errors. |
tests/redis_test.go |
Adds Redis integration tests covering exclusivity, readers, waits, expiry, and stop behavior. |
tests/go.mod / tests/go.sum |
Adds go-redis/v9 and required indirect deps for the test module. |
go.mod / go.sum |
Adds go-redis/v9 and required indirect deps for the plugin module. |
.github/workflows/linux.yml |
Adds Redis service and runs go test ./... for the tests module. |
README.md |
Documents backend selection, Redis config, behavior semantics, and how to run tests locally. |
Review details
- Files reviewed: 11/13 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #101 +/- ##
==========================================
+ Coverage 78.82% 83.78% +4.96%
==========================================
Files 4 6 +2
Lines 595 697 +102
==========================================
+ Hits 469 584 +115
+ Misses 126 113 -13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
go-redis/v9, the client used by the RoadRunner Redis plugin.closes: roadrunner-server/roadrunner#2070.