Skip to content

Skip expired hash fields when loading non-preamble RDB on primary - #3091

Merged
ranshid merged 35 commits into
valkey-io:unstablefrom
hanxizh9910:fix/rdb-skip-expired-fields
Feb 24, 2026
Merged

ranshid merged 35 commits into
valkey-io:unstablefrom
hanxizh9910:fix/rdb-skip-expired-fields

Conversation

@hanxizh9910

Copy link
Copy Markdown
Contributor

Summary

Fixes #2620

Skip loading expired hash fields when a non-preamble RDB is being loaded on a primary server. Propagate HDEL to replicas when expired fields are skipped.

Changes

  • Updated rdbLoadObject signature to accept rdbflags and now parameters
  • Added logic to skip expired hash fields during RDB load on primary
  • Propagate HDEL to replicas when RDBFLAGS_FEED_REPL is set
  • Updated all callers of rdbLoadObject
  • Added unit test

…eing loaded on primary

Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
… fields

Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
@hanxizh9910
hanxizh9910 marked this pull request as draft January 21, 2026 22:13
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
@hanxizh9910
hanxizh9910 marked this pull request as ready for review January 21, 2026 22:48
Comment thread src/valkey-check-rdb.c Resolved
Comment thread tests/unit/hashexpire.tcl Resolved
Comment thread tests/unit/hashexpire.tcl Resolved
Comment thread tests/unit/hashexpire.tcl Resolved
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
@codecov

codecov Bot commented Jan 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (c1b4129) to head (cd68973).
⚠️ Report is 84 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable   #3091       +/-   ##
============================================
- Coverage     74.32%       0   -74.33%     
============================================
  Files           129       0      -129     
  Lines         71011       0    -71011     
============================================
- Hits          52778       0    -52778     
+ Misses        18233       0    -18233     

see 129 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.

Comment thread src/cluster.c Resolved
Comment thread src/rdb.c Resolved
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
…mary RDB reload

Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Comment thread src/rdb.c Resolved
Comment thread tests/unit/hashexpire.tcl Resolved
Comment thread tests/unit/hashexpire.tcl Resolved
Comment thread tests/unit/hashexpire.tcl Resolved
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
@hanxizh9910
hanxizh9910 force-pushed the fix/rdb-skip-expired-fields branch from edba8e1 to f631499 Compare January 28, 2026 00:11
@madolson

madolson commented Feb 9, 2026

Copy link
Copy Markdown
Member

You means rdb_last_load_all_fields_expired? I don't see it was added in the INFO fileds or top comment.

I still would rather not add an info field which is a static value the entire lifetime of the application. There is a log you can go check to see what the values of the RDB load were.

Comment thread src/rdb.c Resolved
@ranshid

ranshid commented Feb 9, 2026

Copy link
Copy Markdown
Member

@valkey-io/core-team points to discuss:

  1. in this PR we also propose (not implemented yet) adding rdb_last_load_all_fields_expired metrioc to report all the hash keys which were "skipped" because all their firlds were expired. The reason is to be more consistent with rdb_last_load_keys_expired which helps the user better "understanding" why some of the keys were NOT loaded from the rdb image.
  2. Shoulf we also track and report the "rdb_last_load_fields_expired` statistic? which means we should also count and report the number of expilicit fields expired (even in case the hash object was not skipped)>
  3. We could also just use the same statistics we have today to track expired_fields. This would not help understand "WHY some HASH objects were NOT loaded"

Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
@sarthakaggarwal97

Copy link
Copy Markdown
Contributor

@ranshid did we finalize on the decision for this PR? (I dropped off when we were discussing in the core meeting)

@ranshid

ranshid commented Feb 12, 2026

Copy link
Copy Markdown
Member

@ranshid did we finalize on the decision for this PR? (I dropped off when we were discussing in the core meeting)

Yes. sorry for the delay.
We decided to include the new stats but only in the log message (as you did) before the last commit.

@ranshid ranshid added major-decision-approved Major decision approved by TSC team and removed major-decision-pending Major decision pending by TSC team labels Feb 12, 2026
@hanxizh9910

Copy link
Copy Markdown
Contributor Author

@ranshid did we finalize on the decision for this PR? (I dropped off when we were discussing in the core meeting)

Yes. sorry for the delay. We decided to include the new stats but only in the log message (as you did) before the last commit.

Ok! Thank you for the update!

Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Comment thread src/server.h Resolved
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Comment thread src/server.h Resolved
Comment thread src/server.c Resolved
Comment thread src/rdb.c Resolved
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>

@ranshid ranshid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment thread src/rdb.c Resolved
Comment thread src/rdb.c Resolved
Comment thread src/rdb.c Resolved
Comment thread tests/unit/hashexpire.tcl Resolved
hanxizh9910 and others added 4 commits February 23, 2026 22:56
Co-authored-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Co-authored-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Co-authored-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Co-authored-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
@zuiderkwast zuiderkwast moved this to Needs Review in Valkey 9.1 Feb 24, 2026
@ranshid
ranshid merged commit 501b315 into valkey-io:unstable Feb 24, 2026
56 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in Valkey 9.1 Feb 24, 2026
@sarthakaggarwal97

Copy link
Copy Markdown
Contributor

Thanks @hanxizh9910, great work!

hpatro pushed a commit to hpatro/valkey that referenced this pull request Mar 5, 2026
…lkey-io#3091)

## Summary

Fixes valkey-io#2620

Skip loading expired hash fields when a non-preamble RDB is being loaded
on a primary server. Propagate `HDEL` to replicas when expired fields
are skipped.

## Changes

- Updated `rdbLoadObject` signature to accept `rdbflags` and `now`
parameters
- Added logic to skip expired hash fields during RDB load on primary
- Propagate `HDEL` to replicas when `RDBFLAGS_FEED_REPL` is set
- Updated all callers of `rdbLoadObject`
- Added unit test

---------

Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Co-authored-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Harkrishn Patro <bunty.hari@gmail.com>
sarthakaggarwal97 added a commit to sarthakaggarwal97/valkey-fuzzer that referenced this pull request Nov 8, 2026
…its AOF replayed

A DEBUG RELOAD drops hash fields (and keys) that expired, but the AOF
still holds the writes that made them. A node restarted from it holds
them again until it expires them, so its DEBUG DIGEST read at once
differs, though nothing it serves changed: the walk's test of
valkey-io/valkey#3091, replayed on the soak, failed lost-data so. The
faults check now judges the restarted node's data once it holds nothing
that may expire, as it already asks before the fault.

Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major-decision-approved Major decision approved by TSC team

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

HFE backlog - Avoid loading expired fields when non-preamble RDB is being loaded on primary

5 participants