diff --git a/CHANGELOG.md b/CHANGELOG.md index 468854d9e3..05bce7334a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## unreleased +* [CHANGE] Make setting out-of-order native histograms feature (`--enable-feature=ooo-native-histograms`) a no-op. Out-of-order native histograms are now always enabled when `out_of_order_time_window` is greater than zero and `--enable-feature=native-histograms` is set. #16207 * [BUGFIX] TSDB: fix unknown series errors and possible lost data during WAL replay when series are removed from the head due to inactivity and reappear before the next WAL checkpoint. #16060 ## 3.2.1 / 2025-02-25 diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index 347bae470c..0e9d7c1d78 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -257,8 +257,7 @@ func (c *flagConfig) setFeatureListOptions(logger *slog.Logger) error { config.DefaultGlobalConfig.ScrapeProtocols = config.DefaultProtoFirstScrapeProtocols logger.Info("Experimental native histogram support enabled. Changed default scrape_protocols to prefer PrometheusProto format.", "global.scrape_protocols", fmt.Sprintf("%v", config.DefaultGlobalConfig.ScrapeProtocols)) case "ooo-native-histograms": - c.tsdb.EnableOOONativeHistograms = true - logger.Info("Experimental out-of-order native histogram ingestion enabled. This will only take effect if OutOfOrderTimeWindow is > 0 and if EnableNativeHistograms = true") + logger.Warn("This option for --enable-feature is now permanently enabled and therefore a no-op.", "option", o) case "created-timestamp-zero-ingestion": c.scrape.EnableCreatedTimestampZeroIngestion = true c.web.CTZeroIngestionEnabled = true @@ -1817,7 +1816,6 @@ type tsdbOptions struct { EnableDelayedCompaction bool CompactionDelayMaxPercent int EnableOverlappingCompaction bool - EnableOOONativeHistograms bool } func (opts tsdbOptions) ToTSDBOptions() tsdb.Options { @@ -1837,7 +1835,6 @@ func (opts tsdbOptions) ToTSDBOptions() tsdb.Options { MaxExemplars: opts.MaxExemplars, EnableMemorySnapshotOnShutdown: opts.EnableMemorySnapshotOnShutdown, EnableNativeHistograms: opts.EnableNativeHistograms, - EnableOOONativeHistograms: opts.EnableOOONativeHistograms, OutOfOrderTimeWindow: opts.OutOfOrderTimeWindow, EnableDelayedCompaction: opts.EnableDelayedCompaction, CompactionDelayMaxPercent: opts.CompactionDelayMaxPercent, diff --git a/storage/interface.go b/storage/interface.go index 32b90cc10a..3562802495 100644 --- a/storage/interface.go +++ b/storage/interface.go @@ -43,7 +43,6 @@ var ( ErrExemplarLabelLength = fmt.Errorf("label length for exemplar exceeds maximum of %d UTF-8 characters", exemplar.ExemplarMaxLabelSetLength) ErrExemplarsDisabled = errors.New("exemplar storage is disabled or max exemplars is less than or equal to 0") ErrNativeHistogramsDisabled = errors.New("native histograms are disabled") - ErrOOONativeHistogramsDisabled = errors.New("out-of-order native histogram ingestion is disabled") // ErrOutOfOrderCT indicates failed append of CT to the storage // due to CT being older the then newer sample. diff --git a/tsdb/db.go b/tsdb/db.go index ff24c8800b..1809499855 100644 --- a/tsdb/db.go +++ b/tsdb/db.go @@ -179,12 +179,6 @@ type Options struct { // EnableNativeHistograms enables the ingestion of native histograms. EnableNativeHistograms bool - // EnableOOONativeHistograms enables the ingestion of OOO native histograms. - // It will only take effect if EnableNativeHistograms is set to true and the - // OutOfOrderTimeWindow is > 0. This flag will be removed after testing of - // OOO Native Histogram ingestion is complete. - EnableOOONativeHistograms bool - // OutOfOrderTimeWindow specifies how much out of order is allowed, if any. // This can change during run-time, so this value from here should only be used // while initialising. @@ -967,7 +961,6 @@ func open(dir string, l *slog.Logger, r prometheus.Registerer, opts *Options, rn headOpts.MaxExemplars.Store(opts.MaxExemplars) headOpts.EnableMemorySnapshotOnShutdown = opts.EnableMemorySnapshotOnShutdown headOpts.EnableNativeHistograms.Store(opts.EnableNativeHistograms) - headOpts.EnableOOONativeHistograms.Store(opts.EnableOOONativeHistograms) headOpts.OutOfOrderTimeWindow.Store(opts.OutOfOrderTimeWindow) headOpts.OutOfOrderCapMax.Store(opts.OutOfOrderCapMax) headOpts.EnableSharding = opts.EnableSharding @@ -1197,16 +1190,6 @@ func (db *DB) DisableNativeHistograms() { db.head.DisableNativeHistograms() } -// EnableOOONativeHistograms enables the ingestion of out-of-order native histograms. -func (db *DB) EnableOOONativeHistograms() { - db.head.EnableOOONativeHistograms() -} - -// DisableOOONativeHistograms disables the ingestion of out-of-order native histograms. -func (db *DB) DisableOOONativeHistograms() { - db.head.DisableOOONativeHistograms() -} - // dbAppender wraps the DB's head appender and triggers compactions on commit // if necessary. type dbAppender struct { diff --git a/tsdb/db_test.go b/tsdb/db_test.go index 4e96680c02..371079eb6b 100644 --- a/tsdb/db_test.go +++ b/tsdb/db_test.go @@ -4433,7 +4433,6 @@ func testOOOWALWrite(t *testing.T, db, err := Open(dir, nil, nil, opts, nil) require.NoError(t, err) db.EnableNativeHistograms() - db.EnableOOONativeHistograms() t.Cleanup(func() { require.NoError(t, db.Close()) @@ -4854,7 +4853,6 @@ func TestMultipleEncodingsCommitOrder(t *testing.T) { db := openTestDB(t, opts, nil) db.DisableCompactions() db.EnableNativeHistograms() - db.EnableOOONativeHistograms() defer func() { require.NoError(t, db.Close()) }() @@ -5015,7 +5013,6 @@ func testOOOCompaction(t *testing.T, scenario sampleTypeScenario, addExtraSample opts.OutOfOrderCapMax = 30 opts.OutOfOrderTimeWindow = 300 * time.Minute.Milliseconds() opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true db, err := Open(dir, nil, nil, opts, nil) require.NoError(t, err) @@ -5222,7 +5219,6 @@ func testOOOCompactionWithNormalCompaction(t *testing.T, scenario sampleTypeScen require.NoError(t, err) db.DisableCompactions() // We want to manually call it. db.EnableNativeHistograms() - db.EnableOOONativeHistograms() t.Cleanup(func() { require.NoError(t, db.Close()) }) @@ -5329,13 +5325,11 @@ func testOOOCompactionWithDisabledWriteLog(t *testing.T, scenario sampleTypeScen opts.OutOfOrderTimeWindow = 300 * time.Minute.Milliseconds() opts.WALSegmentSize = -1 // disabled WAL and WBL opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true db, err := Open(dir, nil, nil, opts, nil) require.NoError(t, err) db.DisableCompactions() // We want to manually call it. db.EnableNativeHistograms() - db.EnableOOONativeHistograms() t.Cleanup(func() { require.NoError(t, db.Close()) }) @@ -5442,7 +5436,6 @@ func testOOOQueryAfterRestartWithSnapshotAndRemovedWBL(t *testing.T, scenario sa opts.OutOfOrderTimeWindow = 300 * time.Minute.Milliseconds() opts.EnableMemorySnapshotOnShutdown = true opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true db, err := Open(dir, nil, nil, opts, nil) require.NoError(t, err) @@ -5808,7 +5801,6 @@ func testQuerierOOOQuery(t *testing.T, db := openTestDB(t, opts, nil) db.DisableCompactions() db.EnableNativeHistograms() - db.EnableOOONativeHistograms() defer func() { require.NoError(t, db.Close()) }() @@ -6139,7 +6131,6 @@ func testChunkQuerierOOOQuery(t *testing.T, db := openTestDB(t, opts, nil) db.DisableCompactions() db.EnableNativeHistograms() - db.EnableOOONativeHistograms() defer func() { require.NoError(t, db.Close()) }() @@ -6320,7 +6311,6 @@ func testOOONativeHistogramsWithCounterResets(t *testing.T, scenario sampleTypeS t.Run(fmt.Sprintf("name=%s", tc.name), func(t *testing.T) { db := openTestDB(t, opts, nil) db.DisableCompactions() - db.EnableOOONativeHistograms() defer func() { require.NoError(t, db.Close()) }() @@ -6558,7 +6548,6 @@ func testOOOInterleavedImplicitCounterResets(t *testing.T, name string, scenario db := openTestDB(t, opts, nil) db.DisableCompactions() - db.EnableOOONativeHistograms() defer func() { require.NoError(t, db.Close()) }() @@ -6661,7 +6650,6 @@ func testOOOAppendAndQuery(t *testing.T, scenario sampleTypeScenario) { db := openTestDB(t, opts, nil) db.DisableCompactions() db.EnableNativeHistograms() - db.EnableOOONativeHistograms() t.Cleanup(func() { require.NoError(t, db.Close()) }) @@ -6794,7 +6782,6 @@ func testOOODisabled(t *testing.T, scenario sampleTypeScenario) { db := openTestDB(t, opts, nil) db.DisableCompactions() db.EnableNativeHistograms() - db.EnableOOONativeHistograms() t.Cleanup(func() { require.NoError(t, db.Close()) }) @@ -6868,7 +6855,6 @@ func testWBLAndMmapReplay(t *testing.T, scenario sampleTypeScenario) { opts.OutOfOrderCapMax = 30 opts.OutOfOrderTimeWindow = 4 * time.Hour.Milliseconds() opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true db := openTestDB(t, opts, nil) db.DisableCompactions() @@ -7062,7 +7048,6 @@ func TestOOOHistogramCompactionWithCounterResets(t *testing.T) { require.NoError(t, err) db.DisableCompactions() // We want to manually call it. db.EnableNativeHistograms() - db.EnableOOONativeHistograms() t.Cleanup(func() { require.NoError(t, db.Close()) }) @@ -7424,7 +7409,6 @@ func TestInterleavedInOrderAndOOOHistogramCompactionWithCounterResets(t *testing require.NoError(t, err) db.DisableCompactions() // We want to manually call it. db.EnableNativeHistograms() - db.EnableOOONativeHistograms() t.Cleanup(func() { require.NoError(t, db.Close()) }) @@ -7540,7 +7524,6 @@ func testOOOCompactionFailure(t *testing.T, scenario sampleTypeScenario) { require.NoError(t, err) db.DisableCompactions() // We want to manually call it. db.EnableNativeHistograms() - db.EnableOOONativeHistograms() t.Cleanup(func() { require.NoError(t, db.Close()) }) @@ -7829,7 +7812,6 @@ func testOOOMmapCorruption(t *testing.T, scenario sampleTypeScenario) { opts.OutOfOrderCapMax = 10 opts.OutOfOrderTimeWindow = 300 * time.Minute.Milliseconds() opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true db, err := Open(dir, nil, nil, opts, nil) require.NoError(t, err) @@ -7964,7 +7946,6 @@ func testOutOfOrderRuntimeConfig(t *testing.T, scenario sampleTypeScenario) { opts := DefaultOptions() opts.OutOfOrderTimeWindow = oooTimeWindow opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true db, err := Open(dir, nil, nil, opts, nil) require.NoError(t, err) @@ -8259,7 +8240,6 @@ func testNoGapAfterRestartWithOOO(t *testing.T, scenario sampleTypeScenario) { opts := DefaultOptions() opts.OutOfOrderTimeWindow = 30 * time.Minute.Milliseconds() opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true db, err := Open(dir, nil, nil, opts, nil) require.NoError(t, err) @@ -8319,7 +8299,6 @@ func testWblReplayAfterOOODisableAndRestart(t *testing.T, scenario sampleTypeSce opts := DefaultOptions() opts.OutOfOrderTimeWindow = 60 * time.Minute.Milliseconds() opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true db, err := Open(dir, nil, nil, opts, nil) require.NoError(t, err) @@ -8388,7 +8367,6 @@ func testPanicOnApplyConfig(t *testing.T, scenario sampleTypeScenario) { opts := DefaultOptions() opts.OutOfOrderTimeWindow = 60 * time.Minute.Milliseconds() opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true db, err := Open(dir, nil, nil, opts, nil) require.NoError(t, err) @@ -8447,7 +8425,6 @@ func testDiskFillingUpAfterDisablingOOO(t *testing.T, scenario sampleTypeScenari opts := DefaultOptions() opts.OutOfOrderTimeWindow = 60 * time.Minute.Milliseconds() opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true db, err := Open(dir, nil, nil, opts, nil) require.NoError(t, err) @@ -8989,7 +8966,7 @@ func TestNativeHistogramFlag(t *testing.T) { }, act) } -func TestOOONativeHistogramFlag(t *testing.T) { +func TestOOONativeHistogramsSettings(t *testing.T) { h := &histogram.Histogram{ Count: 9, ZeroCount: 4, @@ -9005,7 +8982,7 @@ func TestOOONativeHistogramFlag(t *testing.T) { l := labels.FromStrings("foo", "bar") - t.Run("Test OOO native histograms if OOO is disabled", func(t *testing.T) { + t.Run("Test OOO native histograms if OOO is disabled and Native Histograms is enabled", func(t *testing.T) { opts := DefaultOptions() opts.OutOfOrderTimeWindow = 0 db := openTestDB(t, opts, []int64{100}) @@ -9013,9 +8990,7 @@ func TestOOONativeHistogramFlag(t *testing.T) { require.NoError(t, db.Close()) }() - // Enable Native Histograms and OOO Native Histogram ingestion db.EnableNativeHistograms() - db.EnableOOONativeHistograms() app := db.Appender(context.Background()) _, err := app.AppendHistogram(0, l, 100, h, nil) @@ -9033,7 +9008,7 @@ func TestOOONativeHistogramFlag(t *testing.T) { l.String(): {sample{t: 100, h: h}}, }, act) }) - t.Run("Test OOO Native Histograms if Native Histograms are disabled", func(t *testing.T) { + t.Run("Test OOO Native Histograms if OOO is enabled and Native Histograms are disabled", func(t *testing.T) { opts := DefaultOptions() opts.OutOfOrderTimeWindow = 100 db := openTestDB(t, opts, []int64{100}) @@ -9041,9 +9016,7 @@ func TestOOONativeHistogramFlag(t *testing.T) { require.NoError(t, db.Close()) }() - // Disable Native Histograms and enable OOO Native Histogram ingestion db.DisableNativeHistograms() - db.EnableOOONativeHistograms() // Attempt to add an in-order sample app := db.Appender(context.Background()) @@ -9061,7 +9034,7 @@ func TestOOONativeHistogramFlag(t *testing.T) { act := query(t, q, labels.MustNewMatcher(labels.MatchEqual, "foo", "bar")) require.Equal(t, map[string][]chunks.Sample{}, act) }) - t.Run("Test OOO native histograms when flag is enabled", func(t *testing.T) { + t.Run("Test OOO native histograms when both OOO and Native Histograms are enabled", func(t *testing.T) { opts := DefaultOptions() opts.OutOfOrderTimeWindow = 100 db := openTestDB(t, opts, []int64{100}) @@ -9069,9 +9042,7 @@ func TestOOONativeHistogramFlag(t *testing.T) { require.NoError(t, db.Close()) }() - // Enable Native Histograms and OOO Native Histogram ingestion db.EnableNativeHistograms() - db.EnableOOONativeHistograms() // Add in-order samples app := db.Appender(context.Background()) diff --git a/tsdb/head.go b/tsdb/head.go index 724437f453..08bac79ca1 100644 --- a/tsdb/head.go +++ b/tsdb/head.go @@ -160,11 +160,6 @@ type HeadOptions struct { // EnableNativeHistograms enables the ingestion of native histograms. EnableNativeHistograms atomic.Bool - // EnableOOONativeHistograms enables the ingestion of OOO native histograms. - // It will only take effect if EnableNativeHistograms is set to true and the - // OutOfOrderTimeWindow is > 0 - EnableOOONativeHistograms atomic.Bool - ChunkRange int64 // ChunkDirRoot is the parent directory of the chunks directory. ChunkDirRoot string @@ -1041,16 +1036,6 @@ func (h *Head) DisableNativeHistograms() { h.opts.EnableNativeHistograms.Store(false) } -// EnableOOONativeHistograms enables the ingestion of out-of-order native histograms. -func (h *Head) EnableOOONativeHistograms() { - h.opts.EnableOOONativeHistograms.Store(true) -} - -// DisableOOONativeHistograms disables the ingestion of out-of-order native histograms. -func (h *Head) DisableOOONativeHistograms() { - h.opts.EnableOOONativeHistograms.Store(false) -} - // PostingsCardinalityStats returns highest cardinality stats by label and value names. func (h *Head) PostingsCardinalityStats(statsByLabelName string, limit int) *index.PostingsStats { cacheKey := statsByLabelName + ";" + strconv.Itoa(limit) diff --git a/tsdb/head_append.go b/tsdb/head_append.go index c94c42bc53..322ff65022 100644 --- a/tsdb/head_append.go +++ b/tsdb/head_append.go @@ -523,7 +523,7 @@ func (s *memSeries) appendable(t int64, v float64, headMaxt, minValidTime, oooTi // appendableHistogram checks whether the given histogram sample is valid for appending to the series. (if we return false and no error) // The sample belongs to the out of order chunk if we return true and no error. // An error signifies the sample cannot be handled. -func (s *memSeries) appendableHistogram(t int64, h *histogram.Histogram, headMaxt, minValidTime, oooTimeWindow int64, oooHistogramsEnabled bool) (isOOO bool, oooDelta int64, err error) { +func (s *memSeries) appendableHistogram(t int64, h *histogram.Histogram, headMaxt, minValidTime, oooTimeWindow int64) (isOOO bool, oooDelta int64, err error) { // Check if we can append in the in-order chunk. if t >= minValidTime { if s.headChunks == nil { @@ -549,9 +549,6 @@ func (s *memSeries) appendableHistogram(t int64, h *histogram.Histogram, headMax // 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 { - if !oooHistogramsEnabled { - return true, headMaxt - t, storage.ErrOOONativeHistogramsDisabled - } return true, headMaxt - t, nil } @@ -568,7 +565,7 @@ func (s *memSeries) appendableHistogram(t int64, h *histogram.Histogram, headMax // appendableFloatHistogram checks whether the given float histogram sample is valid for appending to the series. (if we return false and no error) // The sample belongs to the out of order chunk if we return true and no error. // An error signifies the sample cannot be handled. -func (s *memSeries) appendableFloatHistogram(t int64, fh *histogram.FloatHistogram, headMaxt, minValidTime, oooTimeWindow int64, oooHistogramsEnabled bool) (isOOO bool, oooDelta int64, err error) { +func (s *memSeries) appendableFloatHistogram(t int64, fh *histogram.FloatHistogram, headMaxt, minValidTime, oooTimeWindow int64) (isOOO bool, oooDelta int64, err error) { // Check if we can append in the in-order chunk. if t >= minValidTime { if s.headChunks == nil { @@ -594,9 +591,6 @@ func (s *memSeries) appendableFloatHistogram(t int64, fh *histogram.FloatHistogr // 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 { - if !oooHistogramsEnabled { - return true, headMaxt - t, storage.ErrOOONativeHistogramsDisabled - } return true, headMaxt - t, nil } @@ -654,7 +648,7 @@ func (a *headAppender) AppendHistogram(ref storage.SeriesRef, lset labels.Labels // Fail fast if OOO is disabled and the sample is out of bounds. // Otherwise a full check will be done later to decide if the sample is in-order or out-of-order. - if (a.oooTimeWindow == 0 || !a.head.opts.EnableOOONativeHistograms.Load()) && t < a.minValidTime { + if a.oooTimeWindow == 0 && t < a.minValidTime { a.head.metrics.outOfBoundSamples.WithLabelValues(sampleMetricTypeHistogram).Inc() return 0, storage.ErrOutOfBounds } @@ -694,7 +688,7 @@ func (a *headAppender) AppendHistogram(ref storage.SeriesRef, lset labels.Labels // TODO(codesome): If we definitely know at this point that the sample is ooo, then optimise // to skip that sample from the WAL and write only in the WBL. - _, delta, err := s.appendableHistogram(t, h, a.headMaxt, a.minValidTime, a.oooTimeWindow, a.head.opts.EnableOOONativeHistograms.Load()) + _, delta, err := s.appendableHistogram(t, h, a.headMaxt, a.minValidTime, a.oooTimeWindow) if err != nil { s.pendingCommit = true } @@ -705,8 +699,6 @@ func (a *headAppender) AppendHistogram(ref storage.SeriesRef, lset labels.Labels if err != nil { switch { case errors.Is(err, storage.ErrOutOfOrderSample): - fallthrough - case errors.Is(err, storage.ErrOOONativeHistogramsDisabled): a.head.metrics.outOfOrderSamples.WithLabelValues(sampleMetricTypeHistogram).Inc() case errors.Is(err, storage.ErrTooOldSample): a.head.metrics.tooOldSamples.WithLabelValues(sampleMetricTypeHistogram).Inc() @@ -731,7 +723,7 @@ func (a *headAppender) AppendHistogram(ref storage.SeriesRef, lset labels.Labels // TODO(codesome): If we definitely know at this point that the sample is ooo, then optimise // to skip that sample from the WAL and write only in the WBL. - _, delta, err := s.appendableFloatHistogram(t, fh, a.headMaxt, a.minValidTime, a.oooTimeWindow, a.head.opts.EnableOOONativeHistograms.Load()) + _, delta, err := s.appendableFloatHistogram(t, fh, a.headMaxt, a.minValidTime, a.oooTimeWindow) if err == nil { s.pendingCommit = true } @@ -742,8 +734,6 @@ func (a *headAppender) AppendHistogram(ref storage.SeriesRef, lset labels.Labels if err != nil { switch { case errors.Is(err, storage.ErrOutOfOrderSample): - fallthrough - case errors.Is(err, storage.ErrOOONativeHistogramsDisabled): a.head.metrics.outOfOrderSamples.WithLabelValues(sampleMetricTypeHistogram).Inc() case errors.Is(err, storage.ErrTooOldSample): a.head.metrics.tooOldSamples.WithLabelValues(sampleMetricTypeHistogram).Inc() @@ -799,9 +789,9 @@ func (a *headAppender) AppendHistogramCTZeroSample(ref storage.SeriesRef, lset l s.lastHistogramValue = zeroHistogram } - // Although we call `appendableHistogram` with oooHistogramsEnabled=true, for CTZeroSamples OOO is not allowed. + // For CTZeroSamples OOO is not allowed. // We set it to true to make this implementation as close as possible to the float implementation. - isOOO, _, err := s.appendableHistogram(ct, zeroHistogram, a.headMaxt, a.minValidTime, a.oooTimeWindow, true) + isOOO, _, err := s.appendableHistogram(ct, zeroHistogram, a.headMaxt, a.minValidTime, a.oooTimeWindow) if err != nil { s.Unlock() if errors.Is(err, storage.ErrOutOfOrderSample) { @@ -833,9 +823,8 @@ func (a *headAppender) AppendHistogramCTZeroSample(ref storage.SeriesRef, lset l s.lastFloatHistogramValue = zeroFloatHistogram } - // Although we call `appendableFloatHistogram` with oooHistogramsEnabled=true, for CTZeroSamples OOO is not allowed. // We set it to true to make this implementation as close as possible to the float implementation. - isOOO, _, err := s.appendableFloatHistogram(ct, zeroFloatHistogram, a.headMaxt, a.minValidTime, a.oooTimeWindow, true) // OOO is not allowed for CTZeroSamples. + isOOO, _, err := s.appendableFloatHistogram(ct, zeroFloatHistogram, a.headMaxt, a.minValidTime, a.oooTimeWindow) // OOO is not allowed for CTZeroSamples. if err != nil { s.Unlock() if errors.Is(err, storage.ErrOutOfOrderSample) { @@ -1256,7 +1245,7 @@ func (a *headAppender) commitHistograms(acc *appenderCommitContext) { series = a.histogramSeries[i] series.Lock() - oooSample, _, err := series.appendableHistogram(s.T, s.H, a.headMaxt, a.minValidTime, a.oooTimeWindow, a.head.opts.EnableOOONativeHistograms.Load()) + oooSample, _, err := series.appendableHistogram(s.T, s.H, a.headMaxt, a.minValidTime, a.oooTimeWindow) if err != nil { handleAppendableError(err, &acc.histogramsAppended, &acc.histoOOORejected, &acc.histoOOBRejected, &acc.histoTooOldRejected) } @@ -1344,7 +1333,7 @@ func (a *headAppender) commitFloatHistograms(acc *appenderCommitContext) { series = a.floatHistogramSeries[i] series.Lock() - oooSample, _, err := series.appendableFloatHistogram(s.T, s.FH, a.headMaxt, a.minValidTime, a.oooTimeWindow, a.head.opts.EnableOOONativeHistograms.Load()) + oooSample, _, err := series.appendableFloatHistogram(s.T, s.FH, a.headMaxt, a.minValidTime, a.oooTimeWindow) if err != nil { handleAppendableError(err, &acc.histogramsAppended, &acc.histoOOORejected, &acc.histoOOBRejected, &acc.histoTooOldRejected) } diff --git a/tsdb/head_test.go b/tsdb/head_test.go index 161ead50b4..25616654c9 100644 --- a/tsdb/head_test.go +++ b/tsdb/head_test.go @@ -2829,7 +2829,6 @@ func TestOutOfOrderSamplesMetric(t *testing.T) { t.Run(name, func(t *testing.T) { options := DefaultOptions() options.EnableNativeHistograms = true - options.EnableOOONativeHistograms = true testOutOfOrderSamplesMetric(t, scenario, options, storage.ErrOutOfOrderSample) }) } @@ -2842,10 +2841,9 @@ func TestOutOfOrderSamplesMetricNativeHistogramOOODisabled(t *testing.T) { } t.Run(name, func(t *testing.T) { options := DefaultOptions() - options.OutOfOrderTimeWindow = (1000 * time.Minute).Milliseconds() + options.OutOfOrderTimeWindow = 0 options.EnableNativeHistograms = true - options.EnableOOONativeHistograms = false - testOutOfOrderSamplesMetric(t, scenario, options, storage.ErrOOONativeHistogramsDisabled) + testOutOfOrderSamplesMetric(t, scenario, options, storage.ErrOutOfOrderSample) }) } } @@ -4784,7 +4782,6 @@ func TestOOOHistogramCounterResetHeaders(t *testing.T) { l := labels.FromStrings("a", "b") head, _ := newTestHead(t, 1000, compression.None, true) head.opts.OutOfOrderCapMax.Store(5) - head.opts.EnableOOONativeHistograms.Store(true) t.Cleanup(func() { require.NoError(t, head.Close()) @@ -4943,7 +4940,6 @@ func TestAppendingDifferentEncodingToSameSeries(t *testing.T) { dir := t.TempDir() opts := DefaultOptions() opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true db, err := Open(dir, nil, nil, opts, nil) require.NoError(t, err) t.Cleanup(func() { @@ -5215,7 +5211,6 @@ func testWBLReplay(t *testing.T, scenario sampleTypeScenario) { opts.ChunkDirRoot = dir opts.OutOfOrderTimeWindow.Store(30 * time.Minute.Milliseconds()) opts.EnableNativeHistograms.Store(true) - opts.EnableOOONativeHistograms.Store(true) h, err := NewHead(nil, nil, wal, oooWlog, opts, nil) require.NoError(t, err) @@ -5310,7 +5305,6 @@ func testOOOMmapReplay(t *testing.T, scenario sampleTypeScenario) { opts.OutOfOrderCapMax.Store(30) opts.OutOfOrderTimeWindow.Store(1000 * time.Minute.Milliseconds()) opts.EnableNativeHistograms.Store(true) - opts.EnableOOONativeHistograms.Store(true) h, err := NewHead(nil, nil, wal, oooWlog, opts, nil) require.NoError(t, err) @@ -5613,7 +5607,6 @@ func testOOOAppendWithNoSeries(t *testing.T, appendFunc func(appender storage.Ap opts.OutOfOrderCapMax.Store(30) opts.OutOfOrderTimeWindow.Store(120 * time.Minute.Milliseconds()) opts.EnableNativeHistograms.Store(true) - opts.EnableOOONativeHistograms.Store(true) h, err := NewHead(nil, nil, wal, oooWlog, opts, nil) require.NoError(t, err) @@ -5705,7 +5698,6 @@ func testHeadMinOOOTimeUpdate(t *testing.T, scenario sampleTypeScenario) { opts.ChunkDirRoot = dir opts.OutOfOrderTimeWindow.Store(10 * time.Minute.Milliseconds()) opts.EnableNativeHistograms.Store(true) - opts.EnableOOONativeHistograms.Store(true) h, err := NewHead(nil, nil, wal, oooWlog, opts, nil) require.NoError(t, err) diff --git a/tsdb/ooo_head_read_test.go b/tsdb/ooo_head_read_test.go index 92bc6d6f28..d2c490f221 100644 --- a/tsdb/ooo_head_read_test.go +++ b/tsdb/ooo_head_read_test.go @@ -389,7 +389,6 @@ func TestOOOHeadChunkReader_LabelValues(t *testing.T) { func testOOOHeadChunkReader_LabelValues(t *testing.T, scenario sampleTypeScenario) { chunkRange := int64(2000) head, _ := newTestHead(t, chunkRange, compression.None, true) - head.opts.EnableOOONativeHistograms.Store(true) t.Cleanup(func() { require.NoError(t, head.Close()) }) ctx := context.Background() @@ -495,7 +494,6 @@ func testOOOHeadChunkReader_Chunk(t *testing.T, scenario sampleTypeScenario) { opts.OutOfOrderCapMax = 5 opts.OutOfOrderTimeWindow = 120 * time.Minute.Milliseconds() opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true s1 := labels.FromStrings("l", "v1") minutes := func(m int64) int64 { return m * time.Minute.Milliseconds() } @@ -906,7 +904,6 @@ func testOOOHeadChunkReader_Chunk_ConsistentQueryResponseDespiteOfHeadExpanding( opts.OutOfOrderCapMax = 5 opts.OutOfOrderTimeWindow = 120 * time.Minute.Milliseconds() opts.EnableNativeHistograms = true - opts.EnableOOONativeHistograms = true s1 := labels.FromStrings("l", "v1") minutes := func(m int64) int64 { return m * time.Minute.Milliseconds() } diff --git a/tsdb/querier_test.go b/tsdb/querier_test.go index 5b1bcef7c2..f55d57cc79 100644 --- a/tsdb/querier_test.go +++ b/tsdb/querier_test.go @@ -1507,8 +1507,6 @@ func TestPopulateWithTombSeriesIterators(t *testing.T) { expectedMinMaxTimes: []minMaxTimes{{7, 12}, {11, 16}, {10, 203}}, }, { - // This case won't actually happen until OOO native histograms is implemented. - // Issue: https://github.com/prometheus/prometheus/issues/11220. name: "int histogram iterables with counter resets", samples: [][]chunks.Sample{ { @@ -1578,8 +1576,6 @@ func TestPopulateWithTombSeriesIterators(t *testing.T) { skipChunkTest: true, }, { - // This case won't actually happen until OOO native histograms is implemented. - // Issue: https://github.com/prometheus/prometheus/issues/11220. name: "float histogram iterables with counter resets", samples: [][]chunks.Sample{ { @@ -1649,8 +1645,6 @@ func TestPopulateWithTombSeriesIterators(t *testing.T) { skipChunkTest: true, }, { - // This case won't actually happen until OOO native histograms is implemented. - // Issue: https://github.com/prometheus/prometheus/issues/11220. name: "iterables with mixed encodings and counter resets", samples: [][]chunks.Sample{ {