-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
474 additions
and
75 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.22.9 | ||
1.22.10 |
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 |
---|---|---|
|
@@ -12488,11 +12488,11 @@ SOFTWARE | |
|
||
-------------------------------------------------------------------------------- | ||
Dependency : github.com/elastic/elastic-agent-libs | ||
Version: v0.17.4 | ||
Version: v0.17.5 | ||
Licence type (autodetected): Apache-2.0 | ||
-------------------------------------------------------------------------------- | ||
|
||
Contents of probable licence file $GOMODCACHE/github.com/elastic/[email protected].4/LICENSE: | ||
Contents of probable licence file $GOMODCACHE/github.com/elastic/[email protected].5/LICENSE: | ||
|
||
Apache License | ||
Version 2.0, January 2004 | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM golang:1.22.9 | ||
FROM golang:1.22.10 | ||
|
||
RUN \ | ||
apt-get update \ | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM golang:1.22.9 | ||
FROM golang:1.22.10 | ||
|
||
RUN \ | ||
apt-get update \ | ||
|
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package logstash | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/elastic/elastic-agent-libs/logp" | ||
) | ||
|
||
type deadlockListener struct { | ||
log *logp.Logger | ||
timeout time.Duration | ||
ticker *time.Ticker | ||
|
||
ackChan chan int | ||
|
||
doneChan chan struct{} | ||
} | ||
|
||
const logstashDeadlockTimeout = 5 * time.Minute | ||
|
||
func newDeadlockListener(log *logp.Logger, timeout time.Duration) *deadlockListener { | ||
if timeout <= 0 { | ||
return nil | ||
} | ||
r := &deadlockListener{ | ||
log: log, | ||
timeout: timeout, | ||
ticker: time.NewTicker(timeout), | ||
|
||
ackChan: make(chan int), | ||
doneChan: make(chan struct{}), | ||
} | ||
go r.run() | ||
return r | ||
} | ||
|
||
func (r *deadlockListener) run() { | ||
defer r.ticker.Stop() | ||
defer close(r.doneChan) | ||
for { | ||
select { | ||
case n, ok := <-r.ackChan: | ||
if !ok { | ||
// Listener has been closed | ||
return | ||
} | ||
if n > 0 { | ||
// If progress was made, reset the countdown. | ||
r.ticker.Reset(r.timeout) | ||
} | ||
case <-r.ticker.C: | ||
// No progress was made within the timeout, log error so users | ||
// know there is likely a problem with the upstream host | ||
r.log.Errorf("Logstash batch hasn't reported progress in the last %v, the Logstash host may be stalled. This problem can be prevented by configuring Logstash to use PipelineBusV1 or by upgrading Logstash to 8.17+, for details see https://github.com/elastic/logstash/issues/16657", r.timeout) | ||
return | ||
} | ||
} | ||
} | ||
|
||
func (r *deadlockListener) ack(n int) { | ||
if r == nil { | ||
return | ||
} | ||
// Send the new ack to the run loop, unless it has already shut down in | ||
// which case it can be safely ignored. | ||
select { | ||
case r.ackChan <- n: | ||
case <-r.doneChan: | ||
} | ||
} | ||
|
||
func (r *deadlockListener) close() { | ||
if r == nil { | ||
return | ||
} | ||
// Signal the run loop to shut down | ||
close(r.ackChan) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package logstash | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/elastic/elastic-agent-libs/logp" | ||
) | ||
|
||
func TestDeadlockListener(t *testing.T) { | ||
const timeout = 5 * time.Millisecond | ||
log := logp.NewLogger("test") | ||
listener := newDeadlockListener(log, timeout) | ||
|
||
// Verify that the listener doesn't trigger when receiving regular acks | ||
for i := 0; i < 5; i++ { | ||
time.Sleep(timeout / 2) | ||
listener.ack(1) | ||
} | ||
select { | ||
case <-listener.doneChan: | ||
require.Fail(t, "Deadlock listener should not trigger unless there is no progress for the configured time interval") | ||
case <-time.After(timeout / 2): | ||
} | ||
|
||
// Verify that the listener does trigger when the acks stop | ||
select { | ||
case <-time.After(timeout): | ||
require.Fail(t, "Deadlock listener should trigger when there is no progress for the configured time interval") | ||
case <-listener.doneChan: | ||
} | ||
} |
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
Oops, something went wrong.