mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
storage: Guard against appending to evicted chunk
Fixes #2480. For certain definition of "fixes". This is something that should never happen. Sadly, it does happen, albeit extremely rarely. This could be some weird cornercase we haven't covered yet. Or it happens as a consequesnce of data corruption or a crash recovery gone bad. This is not a "real" fix as we don't know the root cause of the incident reported in #2480. However, this makes sure the server does not crash, but deals gracefully with the problem: The series in question is quarantined, which even makes it available for forensics.
This commit is contained in:
parent
9775ad4754
commit
7199a9d9d4
|
@ -33,7 +33,10 @@ const ChunkLen = 1024
|
||||||
// DefaultEncoding can be changed via a flag.
|
// DefaultEncoding can be changed via a flag.
|
||||||
var DefaultEncoding = DoubleDelta
|
var DefaultEncoding = DoubleDelta
|
||||||
|
|
||||||
var errChunkBoundsExceeded = errors.New("attempted access outside of chunk boundaries")
|
var (
|
||||||
|
errChunkBoundsExceeded = errors.New("attempted access outside of chunk boundaries")
|
||||||
|
errAddedToEvictedChunk = errors.New("attempted to add sample to evicted chunk")
|
||||||
|
)
|
||||||
|
|
||||||
// EvictRequest is a request to evict a chunk from memory.
|
// EvictRequest is a request to evict a chunk from memory.
|
||||||
type EvictRequest struct {
|
type EvictRequest struct {
|
||||||
|
@ -133,6 +136,9 @@ func NewDesc(c Chunk, firstTime model.Time) *Desc {
|
||||||
// The chunk must be pinned, and the caller must have locked the fingerprint of
|
// The chunk must be pinned, and the caller must have locked the fingerprint of
|
||||||
// the series.
|
// the series.
|
||||||
func (d *Desc) Add(s model.SamplePair) ([]Chunk, error) {
|
func (d *Desc) Add(s model.SamplePair) ([]Chunk, error) {
|
||||||
|
if d.C == nil {
|
||||||
|
return nil, errAddedToEvictedChunk
|
||||||
|
}
|
||||||
return d.C.Add(s)
|
return d.C.Add(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue