Skip to content

Fix off_t to int truncation in bio repl transfer size reporting#3811

Merged
zuiderkwast merged 1 commit into
valkey-io:unstablefrom
chx9:fix/repl-off_t-truncation
Jun 12, 2026
Merged

Fix off_t to int truncation in bio repl transfer size reporting#3811
zuiderkwast merged 1 commit into
valkey-io:unstablefrom
chx9:fix/repl-off_t-truncation

Conversation

@chx9

@chx9 chx9 commented May 23, 2026

Copy link
Copy Markdown
Contributor

off_t (64-bit), but were read into int (32-bit) locals in genValkeyInfoString() and handleBioThreadFinishedRDBDownload().

This causes INFO replication to report negative master_sync_total_bytes during bio disk-based sync when RDB exceeds 2GB.

Fix: change the local variable types from int to off_t.

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 57200a82-aed0-4d7f-bb40-20ee5e3df88e

📥 Commits

Reviewing files that changed from the base of the PR and between 05fa87d and 0203835.

📒 Files selected for processing (2)
  • src/replication.c
  • src/server.c

📝 Walkthrough

Walkthrough

Two replication code paths now use off_t instead of int for local transfer-size/read counters: the bio-thread RDB download state restore and the INFO replication transfer reporting.

Changes

Replication transfer statistics type widening

Layer / File(s) Summary
Transfer statistics type widening
src/replication.c, src/server.c
Local variables in bio-thread RDB download state restoration (handleBioThreadFinishedRDBDownload()) and INFO replication output reporting are changed from int to off_t to avoid truncation of large transfer byte counters.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers:

  • enjoy-binbin
  • roshkhatri
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and accurately describes the main change: fixing truncation of off_t values to int in bio repl transfer size reporting.
Description check ✅ Passed The description clearly explains the bug (truncation of 64-bit off_t to 32-bit int causing negative values), the affected functions, and the fix applied.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@chx9 chx9 force-pushed the fix/repl-off_t-truncation branch from 741e827 to 96d4ae5 Compare May 23, 2026 02:11
@codecov

codecov Bot commented May 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.72%. Comparing base (cce8f49) to head (0203835).

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #3811   +/-   ##
=========================================
  Coverage     76.71%   76.72%           
=========================================
  Files           162      162           
  Lines         80704    80704           
=========================================
+ Hits          61914    61918    +4     
+ Misses        18790    18786    -4     
Files with missing lines Coverage Δ
src/replication.c 86.07% <100.00%> (ø)
src/server.c 89.49% <100.00%> (-0.03%) ⬇️

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

@chx9 chx9 force-pushed the fix/repl-off_t-truncation branch from 96d4ae5 to 05fa87d Compare May 23, 2026 06:57

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

thanks.

@enjoy-binbin enjoy-binbin requested a review from nitaicaro May 24, 2026 03:49
@enjoy-binbin enjoy-binbin moved this to To be backported in Valkey 9.0 May 24, 2026
@enjoy-binbin enjoy-binbin moved this to To be backported in Valkey 9.1 May 24, 2026
`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative `master_sync_total_bytes`
during bio disk-based sync when RDB exceeds 2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
@chx9 chx9 force-pushed the fix/repl-off_t-truncation branch from 05fa87d to 0203835 Compare May 25, 2026 03:19
@zuiderkwast zuiderkwast merged commit b4ea71e into valkey-io:unstable Jun 12, 2026
63 checks passed
valkeyrie-ops Bot pushed a commit that referenced this pull request Jun 14, 2026
`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
valkeyrie-ops Bot pushed a commit that referenced this pull request Jun 18, 2026
`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
sarthakaggarwal97 added a commit to sarthakaggarwal97/valkey that referenced this pull request Jun 22, 2026
…ey-io#3811) (#306)

`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.


(cherry picked from commit b4ea71e)

Signed-off-by: chx9 <lovelypiska@outlook.com>
Co-authored-by: lovelypiska <lovelypiska@outlook.com>
sarthakaggarwal97 pushed a commit to sarthakaggarwal97/valkey that referenced this pull request Jun 22, 2026
…ey-io#3811)

`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
(cherry picked from commit b4ea71e)
sarthakaggarwal97 pushed a commit to sarthakaggarwal97/valkey that referenced this pull request Jun 22, 2026
sarthakaggarwal97 added a commit to sarthakaggarwal97/valkey that referenced this pull request Jun 22, 2026
…ey-io#3811) (#313)

`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
Co-authored-by: lovelypiska <lovelypiska@outlook.com>
sarthakaggarwal97 added a commit to sarthakaggarwal97/valkey that referenced this pull request Jun 23, 2026
…ey-io#3811) (#318)

`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
Co-authored-by: lovelypiska <lovelypiska@outlook.com>
sarthakaggarwal97 added a commit to sarthakaggarwal97/valkey that referenced this pull request Jun 23, 2026
…ey-io#3811) (#322)

`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
Co-authored-by: lovelypiska <lovelypiska@outlook.com>
sarthakaggarwal97 added a commit to sarthakaggarwal97/valkey that referenced this pull request Jun 23, 2026
…ey-io#3811) (#326)

`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
Co-authored-by: lovelypiska <lovelypiska@outlook.com>
sarthakaggarwal97 pushed a commit to sarthakaggarwal97/valkey that referenced this pull request Jun 23, 2026
…ey-io#3811)

`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
sarthakaggarwal97 added a commit to sarthakaggarwal97/valkey that referenced this pull request Jun 23, 2026
…ey-io#3811) (#333)

`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
Co-authored-by: lovelypiska <lovelypiska@outlook.com>
sarthakaggarwal97 added a commit to sarthakaggarwal97/valkey that referenced this pull request Jun 23, 2026
…ey-io#3811) (#337)

`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
Co-authored-by: lovelypiska <lovelypiska@outlook.com>
sarthakaggarwal97 added a commit to sarthakaggarwal97/valkey that referenced this pull request Jun 23, 2026
…ey-io#3811) (#342)

`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
Co-authored-by: lovelypiska <lovelypiska@outlook.com>
valkeyrie-ops Bot pushed a commit that referenced this pull request Jun 25, 2026
`off_t` (64-bit), but were read into `int` (32-bit) locals in
`genValkeyInfoString()` and `handleBioThreadFinishedRDBDownload()`.

This causes INFO replication to report negative
`master_sync_total_bytes` during bio disk-based sync when RDB exceeds
2GB.

Fix: change the local variable types from `int` to `off_t`.

Signed-off-by: chx9 <lovelypiska@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To be backported
Status: To be backported

Development

Successfully merging this pull request may close these issues.

3 participants