Skip to content

fix(blocklists): promote blocklist via single atomic RENAME in Redis swap - #223

Open
MaciejTe wants to merge 1 commit into
developfrom
fix/redis-blocklists-rename
Open

fix(blocklists): promote blocklist via single atomic RENAME in Redis swap#223
MaciejTe wants to merge 1 commit into
developfrom
fix/redis-blocklists-rename

Conversation

@MaciejTe

@MaciejTe MaciejTe commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

PR type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other... Please describe:

…swap

Signed-off-by: Maciek <tomczukmaciej@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens Redis-backed blocklist updates by promoting the populated temp set to the live key using a single atomic RENAME, avoiding multi-step swap failure modes that could drop/relocate the live set if the temp key disappears between population and promotion.

Changes:

  • Replace the prior multi-command/pipelined swap (RENAMENX + RENAME + DEL) with a dedicated swapBlocklist helper that performs a single RENAME promotion.
  • Add best-effort cleanup for legacy _old keys left behind by interrupted swaps from the previous implementation.
  • Extend unit tests to cover missing-temp behavior (live preserved), overwriting an existing live set, and cleaning orphaned _old keys.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
blocklists/cache/redis.go Introduces swapBlocklist and updates blocklist promotion to a single atomic RENAME, with legacy _old cleanup.
blocklists/cache/redis_test.go Adds/updates tests to validate atomic promotion semantics and resilience when temp keys are missing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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