Skip to content

Fix missing flush, flush before sync#7263

Merged
generall merged 2 commits intodevfrom
flush-buffer-in-immutable-id-tracker
Sep 16, 2025
Merged

Fix missing flush, flush before sync#7263
generall merged 2 commits intodevfrom
flush-buffer-in-immutable-id-tracker

Conversation

@generall
Copy link
Member

Also checked other places with sync_all, seems to be the only one missing.

@generall generall requested a review from timvisee September 15, 2025 18:36
coderabbitai[bot]

This comment was marked as resolved.

@qdrant qdrant deleted a comment from coderabbitai bot Sep 16, 2025
@timvisee timvisee changed the title add missed flush buffer Fix missing flush, flush before sync Sep 16, 2025
Copy link
Member

@timvisee timvisee left a comment

Choose a reason for hiding this comment

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

Great find! Yes, here we try to sync before all data from the writer is flushed.

I changed to logic a bit. The write buffer now wraps the owned type. It makes it impossible to call sync_all without explicitly flushing it first.

I applied the same to all other write buffer instances, as there were some inconsistencies.

@timvisee timvisee requested a review from agourlay September 16, 2025 07:48
Comment on lines 337 to 345
// Write mappings to disk.
let file = File::create(Self::mappings_file_path(path))?;
let mut writer = BufWriter::new(&file);
let mut writer = BufWriter::new(file);
Self::store_mapping(&mappings, &mut writer)?;

// Explicitly fsync file contents to ensure durability
writer.flush()?;
let file = writer.into_inner().unwrap();
file.sync_all()?;
Copy link
Member

Choose a reason for hiding this comment

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

Key change is here: first flush, then sync_all.

coderabbitai[bot]

This comment was marked as resolved.

@qdrant qdrant deleted a comment from coderabbitai bot Sep 16, 2025
@generall generall merged commit dbe71d4 into dev Sep 16, 2025
16 checks passed
@generall generall deleted the flush-buffer-in-immutable-id-tracker branch September 16, 2025 08:34
timvisee added a commit that referenced this pull request Sep 29, 2025
* add missed flush buffer

* For all BufWriters, wrap owned type and explicitly flush

---------

Co-authored-by: timvisee <tim@visee.me>
@timvisee timvisee mentioned this pull request Sep 29, 2025
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