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

storage/engine: Do we need use_fsync? #16412

Closed
irfansharif opened this issue Jun 8, 2017 · 6 comments
Closed

storage/engine: Do we need use_fsync? #16412

irfansharif opened this issue Jun 8, 2017 · 6 comments
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-1-stability Severe stability issues that can be fixed by upgrading, but usually don’t resolve by restarting
Milestone

Comments

@irfansharif
Copy link
Contributor

Fallout from discussion at #16361.

RocksDB by default uses faster fdatasync() to sync files. If you want to use fsync(), you can set Options::use_fsync to true. You should set this to true on filesystems like ext3 that can lose files after a reboot.

Source: rocksdb/wiki

This is a flag set on rocksdb::Options, it should somewhere happen here but we don't seem to be doing so.

cc @petermattis.

@irfansharif irfansharif added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Jun 8, 2017
@irfansharif irfansharif self-assigned this Jun 8, 2017
@irfansharif irfansharif added the S-1-stability Severe stability issues that can be fixed by upgrading, but usually don’t resolve by restarting label Jun 8, 2017
@bdarnell
Copy link
Contributor

bdarnell commented Jun 8, 2017

Which filesystems are "like ext3" in this respect? How common is ext3 these days? ext4 was the default in RHEL6, which is the oldest platform we support. I would expect (but have not verified) that all platforms we care about default to filesystems where this is not an issue.

It would be nice if we could encapsulate this knowledge into rocksdb instead of doing our own inspection of the filesystem.

@petermattis petermattis added this to the 1.1 milestone Aug 1, 2017
@andreimatei andreimatei assigned cuongdo and unassigned irfansharif Oct 2, 2017
@petermattis
Copy link
Collaborator

This isn't new behavior in 1.1. Punting to 1.2.

@petermattis petermattis modified the milestones: 1.1, 1.2 Oct 2, 2017
@cuongdo cuongdo assigned nvanbenschoten and unassigned cuongdo Oct 3, 2017
@nvanbenschoten
Copy link
Member

This is also discussed on the comment for rocksdb::Options.use_fsync.

I'm also kind of confused why this logic isn't encapsulated in RocksDB, especially because the criteria is pretty vague: "filesystems like ext3 that can lose files after a reboot". Is anyone aware of a way to detect systems that match this requirement?

I've audited a few popular uses of RocksDB (MyRocks, MongoRocks, and TIKV) and none of them have any logic to handle this. In fact, the only project that even uses the use_fsync option at all is MyRocks, which seems to link it to a command-line flag.

@bdarnell
Copy link
Contributor

bdarnell commented Jan 25, 2018

Wearing my programmer-archaeologist hat:

The line "filesystems like ext3 that can lose files after a reboot" was added in August 27, 2012 (facebook/rocksdb@fc20273)

An fdatasync bug in both ext3 and ext4 was reported and fixed in september. The fixes are torvalds/linux@156bddd for ext3 (first published in kernel version 3.6 AFAICT) and torvalds/linux@b71fc07 for ext4 (first published in kernel version 3.7).

So at the time that comment was written, ext4 was "like ext3" and could lose data if fdatasync were used instead of fsync. I think it's plausible that this is the bug it was referring to. This particular bug is long since fixed for both filesystems. It's always possible that there are other bugs but I don't see any particular reason to single out ext4 for this. I haven't seen any more recent reports of problems that are fixed by switching from fdatasync to fsync.

This is most interesting in the context of RHEL6, our oldest supported platform. They run with a custom kernel, branched from the mainline way back in 2.6.32 but with many fixes backported. I think the ext4 fix was not backported to the RHEL6 kernel until Dec 17 2015, in version 2.6.32-595.el6 (source)

@bdarnell bdarnell changed the title storage/engine: RocksDB can lose synced writes on ext3 filesystems storage/engine: Do we need use_fsync? Jan 25, 2018
@bdarnell bdarnell modified the milestones: 2.0, Later Jan 25, 2018
@bdarnell
Copy link
Contributor

Removing milestone because I don't think we need to do anything involving the use_fsync option. Leaving open until we get an upstream response on facebook/rocksdb#3410

@bdarnell bdarnell self-assigned this Jan 25, 2018
@bdarnell
Copy link
Contributor

Upstream doesn't know of any other reason to set this flag, so I think we can just close this issue without exposing a way to set use_fsync (unless and until a new bug here is discovered)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-1-stability Severe stability issues that can be fixed by upgrading, but usually don’t resolve by restarting
Projects
None yet
Development

No branches or pull requests

5 participants