Skip to content

feat: add Redis lock backend - #101

Open
rustatian wants to merge 3 commits into
masterfrom
feature/redis
Open

feat: add Redis lock backend#101
rustatian wants to merge 3 commits into
masterfrom
feature/redis

Conversation

@rustatian

@rustatian rustatian commented Sep 9, 2026

Copy link
Copy Markdown
Member
  • Add shared Redis locks through the existing RPC API, with in-memory locks as the default.
  • Use atomic Lua scripts and Pub/Sub with expiry timers for lock operations and waits.
  • Use go-redis/v9, the client used by the RoadRunner Redis plugin.

closes: roadrunner-server/roadrunner#2070.

Copilot AI lite review requested due to automatic review settings September 9, 2026 19:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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/v9 plus 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.

Comment thread redis.go
Comment thread redis.lua
Comment thread tests/redis_test.go Outdated
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.72727% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.78%. Comparing base (d2614fc) to head (15695bd).

Files with missing lines Patch % Lines
redis.go 96.15% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
@rustatian rustatian self-assigned this Sep 11, 2026
@rustatian rustatian added the enhancement New feature or request label Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[💡 FEATURE REQUEST]: Redis powered lock's

2 participants