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

Commit 03a8277

Browse files
authored
handle duplicate datapoints in a consistent manner
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.
1 parent 9574fea commit 03a8277

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mdata/reorder_buffer.go

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ func (rob *ReorderBuffer) Add(ts uint32, val float64) ([]schema.Point, bool) {
3939
var res []schema.Point
4040
oldest := (rob.newest + 1) % uint32(cap(rob.buf))
4141
index := (ts / rob.interval) % uint32(cap(rob.buf))
42+
if rob.buf[index].Ts == ts {
43+
// duplicate datapoint received.
44+
metricsTooOld.Inc()
45+
return nil, false
46+
}
4247
if ts > rob.buf[rob.newest].Ts {
4348
flushCount := (ts - rob.buf[rob.newest].Ts) / rob.interval
4449
if flushCount > uint32(cap(rob.buf)) {

0 commit comments

Comments
 (0)