Skip to content

Fix RDB expiry write length and leak when loading zipmap - #3422

Merged
zuiderkwast merged 3 commits into
valkey-io:unstablefrom
charsyam:feature/rdb-memory-leak
Apr 7, 2026
Merged

zuiderkwast merged 3 commits into
valkey-io:unstablefrom
charsyam:feature/rdb-memory-leak

Conversation

@charsyam

@charsyam charsyam commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Fix two things:

  1. Incorrect RDB object size reported when writing hash fields with expiration, because of wrong position of parentheses. Affects the serialized size reported in DEBUG OBJECT.

  2. Memory leak when loading a zipmap (only used in really old RDB versions).

@codecov

codecov Bot commented Mar 31, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 76.50%. Comparing base (fb655db) to head (f470d87).
⚠️ Report is 7 commits behind head on unstable.

Files with missing lines Patch % Lines
src/rdb.c 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #3422      +/-   ##
============================================
- Coverage     76.51%   76.50%   -0.01%     
============================================
  Files           157      157              
  Lines         79025    79027       +2     
============================================
- Hits          60463    60461       -2     
- Misses        18562    18566       +4     
Files with missing lines Coverage Δ
src/rdb.c 76.76% <50.00%> (-0.29%) ⬇️

... and 23 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.

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

Thanks!

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

Thanks!

Comment thread src/rdb.c Resolved

@hpatro hpatro 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 @charsyam . Did you manage to find them just by reading the code or did some tool help identify them ?

@hpatro hpatro changed the title [BUGFIX] fix rdb memory leak and invalid size update [BUGFIX] Fix RDB expiry write length and listpack cleanup Apr 2, 2026
@hpatro

hpatro commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Retried the test failure but it failed again. Hence, performed a merge with unstable. if the tests passes now, will merge this.

@hpatro

hpatro commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

one pending test failure on this PR

*** [err]: diskless no replicas drop during rdb pipe in tests/integration/replication.tcl
rdb child didn't terminate
Cleanup: may take some time... OK

https://github.com/valkey-io/valkey/actions/runs/23921583291/job/69768943397?pr=3422

Is it somehow related ? Could you take a look @charsyam ?

@charsyam

charsyam commented Apr 3, 2026

Copy link
Copy Markdown
Contributor Author

@hpatro I will check soon. but I think it is not related it.

@zuiderkwast

Copy link
Copy Markdown
Contributor

diskless no replicas drop during rdb pipe in tests/integration/replication.tcl

This one is flaky on unstable. I've seen it failing.

@daemyung-lablup

Copy link
Copy Markdown
Contributor

@hpatro I think it is a kind of timing issue. in my local, and other machine , the tests work well.

@zuiderkwast zuiderkwast changed the title [BUGFIX] Fix RDB expiry write length and listpack cleanup Fix RDB expiry write length and leak when loading zipmap Apr 7, 2026
@zuiderkwast
zuiderkwast merged commit 2585f60 into valkey-io:unstable Apr 7, 2026
84 of 86 checks passed
sarthakaggarwal97 pushed a commit to sarthakaggarwal97/valkey that referenced this pull request Apr 16, 2026
)

Fix two things:

1. Incorrect RDB object size reported when writing hash fields with
expiration, because of wrong position of parentheses. Affects the
serialized size reported in DEBUG OBJECT.

2. Memory leak when loading a zipmap (only used in really old RDB
versions).

Signed-off-by: charsyam <[email protected]>
Co-authored-by: Harkrishn Patro <[email protected]>
madolson pushed a commit that referenced this pull request Apr 27, 2026
Fix two things:

1. Incorrect RDB object size reported when writing hash fields with
expiration, because of wrong position of parentheses. Affects the
serialized size reported in DEBUG OBJECT.

2. Memory leak when loading a zipmap (only used in really old RDB
versions).

Signed-off-by: charsyam <[email protected]>
Co-authored-by: Harkrishn Patro <[email protected]>
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request May 26, 2026
)

Fix two things:

1. Incorrect RDB object size reported when writing hash fields with
expiration, because of wrong position of parentheses. Affects the
serialized size reported in DEBUG OBJECT.

2. Memory leak when loading a zipmap (only used in really old RDB
versions).

Signed-off-by: charsyam <[email protected]>
Co-authored-by: Harkrishn Patro <[email protected]>
Signed-off-by: Roshan Khatri <[email protected]>
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.

8 participants