Skip to content

Fix check-rdb --stats crash with empty RDB#2382

Merged
enjoy-binbin merged 1 commit intovalkey-io:unstablefrom
enjoy-binbin:check_rdb2
Aug 4, 2025
Merged

Fix check-rdb --stats crash with empty RDB#2382
enjoy-binbin merged 1 commit intovalkey-io:unstablefrom
enjoy-binbin:check_rdb2

Conversation

@enjoy-binbin
Copy link
Member

@enjoy-binbin enjoy-binbin commented Jul 27, 2025

There are two problems with initializing databases to 1:

  1. db0 is used by default. After printing db0, we will additionally print
    db1 with no reason.
  2. Based on 1, if the RDB is an empty RDB, check-rdb will crash. Because
    there is no key data, we don't have the chance to call tryExpandRdbStats,
    and then when printting db1, we will crash on rdbstate.stats.

Introduced in #1743.

There are two problems with initializing databases to 1:
1. db0 is used by default. After printing db0, we will additionally print
   db1 with no reason.
2. Based on 1, if the RDB is an empty RDB, check-rdb will crash. Because
   there is no key data, we don't have the chance to call tryExpandRdbStats,
   and then when printting db1, we will crash on rdbstate.stats.

Intrudoced in valkey-io#1743.

Signed-off-by: Binbin <[email protected]>
@enjoy-binbin enjoy-binbin requested a review from zuiderkwast July 27, 2025 08:29
@codecov
Copy link

codecov bot commented Jul 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.44%. Comparing base (f21beaf) to head (059efe2).
⚠️ Report is 13 commits behind head on unstable.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #2382   +/-   ##
=========================================
  Coverage     71.44%   71.44%           
=========================================
  Files           123      123           
  Lines         67139    67139           
=========================================
  Hits          47968    47968           
  Misses        19171    19171           
Files with missing lines Coverage Δ
src/valkey-check-rdb.c 71.77% <100.00%> (ø)

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

@enjoy-binbin enjoy-binbin merged commit e16fc8d into valkey-io:unstable Aug 4, 2025
52 checks passed
@enjoy-binbin enjoy-binbin deleted the check_rdb2 branch August 4, 2025 11:11
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