-
Notifications
You must be signed in to change notification settings - Fork 47
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: Fix file descriptor leaks in WriteApi #95
Conversation
When a worker is created for a flush of the worker on close, it will just create a new object which makes it harder for for the garbage collector to correctly free the unused objects because the Worker itself has a reference to the WriteApi object it called. This is especially frustrating for WriteType::SYNCHRONOUS which doesn't need workers at all.
The worker will be flushed when something calls close on the WriteApi. But the worker will still continue to hold an reference to the WriteApi. This prevents an easy cleanup of the WriteApi by the (non-cyclic) garbage collector.
The autoCloseable list of a client is only growing but is never cleared. This causes problems with the reference based garbage collection. But there is nothing more to process when all writers were closed. This problem can often be seen on a system that each call of client->createWriteApi (on the same "global" client) followed by a ->write() will leak one or more file descriptor(s).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ecsv thanks for your PR 👍
Can you please update CHANGELOG.md? After that we can merge this PR into master.
Codecov Report
@@ Coverage Diff @@
## master #95 +/- ##
============================================
+ Coverage 81.60% 81.66% +0.06%
- Complexity 378 379 +1
============================================
Files 23 23
Lines 897 900 +3
============================================
+ Hits 732 735 +3
Misses 165 165
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for your PR 👍
Proposed Changes
disable creation of WriteApi worker on close
When a worker is created for a flush of the worker on close, it will just create a new object which makes it harder for for the garbage collector to correctly free the unused objects because the Worker itself has a reference to the WriteApi object it called. This is especially frustrating for WriteType::SYNCHRONOUS which doesn't need workers at all.
ensure worker are destroyed after WriteApi::close
The worker will be flushed when something calls close on the WriteApi. But the worker will still continue to hold an reference to the WriteApi. This prevents an easy cleanup of the WriteApi by the (non-cyclic) garbage collector.
clear Client::autoCloseable on close
The autoCloseable list of a client is only growing but is never cleared. This causes problems with the reference based garbage collection. But there is nothing more to process when all writers were closed.
This problem can often be seen on a system that each call of client->createWriteApi (on the same "global" client) followed by a ->write() will leak one or more file descriptor(s).
Checklist
make test
completes successfully