Skip to content

Fix: update buffered counter only when fwrite succeeds in rioFileWrite#14833

Open
RustyCoderX wants to merge 3 commits intoredis:unstablefrom
RustyCoderX:fix-riofilewrite-buffer-bug
Open

Fix: update buffered counter only when fwrite succeeds in rioFileWrite#14833
RustyCoderX wants to merge 3 commits intoredis:unstablefrom
RustyCoderX:fix-riofilewrite-buffer-bug

Conversation

@RustyCoderX
Copy link

@RustyCoderX RustyCoderX commented Mar 1, 2026

Note

Low Risk
Low-risk, localized changes to rioFileWrite/rioSetAutoSync that adjust internal buffering counters; main risk is subtle behavior change in file I/O accounting around persistence syncing.

Overview
Fixes file-backed rio buffering accounting when autosync is disabled by only incrementing io.file.buffered after fwrite() succeeds (and returning failure on a short/failed write).

Also resets io.file.buffered when rioSetAutoSync(..., 0) disables autosync, avoiding later assertion failures if autosync is re-enabled with a smaller threshold.

Written by Cursor Bugbot for commit 5656a47. This will update automatically on new commits. Configure here.

@jit-ci
Copy link

jit-ci bot commented Mar 1, 2026

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

if (!r->io.file.autosync) return fwrite(buf,len,1,r->io.file.fp);
if (!r->io.file.autosync) {
if (fwrite(buf,len,1,r->io.file.fp) == 0) return 0;
r->io.file.buffered += len;
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the point of increasing it if autosync is turned off?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@RustyCoderX I think you've misunderstood. What I mean is that io.file.buffered only works when autosync is enabled. If it's disabled, why bother to update it?

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