mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
Correctly stop the timer used in the remote write path.
This commit is contained in:
parent
f63e7db4cb
commit
97a5fc8cbb
|
@ -430,6 +430,14 @@ func (s *shards) runShard(i int) {
|
||||||
pendingSamples := model.Samples{}
|
pendingSamples := model.Samples{}
|
||||||
|
|
||||||
timer := time.NewTimer(s.qm.cfg.BatchSendDeadline)
|
timer := time.NewTimer(s.qm.cfg.BatchSendDeadline)
|
||||||
|
defer func() {
|
||||||
|
if !timer.Stop() {
|
||||||
|
select {
|
||||||
|
case <-timer.C:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -449,11 +457,16 @@ func (s *shards) runShard(i int) {
|
||||||
for len(pendingSamples) >= s.qm.cfg.MaxSamplesPerSend {
|
for len(pendingSamples) >= s.qm.cfg.MaxSamplesPerSend {
|
||||||
s.sendSamples(pendingSamples[:s.qm.cfg.MaxSamplesPerSend])
|
s.sendSamples(pendingSamples[:s.qm.cfg.MaxSamplesPerSend])
|
||||||
pendingSamples = pendingSamples[s.qm.cfg.MaxSamplesPerSend:]
|
pendingSamples = pendingSamples[s.qm.cfg.MaxSamplesPerSend:]
|
||||||
|
|
||||||
|
if !timer.Stop() {
|
||||||
|
select {
|
||||||
|
case <-timer.C:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
timer.Reset(s.qm.cfg.BatchSendDeadline)
|
||||||
}
|
}
|
||||||
if !timer.Stop() {
|
|
||||||
<-timer.C
|
|
||||||
}
|
|
||||||
timer.Reset(s.qm.cfg.BatchSendDeadline)
|
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
if len(pendingSamples) > 0 {
|
if len(pendingSamples) > 0 {
|
||||||
s.sendSamples(pendingSamples)
|
s.sendSamples(pendingSamples)
|
||||||
|
|
Loading…
Reference in a new issue