Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
handle duplicate datapoints in a consistent manner
Browse files Browse the repository at this point in the history
fixes #1201

Without the reorder_buffer, MT only persists the first value received for each timestamp. With the re-order buffer we should do the same.
  • Loading branch information
woodsaj committed Apr 10, 2019
1 parent 9574fea commit 03a8277
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mdata/reorder_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func (rob *ReorderBuffer) Add(ts uint32, val float64) ([]schema.Point, bool) {
var res []schema.Point
oldest := (rob.newest + 1) % uint32(cap(rob.buf))
index := (ts / rob.interval) % uint32(cap(rob.buf))
if rob.buf[index].Ts == ts {
// duplicate datapoint received.
metricsTooOld.Inc()
return nil, false
}
if ts > rob.buf[rob.newest].Ts {
flushCount := (ts - rob.buf[rob.newest].Ts) / rob.interval
if flushCount > uint32(cap(rob.buf)) {
Expand Down

0 comments on commit 03a8277

Please sign in to comment.