Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "TSDB: Always drop 'quiet zeros' if out-of-order" #789

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions tsdb/head_append.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,6 @@ func (s *memSeries) appendable(t int64, v float64, headMaxt, minValidTime, oooTi
}
}

if math.Float64bits(v) == value.QuietZeroNaN { // Say it's allowed; it will be dropped later in commitSamples.
return true, 0, nil
}

// The sample cannot go in the in-order chunk. Check if it can go in the out-of-order chunk.
if oooTimeWindow > 0 && t >= headMaxt-oooTimeWindow {
return true, headMaxt - t, nil
Expand Down Expand Up @@ -1145,11 +1141,13 @@ func (a *headAppender) commitSamples(acc *appenderCommitContext) {
handleAppendableError(err, &acc.floatsAppended, &acc.floatOOORejected, &acc.floatOOBRejected, &acc.floatTooOldRejected)
}

if math.Float64bits(s.V) == value.QuietZeroNaN {
s.V = 0
}

switch {
case err != nil:
// Do nothing here.
case oooSample && math.Float64bits(s.V) == value.QuietZeroNaN:
// No-op: we don't store quiet zeros out-of-order.
case oooSample:
// Sample is OOO and OOO handling is enabled
// and the delta is within the OOO tolerance.
Expand Down Expand Up @@ -1196,9 +1194,6 @@ func (a *headAppender) commitSamples(acc *appenderCommitContext) {
acc.floatsAppended--
}
default:
if math.Float64bits(s.V) == value.QuietZeroNaN {
s.V = 0
}
ok, chunkCreated = series.append(s.T, s.V, a.appendID, acc.appendChunkOpts)
if ok {
if s.T < acc.inOrderMint {
Expand Down
9 changes: 0 additions & 9 deletions tsdb/head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6123,15 +6123,6 @@ func TestAppendDuplicates(t *testing.T) {
sample{t: ts + 10, f: 0},
}
require.Equal(t, expectedSamples, result[`{foo="bar"}`])

a = h.Appender(context.Background())
_, err = a.Append(0, lbls, ts+5, math.Float64frombits(value.QuietZeroNaN)) // This is out-of-order, so should be dropped.
require.NoError(t, err)
require.NoError(t, a.Commit())

result, err = queryHead(t, h, math.MinInt64, math.MaxInt64, labels.Label{Name: "foo", Value: "bar"})
require.NoError(t, err)
require.Equal(t, expectedSamples, result[`{foo="bar"}`]) // Same expectedSamples as before.
}

// TestHeadDetectsDuplicateSampleAtSizeLimit tests a regression where a duplicate sample
Expand Down
Loading