mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Merge pull request #9457 from prometheus/release-2.30-merge
Merge release-2.30 branch into main
This commit is contained in:
commit
5a4c3734b1
|
@ -1,3 +1,12 @@
|
||||||
|
## 2.30.3 / 2021-10-05
|
||||||
|
|
||||||
|
* [BUGFIX] TSDB: Fix panic on failed snapshot replay. #9438
|
||||||
|
* [BUGFIX] TSDB: Don't fail snapshot replay with exemplar storage disabled when the snapshot contains exemplars. #9438
|
||||||
|
|
||||||
|
## 2.30.2 / 2021-10-01
|
||||||
|
|
||||||
|
* [BUGFIX] TSDB: Don't error on overlapping m-mapped chunks during WAL replay. #9381
|
||||||
|
|
||||||
## 2.30.1 / 2021-09-28
|
## 2.30.1 / 2021-09-28
|
||||||
|
|
||||||
* [ENHANCEMENT] Remote Write: Redact remote write URL when used for metric label. #9383
|
* [ENHANCEMENT] Remote Write: Redact remote write URL when used for metric label. #9383
|
||||||
|
|
15
tsdb/head.go
15
tsdb/head.go
|
@ -176,6 +176,10 @@ func NewHead(r prometheus.Registerer, l log.Logger, wal *wal.WAL, opts *HeadOpti
|
||||||
stats = NewHeadStats()
|
stats = NewHeadStats()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !opts.EnableExemplarStorage {
|
||||||
|
opts.MaxExemplars.Store(0)
|
||||||
|
}
|
||||||
|
|
||||||
h := &Head{
|
h := &Head{
|
||||||
wal: wal,
|
wal: wal,
|
||||||
logger: l,
|
logger: l,
|
||||||
|
@ -211,7 +215,16 @@ func NewHead(r prometheus.Registerer, l log.Logger, wal *wal.WAL, opts *HeadOpti
|
||||||
|
|
||||||
func (h *Head) resetInMemoryState() error {
|
func (h *Head) resetInMemoryState() error {
|
||||||
var err error
|
var err error
|
||||||
em := NewExemplarMetrics(h.reg)
|
var em *ExemplarMetrics
|
||||||
|
if h.exemplars != nil {
|
||||||
|
ce, ok := h.exemplars.(*CircularExemplarStorage)
|
||||||
|
if ok {
|
||||||
|
em = ce.metrics
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if em == nil {
|
||||||
|
em = NewExemplarMetrics(h.reg)
|
||||||
|
}
|
||||||
es, err := NewCircularExemplarStorage(h.opts.MaxExemplars.Load(), em)
|
es, err := NewCircularExemplarStorage(h.opts.MaxExemplars.Load(), em)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -31,6 +31,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
prom_testutil "github.com/prometheus/client_golang/prometheus/testutil"
|
prom_testutil "github.com/prometheus/client_golang/prometheus/testutil"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
|
@ -2753,7 +2754,16 @@ func TestChunkSnapshot(t *testing.T) {
|
||||||
|
|
||||||
// Test the replay of snapshot.
|
// Test the replay of snapshot.
|
||||||
head.opts.EnableMemorySnapshotOnShutdown = true // Enabled to read from snapshot.
|
head.opts.EnableMemorySnapshotOnShutdown = true // Enabled to read from snapshot.
|
||||||
|
|
||||||
|
// Disabling exemplars to check that it does not hard fail replay
|
||||||
|
// https://github.com/prometheus/prometheus/issues/9437#issuecomment-933285870.
|
||||||
|
head.opts.EnableExemplarStorage = false
|
||||||
|
head.opts.MaxExemplars.Store(0)
|
||||||
|
expExemplars = expExemplars[:0]
|
||||||
|
|
||||||
openHeadAndCheckReplay()
|
openHeadAndCheckReplay()
|
||||||
|
|
||||||
|
require.Equal(t, 0.0, prom_testutil.ToFloat64(head.metrics.snapshotReplayErrorTotal))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2805,7 +2815,8 @@ func TestSnapshotError(t *testing.T) {
|
||||||
// Create new Head which should replay this snapshot.
|
// Create new Head which should replay this snapshot.
|
||||||
w, err := wal.NewSize(nil, nil, head.wal.Dir(), 32768, false)
|
w, err := wal.NewSize(nil, nil, head.wal.Dir(), 32768, false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
head, err = NewHead(nil, nil, w, head.opts, nil)
|
// Testing https://github.com/prometheus/prometheus/issues/9437 with the registry.
|
||||||
|
head, err = NewHead(prometheus.NewRegistry(), nil, w, head.opts, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, head.Init(math.MinInt64))
|
require.NoError(t, head.Init(math.MinInt64))
|
||||||
|
|
||||||
|
|
|
@ -948,6 +948,11 @@ Outer:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !h.opts.EnableExemplarStorage || h.opts.MaxExemplars.Load() <= 0 {
|
||||||
|
// Exemplar storage is disabled.
|
||||||
|
continue Outer
|
||||||
|
}
|
||||||
|
|
||||||
decbuf := encoding.Decbuf{B: rec[1:]}
|
decbuf := encoding.Decbuf{B: rec[1:]}
|
||||||
|
|
||||||
exemplarBuf = exemplarBuf[:0]
|
exemplarBuf = exemplarBuf[:0]
|
||||||
|
@ -969,7 +974,7 @@ Outer:
|
||||||
Value: e.V,
|
Value: e.V,
|
||||||
Ts: e.T,
|
Ts: e.T,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
loopErr = errors.Wrap(err, "append exemplar")
|
loopErr = errors.Wrap(err, "add exemplar")
|
||||||
break Outer
|
break Outer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue