-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
buf_file: handle "Too many open files" error to keep buffer and metadata pair #1468
Conversation
387295c
to
27ecd86
Compare
…ata pair This is not incomplete but keep buffer and metadata pair phase as much as possible.
27ecd86
to
332ee73
Compare
@tagomoris Could you check this? |
@repeatedly Do you have any issues that this pull-request is about? Add it in description if exists. |
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.
I cannot understand why rescue => re
can be ignored, why this code try to rename once again with new_chunk_path
, and many others (without tests).
Add many comments for why, and test cases if possible.
Because it can't be restored. We can add retry mechanizm for it but it may cause livelock under too many open and high load environment . |
Added comment. |
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.
Added comments.
# So we ignore such errors for now and log better message instead. | ||
# "Too many open files" should be fixed by proper buffer configuration and system setting. | ||
end | ||
if re |
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.
It's better to use else clause to simplify code.
begin
file_rename
rescue => re
raise "" # using re
else
raise "" # using e
end
rescue => re | ||
# See above | ||
end | ||
if re |
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.
ditto
@chunk.sync = true | ||
@chunk.binmode | ||
rescue => e | ||
raise BufferOverflowError, "can't create buffer file for #{path}. Stop creating buffer files: error = #{e}" |
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.
Does this statement expect "too many open files" or exceptions like that?
Please add a comment about expected exception types - it seems not the direct "buffer overflow" error.
@meta.sync = true | ||
@meta.binmode | ||
rescue => e | ||
@chunk.close |
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.
this requires rescue nil
.
@meta.binmode | ||
rescue => e | ||
@chunk.close | ||
File.unlink(@path) |
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.
ditto.
rescue => e | ||
@chunk.close | ||
File.unlink(@path) | ||
raise BufferOverflowError, "can't create buffer metadata for #{path}. Stop creating buffer files: error = #{e}" |
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.
Same comment required above.
This is not incomplete but keep buffer and metadata pair phase as much as possible.
Use
BufferOverflowError
increate_new_chunk
for input plugin retry.TODO: Writing unittest for this case is hard. It will be added to integration test.