-
Notifications
You must be signed in to change notification settings - Fork 82
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: free resources on close #173
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,21 +91,6 @@ | |
Thread.current[:filter_elasticsearch_client] = nil | ||
end | ||
|
||
# Since the Elasticsearch Ruby client is not thread safe | ||
# and under high load we can get error with the connection pool | ||
# we have decided to create a new instance per worker thread which | ||
# will be lazy created on the first call to `#filter` | ||
# | ||
# I am adding a simple test case for future changes | ||
it "uses a different connection object per thread wait" do | ||
expect(plugin.clients_pool.size).to eq(0) | ||
|
||
Thread.new { plugin.filter(event) }.join | ||
Thread.new { plugin.filter(event) }.join | ||
|
||
expect(plugin.clients_pool.size).to eq(2) | ||
end | ||
|
||
it "should enhance the current event with new data" do | ||
plugin.filter(event) | ||
expect(event.get("code")).to eq(404) | ||
|
@@ -466,6 +451,32 @@ def wait_receive_request | |
Thread.current[:filter_elasticsearch_client] = nil | ||
end | ||
|
||
it 'uses a threadsafe transport adapter' do | ||
client = plugin.send(:get_client).client | ||
# we currently rely on the threadsafety guarantees provided by Manticore | ||
# this spec is a safeguard to trigger an assessment of thread-safety should | ||
# we choose a different transport adapter in the future. | ||
transport_class = extract_transport(client).options.fetch(:transport_class) | ||
expect(transport_class).to equal ::Elasticsearch::Transport::Transport::HTTP::Manticore | ||
end | ||
|
||
it 'uses a client with sufficient connection pool size' do | ||
client = plugin.send(:get_client).client | ||
transport_options = extract_transport(client).options.fetch(:transport_options) | ||
# pool_max and pool_max_per_route are manticore-specific transport options | ||
expect(transport_options).to include(:pool_max => 1000, :pool_max_per_route => 100) | ||
end | ||
|
||
it 'uses a single shared client across threads' do | ||
q = Queue.new | ||
10.times.map do | ||
Thread.new(plugin) { |instance| q.push instance.send(:get_client) } | ||
end.map(&:join) | ||
|
||
first = q.pop | ||
expect(q.pop).to be(first) until q.empty? | ||
end | ||
|
||
describe "cloud.id" do | ||
let(:valid_cloud_id) do | ||
'sample:dXMtY2VudHJhbDEuZ2NwLmNsb3VkLmVzLmlvJGFjMzFlYmI5MDI0MTc3MzE1NzA0M2MzNGZkMjZmZDQ2OjkyNDMkYTRjMDYyMzBlNDhjOGZjZTdiZTg4YTA3NGEzYmIzZTA6OTI0NA==' | ||
|
@@ -712,9 +723,9 @@ def wait_receive_request | |
end | ||
|
||
it "should read and send non-ascii query" do | ||
expect(client).to receive(:search).with( | ||
expect(client).to receive(:search).with({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. review note: rspec's message expectations differentiate between bare keyword arguments or a hash in Ruby 3.x (and so: JRuby 9.4.x from Logstash 8.10), so making this expect a hash fixes the build) |
||
:body => { "query" => { "terms" => { "lock" => [ "잠금", "uzávěr" ] } } }, | ||
:index => "") | ||
:index => ""}) | ||
|
||
plugin.filter(LogStash::Event.new) | ||
end | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@edmocosta to avoid adding config options in a patch release, I have added these with the same default values that we have in the referenced Elasticsearch Output plugin, which should allow us to completely eliminate connection contention on pipelines with fewer than 100 workers and 10
hosts
. We can make this configurable if/when necessary.