Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve durability of schema version file writes #7065

Merged
merged 1 commit into from
Sep 20, 2022

Conversation

squalus
Copy link
Member

@squalus squalus commented Sep 19, 2022

This makes some durability improvements to the schema version file writes and fixes the "schema is corrupt" errors from the test case described in #7064.

I haven't tested on Darwin yet.

  • call close explicitly in writeFile to prevent the close exception from being ignored
  • fsync after writing schema file to flush data to disk
  • fsync schema file parent to flush metadata to disk

Copy link
Member

@thufschmitt thufschmitt left a comment

Choose a reason for hiding this comment

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

Thanks,

A couple small suggestions but looks good overall.

Note that the CI is failing on darwin (doesn't like F_FULLSYNC. Maybe a missing #include?)

src/libutil/util.cc Show resolved Hide resolved
src/libstore/local-store.cc Outdated Show resolved Hide resolved
- call close explicitly in writeFile to prevent the close exception
  from being ignored
- fsync after writing schema file to flush data to disk
- fsync schema file parent to flush metadata to disk

NixOS#7064
@squalus
Copy link
Member Author

squalus commented Sep 20, 2022

Note that the CI is failing on darwin (doesn't like F_FULLSYNC. Maybe a missing #include?)

Oops, it's F_FULLFSYNC. Fixed the typo and tested a build on Darwin.

Copy link
Member

@thufschmitt thufschmitt left a comment

Choose a reason for hiding this comment

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

Great, thanks :)

@thufschmitt thufschmitt merged commit 9dadb54 into NixOS:master Sep 20, 2022
@squalus squalus deleted the schema-corrupt branch September 20, 2022 16:11
Minion3665 pushed a commit to Minion3665/nix that referenced this pull request Feb 23, 2023
Improve durability of schema version file writes
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