Skip to content

MOD-16050 - CF.LOADCHUNK: replicate data chunks (fix silent CF data loss on failover) - #1014

Merged
gabsow merged 1 commit into
masterfrom
tom.gabsow/MOD-16050-cf-loadchunk-replicate
Jun 3, 2026
Merged

gabsow merged 1 commit into
masterfrom
tom.gabsow/MOD-16050-cf-loadchunk-replicate

Conversation

@gabsow

@gabsow gabsow commented Jun 3, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

CF.LOADCHUNK only replicates the header chunk (pos == 1). The subsequent data chunks are applied on the primary but never propagated to replicas / AOF.

A replica of a cuckoo filter that was restored via CF.SCANDUMP/CF.LOADCHUNK therefore ends up with correct metadata (CF.INFO reports the full Number of items inserted) but empty buckets. The divergence is silent — master_link_status:up, equal master_repl_offset/slave_repl_offset, and matching CF.INFO all look healthy — until a failover promotes the replica, at which point every CF.EXISTS misses. A cuckoo filter has no false negatives, so this is real, total data loss for that key.

BFLoadChunk_RedisCommand (Bloom) already replicates its data chunks; CFLoadChunk_RedisCommand (Cuckoo) was missing the call.

Fix

Add RedisModule_ReplicateVerbatim(ctx) to the data-chunk branch of CFLoadChunk_RedisCommand, mirroring the Bloom path.

The RDB / DUMP / RESTORE / full-sync path was already correct (so a full resync heals an affected replica); this closes the incremental replication gap.

Reproduction (stock OSS Redis, primary + replica)

Build one filter via CF.ADD (control) and one via CF.LOADCHUNK on the primary, WAIT 1, then read both on the replica:

  • CF.ADD-built key -> 0 missing.
  • CF.LOADCHUNK-built key -> 100% missing, while replica CF.INFO still reports the full inserted count.

Also reproduced on a 3-node Redis Enterprise cluster (promoted replica serves an empty filter). Verified the fix: with the change, the CF.LOADCHUNK-built key replicates fully.

Test

Adds test_cf_loadchunk_replicates_to_replica (replicated env): builds a multi-sub-filter CF via CF.LOADCHUNK on the primary, WAITs, and asserts every member is present on the replica. Verified the test fails on the unpatched build (2000/2000 missing) and passes with the fix. Full test_cuckoo.py suite green (31/31) with --enable-debug-command.

Jira: MOD-16050


Note

High Risk
Fixes silent total data loss on replica failover for CF.LOADCHUNK-restored keys; change is a one-line replication call aligned with Bloom, but the failure mode was security/data-critical.

Overview
CF.LOADCHUNK now calls RedisModule_ReplicateVerbatim after each successful data chunk load (pos != 1), matching BF.LOADCHUNK and the existing header-chunk path. Without this, replicas could show correct CF.INFO counts but empty buckets after incremental restore, causing total membership loss after failover.

A new master/replica test builds a multi-chunk filter via CF.SCANDUMP / CF.LOADCHUNK, waits for replication, and asserts every member exists on the replica with CF.EXISTS.

Reviewed by Cursor Bugbot for commit a8d0991. Bugbot is set up for automated code reviews on this repo. Configure here.

…oss on failover)

CFLoadChunk_RedisCommand only replicated the header chunk (pos == 1). The
data chunks were applied on the primary but never propagated to replicas /
AOF, so a replica of a CF.LOADCHUNK-restored cuckoo filter ended up with
correct metadata (CF.INFO reports the full item count) but empty buckets.
The divergence was silent - master_link_status:up, equal replication
offsets and matching CF.INFO - until a failover promoted the replica, at
which point every CF.EXISTS missed (a cuckoo filter has no false negatives,
so this is real data loss).

Add RedisModule_ReplicateVerbatim to the data-chunk branch, mirroring
BFLoadChunk_RedisCommand. The RDB/DUMP/RESTORE path was already correct, so
a full resync heals an affected replica; this fix closes the incremental
replication gap. Includes a replication regression test that builds a
filter via CF.LOADCHUNK on the primary and asserts all members are present
on the replica.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@gabsow
gabsow force-pushed the tom.gabsow/MOD-16050-cf-loadchunk-replicate branch from 3da635f to a8d0991 Compare June 3, 2026 08:24
@sonarqubecloud

sonarqubecloud Bot commented Jun 3, 2026

Copy link
Copy Markdown

@gabsow
gabsow merged commit 5dad710 into master Jun 3, 2026
59 checks passed
@gabsow
gabsow deleted the tom.gabsow/MOD-16050-cf-loadchunk-replicate branch June 3, 2026 18:39
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