diff --git a/CHANGELOG.md b/CHANGELOG.md index c33357a391..87b84f14d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pkg/alert/alert.go b/pkg/alert/alert.go index 4ad30b7c03..d527b87abe 100644 --- a/pkg/alert/alert.go +++ b/pkg/alert/alert.go @@ -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] } diff --git a/pkg/alert/alert_test.go b/pkg/alert/alert_test.go index 7139dfc652..67f280280d 100644 --- a/pkg/alert/alert_test.go +++ b/pkg/alert/alert_test.go @@ -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,