Skip to content

event database: Force an fsync after write#3220

Closed
badboy wants to merge 1 commit intomainfrom
push-mmlmtwmtnurz
Closed

event database: Force an fsync after write#3220
badboy wants to merge 1 commit intomainfrom
push-mmlmtwmtnurz

Conversation

@badboy
Copy link
Copy Markdown
Member

@badboy badboy commented Aug 15, 2025

Otherwise the file might be empty looking to outsiders. At least on Windows this caused test failures in m-c when we were implement a prototype-health ping and checking files on disk.

Only by syncing it all do we actually get the right file size on disk.

Before we used to open/close the event database files all the time, which internally does a sync.
Now sync_all is potentially more expensive than a close (through drop), as the latter is not required to block until the data is written (according to the docs: https://doc.rust-lang.org/std/fs/struct.File.html#method.sync_all)

Otherwise the file might be empty looking to outsiders.
At least on Windows this caused test failures in m-c when we were
implement a prototype-health ping and checking files on disk.

Only by syncing it all do we actually get the right file size on disk.

Before we used to open/close the event database files all the time,
which internally does a sync.
Now `sync_all` is potentially _more_ expensive than a close (through
drop), as the latter is not required to block until the data is written
(according to the docs: https://doc.rust-lang.org/std/fs/struct.File.html#method.sync_all)
@badboy badboy requested a review from a team as a code owner August 15, 2025 11:32
@badboy badboy requested review from jeddai and removed request for a team August 15, 2025 11:32
@badboy badboy marked this pull request as draft August 15, 2025 13:58
@badboy badboy closed this Aug 18, 2025
@badboy badboy deleted the push-mmlmtwmtnurz branch August 18, 2025 10:20
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.

1 participant