fix(blocklists): promote blocklist via single atomic RENAME in Redis swap - #223
Open
MaciejTe wants to merge 1 commit into
Open
fix(blocklists): promote blocklist via single atomic RENAME in Redis swap#223MaciejTe wants to merge 1 commit into
MaciejTe wants to merge 1 commit into
Conversation
…swap Signed-off-by: Maciek <tomczukmaciej@gmail.com>
There was a problem hiding this comment.
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 dedicatedswapBlocklisthelper that performs a singleRENAMEpromotion. - Add best-effort cleanup for legacy
_oldkeys 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
_oldkeys.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR type
What kind of change does this PR introduce?