Skip to content

Conversation

sourcejedi
Copy link

Two very minor improvements, for your reviewing pleasure.

  • Clean up fds of segments we delete (during compaction)
  • io.write_commit() already implies io.close_segment()

When we delete a segment, let's close its fd as well.
Note as well wasting the fd, this was forcing the
filesystem to preserve the deleted file until we exited.

I noticed roughly 20 open fds of deleted files when
attic saved 10G of data.
@ThomasWaldmann
Copy link
Contributor

Nice findings!

One slight style improvement: use "is not None" rather than "!= None".
As there is only one None object, you can compare based on object identity rather than object value.

@ThomasWaldmann
Copy link
Contributor

also, while you are at it:

    self.fds.pop(segment).close()

Search that line and see it should use same code as you did and rather check the return value of the pop operation before calling .close() on it. Maybe never a problem in practice, but the check should be made always, imho.

PEP8 says to prefer "is not None"
Suggested by @ThomasWaldmann.  Avoiding a complex assumption
should make the code easier to understand and maintain.

(Technically we do have an fd for the segment, because
the only caller opens the segment and checks it before
calling for repair.)
@sourcejedi
Copy link
Author

Thanks for the style hint!

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