-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fsync directory after creating files #105
Conversation
Review status: 0 of 3 files reviewed at latest revision, 1 unresolved discussion. kv.go, line 376 at r1 (raw file):
Can't you just open directory with O_DSYNC? That way all creates, deletes etc. would automatically be synced; avoiding code complexity. Comments from Reviewable |
Review status: 0 of 3 files reviewed at latest revision, 1 unresolved discussion. kv.go, line 376 at r1 (raw file): Previously, manishrjain (Manish R Jain) wrote…
I don't think that works. Being opened O_SYNC or O_DSYNC is part of the file descriptor, so you'd need a way to open the file using a directory file descriptor. You can't do write operations on a directory file descriptor, generally speaking. (You can only open a directory with O_RDONLY, in fact.) The system call openat(2) exists, but it's not exposed in Go and anyway, I doubt it has that semantic. Comments from Reviewable |
Reviewed 3 of 3 files at r1. kv.go, line 325 at r1 (raw file):
Just call sync twice, and avoid the syncBothDirs function. This is not performance critical, and the function adds unnecessary code. levels.go, line 315 at r1 (raw file):
This isn't required. the levels.go, line 327 at r1 (raw file):
This can be rewritten: if firstErr == nil { You anyways only want to call syncDir if firstErr was nil. (no need for syncErr var). value.go, line 650 at r1 (raw file):
if l.opt.SyncWrites is false, then do we need to do this? value.go, line 653 at r1 (raw file):
can fit in last line. Comments from Reviewable |
It seems not to help performance or memory usage substantially. Maybe it does not help at all.
- We now close fd inside of OpenTable upon error. - At many callsites (where we call OpenTable many times in a loop) we now cleanup resources properly.
Review status: 0 of 3 files reviewed at latest revision, 6 unresolved discussions. kv.go, line 325 at r1 (raw file): Previously, manishrjain (Manish R Jain) wrote…
Done. levels.go, line 315 at r1 (raw file): Previously, manishrjain (Manish R Jain) wrote…
Done. levels.go, line 327 at r1 (raw file): Previously, manishrjain (Manish R Jain) wrote…
Done. value.go, line 650 at r1 (raw file): Previously, manishrjain (Manish R Jain) wrote…
I guess not. Changing that to call conditionally. But also, I'll add a syncDir() call to valueLog::sync(). value.go, line 653 at r1 (raw file): Previously, manishrjain (Manish R Jain) wrote…
So for 100 columns, we're basing that on there being 4 spaces per tab? I was doing 8. Doing 4 now. Comments from Reviewable |
Reviewed 3 of 3 files at r2. value.go, line 653 at r1 (raw file): Previously, srh (Sam Hughes) wrote…
I think Comments from Reviewable |
We don't fsync the directory when removing files, because it's safe to crash if you haven't removed a file. (We do though, when cleanly shutting down the KV-store.)
Fixes #104.
I've assumed that removing files doesn't have the same urgency (I don't know Badger in and out, the assumption here is that starting the store doesn't infer anything from a file's mere existence).
Things might look slightly unfamiliar because it's based on the changes from the other two PR's I've made, #102 and #103.
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)