mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
Metrics / Bug Fix: Protect against race condition in metrics reporting with multiple inputs.
Protect initialization of metrics obejcts with mutex to prevent race condition. See https://github.com/elastic/logstash/issues/8011 for additional information. Fixes #8011 Fixes #8027 Fixes #8047
This commit is contained in:
parent
da5e3c711c
commit
7f633af69f
1 changed files with 5 additions and 2 deletions
|
@ -38,7 +38,7 @@ module LogStash; class BasePipeline
|
|||
|
||||
def initialize(pipeline_config, namespaced_metric = nil, agent = nil)
|
||||
@logger = self.logger
|
||||
|
||||
@mutex = Mutex.new
|
||||
@ephemeral_id = SecureRandom.uuid
|
||||
|
||||
@pipeline_config = pipeline_config
|
||||
|
@ -822,6 +822,9 @@ module LogStash; class Pipeline < BasePipeline
|
|||
end
|
||||
|
||||
def wrapped_write_client(plugin)
|
||||
LogStash::Instrument::WrappedWriteClient.new(@input_queue_client, self, metric, plugin)
|
||||
#need to ensure that metrics are initialized one plugin at a time, else a race condition can exist.
|
||||
@mutex.synchronize do
|
||||
LogStash::Instrument::WrappedWriteClient.new(@input_queue_client, self, metric, plugin)
|
||||
end
|
||||
end
|
||||
end; end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue