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

ruler: Fix #2204 bug where alert queue is unpoppable causing full queue and dropped alerts #2238

Merged
merged 5 commits into from Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,10 @@ We use *breaking* word for marking changes that are not backward compatible (rel

## Unreleased

### Fixed

- [#2238](https://github.com/thanos-io/thanos/pull/2238) Ruler: Fixed Issue #2204 bug in alert queue signalling filled up queue and alerts were dropped

## [v0.11.0](https://github.com/thanos-io/thanos/releases/tag/v0.11.0-rc.1) - 2020.03.02

### Fixed
Expand Down
6 changes: 6 additions & 0 deletions pkg/alert/alert.go
Expand Up @@ -195,6 +195,12 @@ func (q *Queue) Pop(termc <-chan struct{}) []*Alert {

q.popped.Add(float64(n))

if len(q.queue) > 0 {
select {
case q.morec <- struct{}{}:
default:
}
}
return as[:n]
}

Expand Down
25 changes: 25 additions & 0 deletions pkg/alert/alert_test.go
Expand Up @@ -19,6 +19,31 @@ import (
"github.com/thanos-io/thanos/pkg/testutil"
)

func TestQueue_Pop_all_Pushed(t *testing.T) {
qcapacity := 10
batchsize := 1
pushes := 3

q := NewQueue(
nil, nil, qcapacity, batchsize, nil, nil,
)
for i := 0; i < pushes; i++ {
q.Push([]*Alert{
{},
{},
})
}

timeoutc := make(chan struct{}, 1)
time.AfterFunc(time.Second, func() { timeoutc <- struct{}{} })
popped := 0
for p := q.Pop(timeoutc); p != nil; p = q.Pop(timeoutc) {
popped += len(p)
}

testutil.Equals(t, pushes*2, popped)
}

func TestQueue_Push_Relabelled(t *testing.T) {
q := NewQueue(
nil, nil, 10, 10,
Expand Down