mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Drop out-of-bound samples
This commit is contained in:
parent
d4779b374c
commit
472c618c39
1
block.go
1
block.go
|
@ -65,6 +65,7 @@ type persistedBlock struct {
|
||||||
|
|
||||||
type blockMeta struct {
|
type blockMeta struct {
|
||||||
*BlockMeta
|
*BlockMeta
|
||||||
|
|
||||||
Version int `json:"version"`
|
Version int `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
head.go
13
head.go
|
@ -131,7 +131,7 @@ func openHeadBlock(dir string, l log.Logger) (*headBlock, error) {
|
||||||
// inBounds returns true if the given timestamp is within the valid
|
// inBounds returns true if the given timestamp is within the valid
|
||||||
// time bounds of the block.
|
// time bounds of the block.
|
||||||
func (h *headBlock) inBounds(t int64) bool {
|
func (h *headBlock) inBounds(t int64) bool {
|
||||||
return h.meta.MinTime != nil && t < *h.meta.MinTime
|
return h.meta.MinTime == nil || t >= *h.meta.MinTime
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close syncs all data and closes underlying resources of the head block.
|
// Close syncs all data and closes underlying resources of the head block.
|
||||||
|
@ -244,10 +244,17 @@ func (a *headAppender) Add(ref uint64, t int64, v float64) error {
|
||||||
if ms == nil {
|
if ms == nil {
|
||||||
return ErrNotFound
|
return ErrNotFound
|
||||||
}
|
}
|
||||||
c := ms.head()
|
|
||||||
|
|
||||||
// TODO(fabxc): memory series should be locked here already.
|
// TODO(fabxc): memory series should be locked here already.
|
||||||
// Only problem is release of locks in case of a rollback.
|
// Only problem is release of locks in case of a rollback.
|
||||||
|
c := ms.head()
|
||||||
|
|
||||||
|
// TODO(fabxc): this is a race. The meta must be locked.
|
||||||
|
// Just drop out-of-bounds sample for now – support for multiple
|
||||||
|
// appendable heads needed.
|
||||||
|
if !a.inBounds(t) {
|
||||||
|
// return ErrOutOfBounds
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if t < c.maxTime {
|
if t < c.maxTime {
|
||||||
return ErrOutOfOrderSample
|
return ErrOutOfOrderSample
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue