-
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
Fix error cleanup in and after OpenTable calls #102
Conversation
Review status: 0 of 4 files reviewed at latest revision, 1 unresolved discussion. levels.go, line 313 at r1 (raw file):
When cleaning up here I chose to close the tables. Instead we could DecrRef and delete the newly created files, or otherwise directly act to delete the newly created files. I don't yet have enough of a "big picture" view of Badger to know what is right here. Comments from Reviewable |
Review status: 0 of 4 files reviewed at latest revision, 2 unresolved discussions. levels.go, line 269 at r2 (raw file):
This "builder.Empty()" condition can never happen. That's good news, because if it did happen, we would have needed to push a nil error onto Comments from Reviewable |
This one is a tricky change. Would be hard to test it as well, given it's hard to reproduce FS failures. But, at least do this. We have a populate script in badger-bench. Run it with 250M keys and 128B values. It would consume 40GB. That should ensure that at least this works well for the normal case. Reviewed 3 of 4 files at r1, 1 of 1 files at r2. levels.go, line 313 at r1 (raw file): Previously, srh (Sam Hughes) wrote…
You do need to call DecrRef here because when tables are opened, they have at least one ref. This way, we'll delete them using the logic already in place (truncate fanciness and all). levels.go, line 147 at r2 (raw file):
My first thought was: If you close the table, but someone is holding a reference to it, this would cause issues. But, I realize that this is only called on tables whose ref is not yet being held by anyone. If that's the case, can you add a comment about it. I think the "unmodified" part is largely irrelevant because all our writes are synced to disk with every levels.go, line 152 at r2 (raw file):
Make it a member of levelsController. levels.go, line 155 at r2 (raw file):
Shouldn't matter if it's first or last. Can simplify the if statement though:
levels.go, line 269 at r2 (raw file): Previously, srh (Sam Hughes) wrote…
Good point. Can you fix up the grammar of comment statement though? levels.go, line 271 at r2 (raw file):
No need for truef. They're costly. Just use y.AssertTrue. levels.go, line 305 at r2 (raw file):
Again, no need for first error (can be the last one). Can simplify if statement. levels.go, line 574 at r2 (raw file):
errors.Wrap here as well. Comments from Reviewable |
Currently running the populate script. 54.24M keys so far. Review status: 3 of 4 files reviewed at latest revision, 8 unresolved discussions. levels.go, line 313 at r1 (raw file): Previously, manishrjain (Manish R Jain) wrote…
Okay, so the decision here is that we do want to delete those files. levels.go, line 147 at r2 (raw file): Previously, manishrjain (Manish R Jain) wrote…
Right. The only plausible error is when writing last modified time, or in the case of some really janky file system. We should still say unmodified here -- I want to warn people off from blindly using it -- because we might not use O_DSYNC in the future (we might explicitly fdatasync, or under some user option, not sync at all). levels.go, line 152 at r2 (raw file): Previously, manishrjain (Manish R Jain) wrote…
Done. levels.go, line 155 at r2 (raw file): Previously, manishrjain (Manish R Jain) wrote…
I'm under the impression that the first is more likely to have useful info, while later errors might be of a more generic nature, or be the result of invalid state resulting from under-tested error handling after the first error. As a general rule. That's why I've been returning first errors. levels.go, line 269 at r2 (raw file): Previously, manishrjain (Manish R Jain) wrote…
Done. levels.go, line 271 at r2 (raw file): Previously, manishrjain (Manish R Jain) wrote…
Done. levels.go, line 574 at r2 (raw file): Previously, manishrjain (Manish R Jain) wrote…
Done. Comments from Reviewable |
Reviewed 1 of 1 files at r3. Comments from Reviewable |
- 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.
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.
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)