Skip to content

Fix CLUSTERSCAN fingerprint to use configurable_hash_seed#3679

Merged
lucasyonge merged 1 commit into
valkey-io:unstablefrom
enjoy-binbin:fix_fp
May 12, 2026
Merged

Fix CLUSTERSCAN fingerprint to use configurable_hash_seed#3679
lucasyonge merged 1 commit into
valkey-io:unstablefrom
enjoy-binbin:fix_fp

Conversation

@enjoy-binbin

@enjoy-binbin enjoy-binbin commented May 12, 2026

Copy link
Copy Markdown
Member

This bug was introduced in #3366.

Before PR #3366, hash-seed config was applied directly via
hashtableSetHashFunctionSeed(), so clusterscanFingerprint() correctly
used hash_function_seed to derive the fingerprint.

if (server.hash_seed != NULL) {
    memset(hashseed, 0, sizeof(hashseed));
    getHashSeedFromString(hashseed, sizeof(hashseed), server.hash_seed);
    hashtableSetHashFunctionSeed(hashseed);
}

PR #3366 introduced a separate configurable_hash_seed for data
hashtables and kept hash_function_seed as a random per-process value.

/* Set the configured hash seed used by data hashtables (keys, sets, zsets,
 * hashes) or use the random seed if not configured. */
if (server.hash_seed) {
    uint8_t seed[16] = {0};
    getHashSeedFromString(seed, sizeof(seed), server.hash_seed);
    setConfigurableHashSeed(seed);
} else {
    setConfigurableHashSeed(hashtableGetHashFunctionSeed());
}

However, clusterscanFingerprint() was not updated accordingly — it
still reads hash_function_seed, which is now random on every node.
This makes fingerprints differ across nodes even when they share the
same hash-seed config, causing cursors to restart on failover.

CLUSTERSCAN was introduced in #2934.

This bug was introduced in valkey-io#3366.

Before PR valkey-io#3366, hash-seed config was applied directly via
hashtableSetHashFunctionSeed(), so clusterscanFingerprint() correctly
used hash_function_seed to derive the fingerprint.

PR valkey-io#3366 introduced a separate configurable_hash_seed for data
hashtables and kept hash_function_seed as a random per-process value.
However, clusterscanFingerprint() was not updated accordingly — it
still reads hash_function_seed, which is now random on every node.
This makes fingerprints differ across nodes even when they share the
same hash-seed config, causing cursors to restart on failover.

Signed-off-by: Binbin <binloveplay1314@qq.com>
@codecov

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.73%. Comparing base (ca9dee3) to head (57475f0).
⚠️ Report is 1 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #3679      +/-   ##
============================================
+ Coverage     76.71%   76.73%   +0.02%     
============================================
  Files           162      162              
  Lines         80656    80656              
============================================
+ Hits          61872    61892      +20     
+ Misses        18784    18764      -20     
Files with missing lines Coverage Δ
src/cluster.c 92.30% <100.00%> (ø)
src/server.c 89.47% <100.00%> (+<0.01%) ⬆️
src/server.h 100.00% <ø> (ø)

... and 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zuiderkwast zuiderkwast 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.

Good catch!

We should have had this test case from before. It would have caught the bug.

@zuiderkwast zuiderkwast moved this from To be backported to Needs Review in Valkey 9.1 May 12, 2026

@sarthakaggarwal97 sarthakaggarwal97 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.

Nice find! Looks good to me! Thank you!

Comment thread tests/unit/cluster/clusterscan.tcl
@lucasyonge lucasyonge merged commit d4337d6 into valkey-io:unstable May 12, 2026
62 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Review to To be backported in Valkey 9.1 May 12, 2026
@enjoy-binbin enjoy-binbin deleted the fix_fp branch May 13, 2026 02:32
@enjoy-binbin enjoy-binbin added the release-notes This issue should get a line item in the release notes label May 13, 2026
@zuiderkwast zuiderkwast removed this from Valkey 9.1 May 14, 2026
@zuiderkwast zuiderkwast moved this to Merged in Valkey 10 May 14, 2026
@zuiderkwast

Copy link
Copy Markdown
Contributor

#3366 is not included in 9.1, so also this PR should not be included in 9.1. I changed it to 10.0.

@enjoy-binbin enjoy-binbin removed the release-notes This issue should get a line item in the release notes label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

4 participants