From 0d50c23c6dac2baca6290d08050888ef30932336 Mon Sep 17 00:00:00 2001 From: spacewander Date: Fri, 2 Sep 2016 15:30:37 +0800 Subject: [PATCH 1/3] Remove duplicate fault handling Refer to: https://discuss.elastic.co/t/logstash-output-shrinkwindow-is-unexpectedly-called-twice/59408/3 --- libbeat/outputs/logstash/async.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libbeat/outputs/logstash/async.go b/libbeat/outputs/logstash/async.go index b7d02743895..5a5340ac07e 100644 --- a/libbeat/outputs/logstash/async.go +++ b/libbeat/outputs/logstash/async.go @@ -115,11 +115,7 @@ func (c *asyncClient) AsyncPublishEvents( data = data[n:] if err != nil { - c.win.shrinkWindow() _ = c.Close() - - logp.Err("Failed to publish events caused by: %v", err) - eventsNotAcked.Add(int64(len(data))) return err } } @@ -191,6 +187,7 @@ func (r *msgRef) dec() { err := r.err if err != nil { eventsNotAcked.Add(int64(len(r.batch))) + logp.Err("Failed to publish events caused by: %v", err) r.cb(r.batch, err) } else { r.cb(nil, nil) From de0901dcde45eafab71e74fe08ab85d26b5c7da0 Mon Sep 17 00:00:00 2001 From: spacewander Date: Fri, 2 Sep 2016 15:32:18 +0800 Subject: [PATCH 2/3] Count down whenever AsyncPublishEvents returns Ensure ref.count is always zero after pushing events. --- libbeat/outputs/logstash/async.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbeat/outputs/logstash/async.go b/libbeat/outputs/logstash/async.go index 5a5340ac07e..a2b4f11027a 100644 --- a/libbeat/outputs/logstash/async.go +++ b/libbeat/outputs/logstash/async.go @@ -106,6 +106,7 @@ func (c *asyncClient) AsyncPublishEvents( cb: cb, err: nil, } + defer ref.dec() for len(data) > 0 { n, err := c.publishWindowed(ref, data) @@ -119,7 +120,6 @@ func (c *asyncClient) AsyncPublishEvents( return err } } - ref.dec() return nil } From 617f9c1c7fd3b401ec3d5a981c06afd32de101b5 Mon Sep 17 00:00:00 2001 From: spacewander Date: Fri, 2 Sep 2016 16:26:43 +0800 Subject: [PATCH 3/3] add a bugfixes entry to CHANGELOG --- CHANGELOG.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index faf275d26d8..95c9e8a0df0 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -41,6 +41,7 @@ https://github.com/elastic/beats/compare/v5.0.0-alpha5...master[Check the HEAD d ==== Bugfixes *Affecting all Beats* +- Fix logstash output handles error twice when asynchronous sending fails. {pull}2441[2441] - Fix Elasticsearch structured error response parsing error. {issue}2229[2229] - Fixed the run script to allow the overriding of the configuration file. {issue}2171[2171] - Fix logstash output crash if no hosts are configured. {issue}2325[2325]