Skip to content
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

Merged
merged 3 commits into from
Feb 16, 2017

Conversation

repeatedly
Copy link
Member

@repeatedly repeatedly commented Feb 15, 2017

This is not incomplete but keep buffer and metadata pair phase as much as possible.

Use BufferOverflowError in create_new_chunk for input plugin retry.

TODO: Writing unittest for this case is hard. It will be added to integration test.

@repeatedly repeatedly force-pushed the buffer-with-too-many-open-files branch from 387295c to 27ecd86 Compare February 15, 2017 17:27
…ata pair

This is not incomplete but keep buffer and metadata pair phase
as much as possible.
@repeatedly repeatedly force-pushed the buffer-with-too-many-open-files branch from 27ecd86 to 332ee73 Compare February 15, 2017 21:06
@repeatedly
Copy link
Member Author

@tagomoris Could you check this?

@tagomoris
Copy link
Member

@repeatedly Do you have any issues that this pull-request is about? Add it in description if exists.

Copy link
Member

@tagomoris tagomoris left a 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.

@repeatedly
Copy link
Member Author

why rescue => re can be ignored,

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 .
This patch adds "This may causes inconsistent state" message instead.
I will add comments.

@repeatedly
Copy link
Member Author

Added comment.

Copy link
Member

@tagomoris tagomoris left a 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
Copy link
Member

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
Copy link
Member

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}"
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment required above.

@repeatedly repeatedly merged commit 9482bb4 into master Feb 16, 2017
@repeatedly repeatedly deleted the buffer-with-too-many-open-files branch February 16, 2017 11:44
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