Skip to content

Commit b02daec

Browse files
authored
Merge pull request #789 from grafana/revert-773-start-time-quiet-ooo
Revert "TSDB: Always drop 'quiet zeros' if out-of-order"
2 parents 2cb07a1 + 6302f97 commit b02daec

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

tsdb/head_append.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,6 @@ func (s *memSeries) appendable(t int64, v float64, headMaxt, minValidTime, oooTi
505505
}
506506
}
507507

508-
if math.Float64bits(v) == value.QuietZeroNaN { // Say it's allowed; it will be dropped later in commitSamples.
509-
return true, 0, nil
510-
}
511-
512508
// The sample cannot go in the in-order chunk. Check if it can go in the out-of-order chunk.
513509
if oooTimeWindow > 0 && t >= headMaxt-oooTimeWindow {
514510
return true, headMaxt - t, nil
@@ -1145,11 +1141,13 @@ func (a *headAppender) commitSamples(acc *appenderCommitContext) {
11451141
handleAppendableError(err, &acc.floatsAppended, &acc.floatOOORejected, &acc.floatOOBRejected, &acc.floatTooOldRejected)
11461142
}
11471143

1144+
if math.Float64bits(s.V) == value.QuietZeroNaN {
1145+
s.V = 0
1146+
}
1147+
11481148
switch {
11491149
case err != nil:
11501150
// Do nothing here.
1151-
case oooSample && math.Float64bits(s.V) == value.QuietZeroNaN:
1152-
// No-op: we don't store quiet zeros out-of-order.
11531151
case oooSample:
11541152
// Sample is OOO and OOO handling is enabled
11551153
// and the delta is within the OOO tolerance.
@@ -1196,9 +1194,6 @@ func (a *headAppender) commitSamples(acc *appenderCommitContext) {
11961194
acc.floatsAppended--
11971195
}
11981196
default:
1199-
if math.Float64bits(s.V) == value.QuietZeroNaN {
1200-
s.V = 0
1201-
}
12021197
ok, chunkCreated = series.append(s.T, s.V, a.appendID, acc.appendChunkOpts)
12031198
if ok {
12041199
if s.T < acc.inOrderMint {

tsdb/head_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -6123,15 +6123,6 @@ func TestAppendDuplicates(t *testing.T) {
61236123
sample{t: ts + 10, f: 0},
61246124
}
61256125
require.Equal(t, expectedSamples, result[`{foo="bar"}`])
6126-
6127-
a = h.Appender(context.Background())
6128-
_, err = a.Append(0, lbls, ts+5, math.Float64frombits(value.QuietZeroNaN)) // This is out-of-order, so should be dropped.
6129-
require.NoError(t, err)
6130-
require.NoError(t, a.Commit())
6131-
6132-
result, err = queryHead(t, h, math.MinInt64, math.MaxInt64, labels.Label{Name: "foo", Value: "bar"})
6133-
require.NoError(t, err)
6134-
require.Equal(t, expectedSamples, result[`{foo="bar"}`]) // Same expectedSamples as before.
61356126
}
61366127

61376128
// TestHeadDetectsDuplicateSampleAtSizeLimit tests a regression where a duplicate sample

0 commit comments

Comments
 (0)