Skip to content

Commit 37c2ebb

Browse files
fionaliaokrajorama
andauthoredMar 18, 2025
Make out-of-order native histograms flag a no-op and always enable (prometheus#16207)
* Remove experimental out-of-order native histogram flag This feature has been available in Prometheus since September 2024, and has no known issues. Therefore proposing to remove the flag entirely and always have it on. Note that there are still two settings that need to be configured (out-of-order time window > 0 and native histograms enabled) for this feature to work. Signed-off-by: Fiona Liao <fiona.liao@grafana.com> * Update CHANGELOG Signed-off-by: Fiona Liao <fiona.liao@grafana.com> * Keep feature flag with warning Signed-off-by: Fiona Liao <fiona.liao@grafana.com> * Update CHANGELOG Signed-off-by: Fiona Liao <fiona.liao@grafana.com> * Update tsdb/head_append.go Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com> Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com> * Update CHANGELOG.md Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com> Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com> * Update tsdb/head_append.go Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com> Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com> * Additional cleanup of comments and test names Signed-off-by: Fiona Liao <fiona.liao@grafana.com> --------- Signed-off-by: Fiona Liao <fiona.liao@grafana.com> Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com> Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com>
1 parent 6a439bd commit 37c2ebb

10 files changed

+18
-110
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## unreleased
44

5+
* [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
56
* [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
67

78
## 3.2.1 / 2025-02-25

‎cmd/prometheus/main.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ func (c *flagConfig) setFeatureListOptions(logger *slog.Logger) error {
257257
config.DefaultGlobalConfig.ScrapeProtocols = config.DefaultProtoFirstScrapeProtocols
258258
logger.Info("Experimental native histogram support enabled. Changed default scrape_protocols to prefer PrometheusProto format.", "global.scrape_protocols", fmt.Sprintf("%v", config.DefaultGlobalConfig.ScrapeProtocols))
259259
case "ooo-native-histograms":
260-
c.tsdb.EnableOOONativeHistograms = true
261-
logger.Info("Experimental out-of-order native histogram ingestion enabled. This will only take effect if OutOfOrderTimeWindow is > 0 and if EnableNativeHistograms = true")
260+
logger.Warn("This option for --enable-feature is now permanently enabled and therefore a no-op.", "option", o)
262261
case "created-timestamp-zero-ingestion":
263262
c.scrape.EnableCreatedTimestampZeroIngestion = true
264263
c.web.CTZeroIngestionEnabled = true
@@ -1817,7 +1816,6 @@ type tsdbOptions struct {
18171816
EnableDelayedCompaction bool
18181817
CompactionDelayMaxPercent int
18191818
EnableOverlappingCompaction bool
1820-
EnableOOONativeHistograms bool
18211819
}
18221820

18231821
func (opts tsdbOptions) ToTSDBOptions() tsdb.Options {
@@ -1837,7 +1835,6 @@ func (opts tsdbOptions) ToTSDBOptions() tsdb.Options {
18371835
MaxExemplars: opts.MaxExemplars,
18381836
EnableMemorySnapshotOnShutdown: opts.EnableMemorySnapshotOnShutdown,
18391837
EnableNativeHistograms: opts.EnableNativeHistograms,
1840-
EnableOOONativeHistograms: opts.EnableOOONativeHistograms,
18411838
OutOfOrderTimeWindow: opts.OutOfOrderTimeWindow,
18421839
EnableDelayedCompaction: opts.EnableDelayedCompaction,
18431840
CompactionDelayMaxPercent: opts.CompactionDelayMaxPercent,

‎storage/interface.go

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ var (
4343
ErrExemplarLabelLength = fmt.Errorf("label length for exemplar exceeds maximum of %d UTF-8 characters", exemplar.ExemplarMaxLabelSetLength)
4444
ErrExemplarsDisabled = errors.New("exemplar storage is disabled or max exemplars is less than or equal to 0")
4545
ErrNativeHistogramsDisabled = errors.New("native histograms are disabled")
46-
ErrOOONativeHistogramsDisabled = errors.New("out-of-order native histogram ingestion is disabled")
4746

4847
// ErrOutOfOrderCT indicates failed append of CT to the storage
4948
// due to CT being older the then newer sample.

‎tsdb/db.go

-17
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ type Options struct {
179179
// EnableNativeHistograms enables the ingestion of native histograms.
180180
EnableNativeHistograms bool
181181

182-
// EnableOOONativeHistograms enables the ingestion of OOO native histograms.
183-
// It will only take effect if EnableNativeHistograms is set to true and the
184-
// OutOfOrderTimeWindow is > 0. This flag will be removed after testing of
185-
// OOO Native Histogram ingestion is complete.
186-
EnableOOONativeHistograms bool
187-
188182
// OutOfOrderTimeWindow specifies how much out of order is allowed, if any.
189183
// This can change during run-time, so this value from here should only be used
190184
// while initialising.
@@ -967,7 +961,6 @@ func open(dir string, l *slog.Logger, r prometheus.Registerer, opts *Options, rn
967961
headOpts.MaxExemplars.Store(opts.MaxExemplars)
968962
headOpts.EnableMemorySnapshotOnShutdown = opts.EnableMemorySnapshotOnShutdown
969963
headOpts.EnableNativeHistograms.Store(opts.EnableNativeHistograms)
970-
headOpts.EnableOOONativeHistograms.Store(opts.EnableOOONativeHistograms)
971964
headOpts.OutOfOrderTimeWindow.Store(opts.OutOfOrderTimeWindow)
972965
headOpts.OutOfOrderCapMax.Store(opts.OutOfOrderCapMax)
973966
headOpts.EnableSharding = opts.EnableSharding
@@ -1197,16 +1190,6 @@ func (db *DB) DisableNativeHistograms() {
11971190
db.head.DisableNativeHistograms()
11981191
}
11991192

1200-
// EnableOOONativeHistograms enables the ingestion of out-of-order native histograms.
1201-
func (db *DB) EnableOOONativeHistograms() {
1202-
db.head.EnableOOONativeHistograms()
1203-
}
1204-
1205-
// DisableOOONativeHistograms disables the ingestion of out-of-order native histograms.
1206-
func (db *DB) DisableOOONativeHistograms() {
1207-
db.head.DisableOOONativeHistograms()
1208-
}
1209-
12101193
// dbAppender wraps the DB's head appender and triggers compactions on commit
12111194
// if necessary.
12121195
type dbAppender struct {

‎tsdb/db_test.go

+4-33
Original file line numberDiff line numberDiff line change
@@ -4433,7 +4433,6 @@ func testOOOWALWrite(t *testing.T,
44334433
db, err := Open(dir, nil, nil, opts, nil)
44344434
require.NoError(t, err)
44354435
db.EnableNativeHistograms()
4436-
db.EnableOOONativeHistograms()
44374436

44384437
t.Cleanup(func() {
44394438
require.NoError(t, db.Close())
@@ -4854,7 +4853,6 @@ func TestMultipleEncodingsCommitOrder(t *testing.T) {
48544853
db := openTestDB(t, opts, nil)
48554854
db.DisableCompactions()
48564855
db.EnableNativeHistograms()
4857-
db.EnableOOONativeHistograms()
48584856
defer func() {
48594857
require.NoError(t, db.Close())
48604858
}()
@@ -5015,7 +5013,6 @@ func testOOOCompaction(t *testing.T, scenario sampleTypeScenario, addExtraSample
50155013
opts.OutOfOrderCapMax = 30
50165014
opts.OutOfOrderTimeWindow = 300 * time.Minute.Milliseconds()
50175015
opts.EnableNativeHistograms = true
5018-
opts.EnableOOONativeHistograms = true
50195016

50205017
db, err := Open(dir, nil, nil, opts, nil)
50215018
require.NoError(t, err)
@@ -5222,7 +5219,6 @@ func testOOOCompactionWithNormalCompaction(t *testing.T, scenario sampleTypeScen
52225219
require.NoError(t, err)
52235220
db.DisableCompactions() // We want to manually call it.
52245221
db.EnableNativeHistograms()
5225-
db.EnableOOONativeHistograms()
52265222
t.Cleanup(func() {
52275223
require.NoError(t, db.Close())
52285224
})
@@ -5329,13 +5325,11 @@ func testOOOCompactionWithDisabledWriteLog(t *testing.T, scenario sampleTypeScen
53295325
opts.OutOfOrderTimeWindow = 300 * time.Minute.Milliseconds()
53305326
opts.WALSegmentSize = -1 // disabled WAL and WBL
53315327
opts.EnableNativeHistograms = true
5332-
opts.EnableOOONativeHistograms = true
53335328

53345329
db, err := Open(dir, nil, nil, opts, nil)
53355330
require.NoError(t, err)
53365331
db.DisableCompactions() // We want to manually call it.
53375332
db.EnableNativeHistograms()
5338-
db.EnableOOONativeHistograms()
53395333
t.Cleanup(func() {
53405334
require.NoError(t, db.Close())
53415335
})
@@ -5442,7 +5436,6 @@ func testOOOQueryAfterRestartWithSnapshotAndRemovedWBL(t *testing.T, scenario sa
54425436
opts.OutOfOrderTimeWindow = 300 * time.Minute.Milliseconds()
54435437
opts.EnableMemorySnapshotOnShutdown = true
54445438
opts.EnableNativeHistograms = true
5445-
opts.EnableOOONativeHistograms = true
54465439

54475440
db, err := Open(dir, nil, nil, opts, nil)
54485441
require.NoError(t, err)
@@ -5808,7 +5801,6 @@ func testQuerierOOOQuery(t *testing.T,
58085801
db := openTestDB(t, opts, nil)
58095802
db.DisableCompactions()
58105803
db.EnableNativeHistograms()
5811-
db.EnableOOONativeHistograms()
58125804
defer func() {
58135805
require.NoError(t, db.Close())
58145806
}()
@@ -6139,7 +6131,6 @@ func testChunkQuerierOOOQuery(t *testing.T,
61396131
db := openTestDB(t, opts, nil)
61406132
db.DisableCompactions()
61416133
db.EnableNativeHistograms()
6142-
db.EnableOOONativeHistograms()
61436134
defer func() {
61446135
require.NoError(t, db.Close())
61456136
}()
@@ -6320,7 +6311,6 @@ func testOOONativeHistogramsWithCounterResets(t *testing.T, scenario sampleTypeS
63206311
t.Run(fmt.Sprintf("name=%s", tc.name), func(t *testing.T) {
63216312
db := openTestDB(t, opts, nil)
63226313
db.DisableCompactions()
6323-
db.EnableOOONativeHistograms()
63246314
defer func() {
63256315
require.NoError(t, db.Close())
63266316
}()
@@ -6558,7 +6548,6 @@ func testOOOInterleavedImplicitCounterResets(t *testing.T, name string, scenario
65586548

65596549
db := openTestDB(t, opts, nil)
65606550
db.DisableCompactions()
6561-
db.EnableOOONativeHistograms()
65626551
defer func() {
65636552
require.NoError(t, db.Close())
65646553
}()
@@ -6661,7 +6650,6 @@ func testOOOAppendAndQuery(t *testing.T, scenario sampleTypeScenario) {
66616650
db := openTestDB(t, opts, nil)
66626651
db.DisableCompactions()
66636652
db.EnableNativeHistograms()
6664-
db.EnableOOONativeHistograms()
66656653
t.Cleanup(func() {
66666654
require.NoError(t, db.Close())
66676655
})
@@ -6794,7 +6782,6 @@ func testOOODisabled(t *testing.T, scenario sampleTypeScenario) {
67946782
db := openTestDB(t, opts, nil)
67956783
db.DisableCompactions()
67966784
db.EnableNativeHistograms()
6797-
db.EnableOOONativeHistograms()
67986785
t.Cleanup(func() {
67996786
require.NoError(t, db.Close())
68006787
})
@@ -6868,7 +6855,6 @@ func testWBLAndMmapReplay(t *testing.T, scenario sampleTypeScenario) {
68686855
opts.OutOfOrderCapMax = 30
68696856
opts.OutOfOrderTimeWindow = 4 * time.Hour.Milliseconds()
68706857
opts.EnableNativeHistograms = true
6871-
opts.EnableOOONativeHistograms = true
68726858

68736859
db := openTestDB(t, opts, nil)
68746860
db.DisableCompactions()
@@ -7062,7 +7048,6 @@ func TestOOOHistogramCompactionWithCounterResets(t *testing.T) {
70627048
require.NoError(t, err)
70637049
db.DisableCompactions() // We want to manually call it.
70647050
db.EnableNativeHistograms()
7065-
db.EnableOOONativeHistograms()
70667051
t.Cleanup(func() {
70677052
require.NoError(t, db.Close())
70687053
})
@@ -7424,7 +7409,6 @@ func TestInterleavedInOrderAndOOOHistogramCompactionWithCounterResets(t *testing
74247409
require.NoError(t, err)
74257410
db.DisableCompactions() // We want to manually call it.
74267411
db.EnableNativeHistograms()
7427-
db.EnableOOONativeHistograms()
74287412
t.Cleanup(func() {
74297413
require.NoError(t, db.Close())
74307414
})
@@ -7540,7 +7524,6 @@ func testOOOCompactionFailure(t *testing.T, scenario sampleTypeScenario) {
75407524
require.NoError(t, err)
75417525
db.DisableCompactions() // We want to manually call it.
75427526
db.EnableNativeHistograms()
7543-
db.EnableOOONativeHistograms()
75447527
t.Cleanup(func() {
75457528
require.NoError(t, db.Close())
75467529
})
@@ -7829,7 +7812,6 @@ func testOOOMmapCorruption(t *testing.T, scenario sampleTypeScenario) {
78297812
opts.OutOfOrderCapMax = 10
78307813
opts.OutOfOrderTimeWindow = 300 * time.Minute.Milliseconds()
78317814
opts.EnableNativeHistograms = true
7832-
opts.EnableOOONativeHistograms = true
78337815

78347816
db, err := Open(dir, nil, nil, opts, nil)
78357817
require.NoError(t, err)
@@ -7964,7 +7946,6 @@ func testOutOfOrderRuntimeConfig(t *testing.T, scenario sampleTypeScenario) {
79647946
opts := DefaultOptions()
79657947
opts.OutOfOrderTimeWindow = oooTimeWindow
79667948
opts.EnableNativeHistograms = true
7967-
opts.EnableOOONativeHistograms = true
79687949

79697950
db, err := Open(dir, nil, nil, opts, nil)
79707951
require.NoError(t, err)
@@ -8259,7 +8240,6 @@ func testNoGapAfterRestartWithOOO(t *testing.T, scenario sampleTypeScenario) {
82598240
opts := DefaultOptions()
82608241
opts.OutOfOrderTimeWindow = 30 * time.Minute.Milliseconds()
82618242
opts.EnableNativeHistograms = true
8262-
opts.EnableOOONativeHistograms = true
82638243

82648244
db, err := Open(dir, nil, nil, opts, nil)
82658245
require.NoError(t, err)
@@ -8319,7 +8299,6 @@ func testWblReplayAfterOOODisableAndRestart(t *testing.T, scenario sampleTypeSce
83198299
opts := DefaultOptions()
83208300
opts.OutOfOrderTimeWindow = 60 * time.Minute.Milliseconds()
83218301
opts.EnableNativeHistograms = true
8322-
opts.EnableOOONativeHistograms = true
83238302

83248303
db, err := Open(dir, nil, nil, opts, nil)
83258304
require.NoError(t, err)
@@ -8388,7 +8367,6 @@ func testPanicOnApplyConfig(t *testing.T, scenario sampleTypeScenario) {
83888367
opts := DefaultOptions()
83898368
opts.OutOfOrderTimeWindow = 60 * time.Minute.Milliseconds()
83908369
opts.EnableNativeHistograms = true
8391-
opts.EnableOOONativeHistograms = true
83928370

83938371
db, err := Open(dir, nil, nil, opts, nil)
83948372
require.NoError(t, err)
@@ -8447,7 +8425,6 @@ func testDiskFillingUpAfterDisablingOOO(t *testing.T, scenario sampleTypeScenari
84478425
opts := DefaultOptions()
84488426
opts.OutOfOrderTimeWindow = 60 * time.Minute.Milliseconds()
84498427
opts.EnableNativeHistograms = true
8450-
opts.EnableOOONativeHistograms = true
84518428

84528429
db, err := Open(dir, nil, nil, opts, nil)
84538430
require.NoError(t, err)
@@ -8989,7 +8966,7 @@ func TestNativeHistogramFlag(t *testing.T) {
89898966
}, act)
89908967
}
89918968

8992-
func TestOOONativeHistogramFlag(t *testing.T) {
8969+
func TestOOONativeHistogramsSettings(t *testing.T) {
89938970
h := &histogram.Histogram{
89948971
Count: 9,
89958972
ZeroCount: 4,
@@ -9005,17 +8982,15 @@ func TestOOONativeHistogramFlag(t *testing.T) {
90058982

90068983
l := labels.FromStrings("foo", "bar")
90078984

9008-
t.Run("Test OOO native histograms if OOO is disabled", func(t *testing.T) {
8985+
t.Run("Test OOO native histograms if OOO is disabled and Native Histograms is enabled", func(t *testing.T) {
90098986
opts := DefaultOptions()
90108987
opts.OutOfOrderTimeWindow = 0
90118988
db := openTestDB(t, opts, []int64{100})
90128989
defer func() {
90138990
require.NoError(t, db.Close())
90148991
}()
90158992

9016-
// Enable Native Histograms and OOO Native Histogram ingestion
90178993
db.EnableNativeHistograms()
9018-
db.EnableOOONativeHistograms()
90198994

90208995
app := db.Appender(context.Background())
90218996
_, err := app.AppendHistogram(0, l, 100, h, nil)
@@ -9033,17 +9008,15 @@ func TestOOONativeHistogramFlag(t *testing.T) {
90339008
l.String(): {sample{t: 100, h: h}},
90349009
}, act)
90359010
})
9036-
t.Run("Test OOO Native Histograms if Native Histograms are disabled", func(t *testing.T) {
9011+
t.Run("Test OOO Native Histograms if OOO is enabled and Native Histograms are disabled", func(t *testing.T) {
90379012
opts := DefaultOptions()
90389013
opts.OutOfOrderTimeWindow = 100
90399014
db := openTestDB(t, opts, []int64{100})
90409015
defer func() {
90419016
require.NoError(t, db.Close())
90429017
}()
90439018

9044-
// Disable Native Histograms and enable OOO Native Histogram ingestion
90459019
db.DisableNativeHistograms()
9046-
db.EnableOOONativeHistograms()
90479020

90489021
// Attempt to add an in-order sample
90499022
app := db.Appender(context.Background())
@@ -9061,17 +9034,15 @@ func TestOOONativeHistogramFlag(t *testing.T) {
90619034
act := query(t, q, labels.MustNewMatcher(labels.MatchEqual, "foo", "bar"))
90629035
require.Equal(t, map[string][]chunks.Sample{}, act)
90639036
})
9064-
t.Run("Test OOO native histograms when flag is enabled", func(t *testing.T) {
9037+
t.Run("Test OOO native histograms when both OOO and Native Histograms are enabled", func(t *testing.T) {
90659038
opts := DefaultOptions()
90669039
opts.OutOfOrderTimeWindow = 100
90679040
db := openTestDB(t, opts, []int64{100})
90689041
defer func() {
90699042
require.NoError(t, db.Close())
90709043
}()
90719044

9072-
// Enable Native Histograms and OOO Native Histogram ingestion
90739045
db.EnableNativeHistograms()
9074-
db.EnableOOONativeHistograms()
90759046

90769047
// Add in-order samples
90779048
app := db.Appender(context.Background())

‎tsdb/head.go

-15
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,6 @@ type HeadOptions struct {
160160
// EnableNativeHistograms enables the ingestion of native histograms.
161161
EnableNativeHistograms atomic.Bool
162162

163-
// EnableOOONativeHistograms enables the ingestion of OOO native histograms.
164-
// It will only take effect if EnableNativeHistograms is set to true and the
165-
// OutOfOrderTimeWindow is > 0
166-
EnableOOONativeHistograms atomic.Bool
167-
168163
ChunkRange int64
169164
// ChunkDirRoot is the parent directory of the chunks directory.
170165
ChunkDirRoot string
@@ -1041,16 +1036,6 @@ func (h *Head) DisableNativeHistograms() {
10411036
h.opts.EnableNativeHistograms.Store(false)
10421037
}
10431038

1044-
// EnableOOONativeHistograms enables the ingestion of out-of-order native histograms.
1045-
func (h *Head) EnableOOONativeHistograms() {
1046-
h.opts.EnableOOONativeHistograms.Store(true)
1047-
}
1048-
1049-
// DisableOOONativeHistograms disables the ingestion of out-of-order native histograms.
1050-
func (h *Head) DisableOOONativeHistograms() {
1051-
h.opts.EnableOOONativeHistograms.Store(false)
1052-
}
1053-
10541039
// PostingsCardinalityStats returns highest cardinality stats by label and value names.
10551040
func (h *Head) PostingsCardinalityStats(statsByLabelName string, limit int) *index.PostingsStats {
10561041
cacheKey := statsByLabelName + ";" + strconv.Itoa(limit)

‎tsdb/head_append.go

+10-21
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ func (s *memSeries) appendable(t int64, v float64, headMaxt, minValidTime, oooTi
523523
// appendableHistogram checks whether the given histogram sample is valid for appending to the series. (if we return false and no error)
524524
// The sample belongs to the out of order chunk if we return true and no error.
525525
// An error signifies the sample cannot be handled.
526-
func (s *memSeries) appendableHistogram(t int64, h *histogram.Histogram, headMaxt, minValidTime, oooTimeWindow int64, oooHistogramsEnabled bool) (isOOO bool, oooDelta int64, err error) {
526+
func (s *memSeries) appendableHistogram(t int64, h *histogram.Histogram, headMaxt, minValidTime, oooTimeWindow int64) (isOOO bool, oooDelta int64, err error) {
527527
// Check if we can append in the in-order chunk.
528528
if t >= minValidTime {
529529
if s.headChunks == nil {
@@ -549,9 +549,6 @@ func (s *memSeries) appendableHistogram(t int64, h *histogram.Histogram, headMax
549549

550550
// The sample cannot go in the in-order chunk. Check if it can go in the out-of-order chunk.
551551
if oooTimeWindow > 0 && t >= headMaxt-oooTimeWindow {
552-
if !oooHistogramsEnabled {
553-
return true, headMaxt - t, storage.ErrOOONativeHistogramsDisabled
554-
}
555552
return true, headMaxt - t, nil
556553
}
557554

@@ -568,7 +565,7 @@ func (s *memSeries) appendableHistogram(t int64, h *histogram.Histogram, headMax
568565
// appendableFloatHistogram checks whether the given float histogram sample is valid for appending to the series. (if we return false and no error)
569566
// The sample belongs to the out of order chunk if we return true and no error.
570567
// An error signifies the sample cannot be handled.
571-
func (s *memSeries) appendableFloatHistogram(t int64, fh *histogram.FloatHistogram, headMaxt, minValidTime, oooTimeWindow int64, oooHistogramsEnabled bool) (isOOO bool, oooDelta int64, err error) {
568+
func (s *memSeries) appendableFloatHistogram(t int64, fh *histogram.FloatHistogram, headMaxt, minValidTime, oooTimeWindow int64) (isOOO bool, oooDelta int64, err error) {
572569
// Check if we can append in the in-order chunk.
573570
if t >= minValidTime {
574571
if s.headChunks == nil {
@@ -594,9 +591,6 @@ func (s *memSeries) appendableFloatHistogram(t int64, fh *histogram.FloatHistogr
594591

595592
// The sample cannot go in the in-order chunk. Check if it can go in the out-of-order chunk.
596593
if oooTimeWindow > 0 && t >= headMaxt-oooTimeWindow {
597-
if !oooHistogramsEnabled {
598-
return true, headMaxt - t, storage.ErrOOONativeHistogramsDisabled
599-
}
600594
return true, headMaxt - t, nil
601595
}
602596

@@ -654,7 +648,7 @@ func (a *headAppender) AppendHistogram(ref storage.SeriesRef, lset labels.Labels
654648

655649
// Fail fast if OOO is disabled and the sample is out of bounds.
656650
// Otherwise a full check will be done later to decide if the sample is in-order or out-of-order.
657-
if (a.oooTimeWindow == 0 || !a.head.opts.EnableOOONativeHistograms.Load()) && t < a.minValidTime {
651+
if a.oooTimeWindow == 0 && t < a.minValidTime {
658652
a.head.metrics.outOfBoundSamples.WithLabelValues(sampleMetricTypeHistogram).Inc()
659653
return 0, storage.ErrOutOfBounds
660654
}
@@ -694,7 +688,7 @@ func (a *headAppender) AppendHistogram(ref storage.SeriesRef, lset labels.Labels
694688

695689
// TODO(codesome): If we definitely know at this point that the sample is ooo, then optimise
696690
// to skip that sample from the WAL and write only in the WBL.
697-
_, delta, err := s.appendableHistogram(t, h, a.headMaxt, a.minValidTime, a.oooTimeWindow, a.head.opts.EnableOOONativeHistograms.Load())
691+
_, delta, err := s.appendableHistogram(t, h, a.headMaxt, a.minValidTime, a.oooTimeWindow)
698692
if err != nil {
699693
s.pendingCommit = true
700694
}
@@ -705,8 +699,6 @@ func (a *headAppender) AppendHistogram(ref storage.SeriesRef, lset labels.Labels
705699
if err != nil {
706700
switch {
707701
case errors.Is(err, storage.ErrOutOfOrderSample):
708-
fallthrough
709-
case errors.Is(err, storage.ErrOOONativeHistogramsDisabled):
710702
a.head.metrics.outOfOrderSamples.WithLabelValues(sampleMetricTypeHistogram).Inc()
711703
case errors.Is(err, storage.ErrTooOldSample):
712704
a.head.metrics.tooOldSamples.WithLabelValues(sampleMetricTypeHistogram).Inc()
@@ -731,7 +723,7 @@ func (a *headAppender) AppendHistogram(ref storage.SeriesRef, lset labels.Labels
731723

732724
// TODO(codesome): If we definitely know at this point that the sample is ooo, then optimise
733725
// to skip that sample from the WAL and write only in the WBL.
734-
_, delta, err := s.appendableFloatHistogram(t, fh, a.headMaxt, a.minValidTime, a.oooTimeWindow, a.head.opts.EnableOOONativeHistograms.Load())
726+
_, delta, err := s.appendableFloatHistogram(t, fh, a.headMaxt, a.minValidTime, a.oooTimeWindow)
735727
if err == nil {
736728
s.pendingCommit = true
737729
}
@@ -742,8 +734,6 @@ func (a *headAppender) AppendHistogram(ref storage.SeriesRef, lset labels.Labels
742734
if err != nil {
743735
switch {
744736
case errors.Is(err, storage.ErrOutOfOrderSample):
745-
fallthrough
746-
case errors.Is(err, storage.ErrOOONativeHistogramsDisabled):
747737
a.head.metrics.outOfOrderSamples.WithLabelValues(sampleMetricTypeHistogram).Inc()
748738
case errors.Is(err, storage.ErrTooOldSample):
749739
a.head.metrics.tooOldSamples.WithLabelValues(sampleMetricTypeHistogram).Inc()
@@ -799,9 +789,9 @@ func (a *headAppender) AppendHistogramCTZeroSample(ref storage.SeriesRef, lset l
799789
s.lastHistogramValue = zeroHistogram
800790
}
801791

802-
// Although we call `appendableHistogram` with oooHistogramsEnabled=true, for CTZeroSamples OOO is not allowed.
792+
// For CTZeroSamples OOO is not allowed.
803793
// We set it to true to make this implementation as close as possible to the float implementation.
804-
isOOO, _, err := s.appendableHistogram(ct, zeroHistogram, a.headMaxt, a.minValidTime, a.oooTimeWindow, true)
794+
isOOO, _, err := s.appendableHistogram(ct, zeroHistogram, a.headMaxt, a.minValidTime, a.oooTimeWindow)
805795
if err != nil {
806796
s.Unlock()
807797
if errors.Is(err, storage.ErrOutOfOrderSample) {
@@ -833,9 +823,8 @@ func (a *headAppender) AppendHistogramCTZeroSample(ref storage.SeriesRef, lset l
833823
s.lastFloatHistogramValue = zeroFloatHistogram
834824
}
835825

836-
// Although we call `appendableFloatHistogram` with oooHistogramsEnabled=true, for CTZeroSamples OOO is not allowed.
837826
// We set it to true to make this implementation as close as possible to the float implementation.
838-
isOOO, _, err := s.appendableFloatHistogram(ct, zeroFloatHistogram, a.headMaxt, a.minValidTime, a.oooTimeWindow, true) // OOO is not allowed for CTZeroSamples.
827+
isOOO, _, err := s.appendableFloatHistogram(ct, zeroFloatHistogram, a.headMaxt, a.minValidTime, a.oooTimeWindow) // OOO is not allowed for CTZeroSamples.
839828
if err != nil {
840829
s.Unlock()
841830
if errors.Is(err, storage.ErrOutOfOrderSample) {
@@ -1256,7 +1245,7 @@ func (a *headAppender) commitHistograms(acc *appenderCommitContext) {
12561245
series = a.histogramSeries[i]
12571246
series.Lock()
12581247

1259-
oooSample, _, err := series.appendableHistogram(s.T, s.H, a.headMaxt, a.minValidTime, a.oooTimeWindow, a.head.opts.EnableOOONativeHistograms.Load())
1248+
oooSample, _, err := series.appendableHistogram(s.T, s.H, a.headMaxt, a.minValidTime, a.oooTimeWindow)
12601249
if err != nil {
12611250
handleAppendableError(err, &acc.histogramsAppended, &acc.histoOOORejected, &acc.histoOOBRejected, &acc.histoTooOldRejected)
12621251
}
@@ -1344,7 +1333,7 @@ func (a *headAppender) commitFloatHistograms(acc *appenderCommitContext) {
13441333
series = a.floatHistogramSeries[i]
13451334
series.Lock()
13461335

1347-
oooSample, _, err := series.appendableFloatHistogram(s.T, s.FH, a.headMaxt, a.minValidTime, a.oooTimeWindow, a.head.opts.EnableOOONativeHistograms.Load())
1336+
oooSample, _, err := series.appendableFloatHistogram(s.T, s.FH, a.headMaxt, a.minValidTime, a.oooTimeWindow)
13481337
if err != nil {
13491338
handleAppendableError(err, &acc.histogramsAppended, &acc.histoOOORejected, &acc.histoOOBRejected, &acc.histoTooOldRejected)
13501339
}

‎tsdb/head_test.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -2829,7 +2829,6 @@ func TestOutOfOrderSamplesMetric(t *testing.T) {
28292829
t.Run(name, func(t *testing.T) {
28302830
options := DefaultOptions()
28312831
options.EnableNativeHistograms = true
2832-
options.EnableOOONativeHistograms = true
28332832
testOutOfOrderSamplesMetric(t, scenario, options, storage.ErrOutOfOrderSample)
28342833
})
28352834
}
@@ -2842,10 +2841,9 @@ func TestOutOfOrderSamplesMetricNativeHistogramOOODisabled(t *testing.T) {
28422841
}
28432842
t.Run(name, func(t *testing.T) {
28442843
options := DefaultOptions()
2845-
options.OutOfOrderTimeWindow = (1000 * time.Minute).Milliseconds()
2844+
options.OutOfOrderTimeWindow = 0
28462845
options.EnableNativeHistograms = true
2847-
options.EnableOOONativeHistograms = false
2848-
testOutOfOrderSamplesMetric(t, scenario, options, storage.ErrOOONativeHistogramsDisabled)
2846+
testOutOfOrderSamplesMetric(t, scenario, options, storage.ErrOutOfOrderSample)
28492847
})
28502848
}
28512849
}
@@ -4784,7 +4782,6 @@ func TestOOOHistogramCounterResetHeaders(t *testing.T) {
47844782
l := labels.FromStrings("a", "b")
47854783
head, _ := newTestHead(t, 1000, compression.None, true)
47864784
head.opts.OutOfOrderCapMax.Store(5)
4787-
head.opts.EnableOOONativeHistograms.Store(true)
47884785

47894786
t.Cleanup(func() {
47904787
require.NoError(t, head.Close())
@@ -4943,7 +4940,6 @@ func TestAppendingDifferentEncodingToSameSeries(t *testing.T) {
49434940
dir := t.TempDir()
49444941
opts := DefaultOptions()
49454942
opts.EnableNativeHistograms = true
4946-
opts.EnableOOONativeHistograms = true
49474943
db, err := Open(dir, nil, nil, opts, nil)
49484944
require.NoError(t, err)
49494945
t.Cleanup(func() {
@@ -5215,7 +5211,6 @@ func testWBLReplay(t *testing.T, scenario sampleTypeScenario) {
52155211
opts.ChunkDirRoot = dir
52165212
opts.OutOfOrderTimeWindow.Store(30 * time.Minute.Milliseconds())
52175213
opts.EnableNativeHistograms.Store(true)
5218-
opts.EnableOOONativeHistograms.Store(true)
52195214

52205215
h, err := NewHead(nil, nil, wal, oooWlog, opts, nil)
52215216
require.NoError(t, err)
@@ -5310,7 +5305,6 @@ func testOOOMmapReplay(t *testing.T, scenario sampleTypeScenario) {
53105305
opts.OutOfOrderCapMax.Store(30)
53115306
opts.OutOfOrderTimeWindow.Store(1000 * time.Minute.Milliseconds())
53125307
opts.EnableNativeHistograms.Store(true)
5313-
opts.EnableOOONativeHistograms.Store(true)
53145308

53155309
h, err := NewHead(nil, nil, wal, oooWlog, opts, nil)
53165310
require.NoError(t, err)
@@ -5613,7 +5607,6 @@ func testOOOAppendWithNoSeries(t *testing.T, appendFunc func(appender storage.Ap
56135607
opts.OutOfOrderCapMax.Store(30)
56145608
opts.OutOfOrderTimeWindow.Store(120 * time.Minute.Milliseconds())
56155609
opts.EnableNativeHistograms.Store(true)
5616-
opts.EnableOOONativeHistograms.Store(true)
56175610

56185611
h, err := NewHead(nil, nil, wal, oooWlog, opts, nil)
56195612
require.NoError(t, err)
@@ -5705,7 +5698,6 @@ func testHeadMinOOOTimeUpdate(t *testing.T, scenario sampleTypeScenario) {
57055698
opts.ChunkDirRoot = dir
57065699
opts.OutOfOrderTimeWindow.Store(10 * time.Minute.Milliseconds())
57075700
opts.EnableNativeHistograms.Store(true)
5708-
opts.EnableOOONativeHistograms.Store(true)
57095701

57105702
h, err := NewHead(nil, nil, wal, oooWlog, opts, nil)
57115703
require.NoError(t, err)

‎tsdb/ooo_head_read_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ func TestOOOHeadChunkReader_LabelValues(t *testing.T) {
389389
func testOOOHeadChunkReader_LabelValues(t *testing.T, scenario sampleTypeScenario) {
390390
chunkRange := int64(2000)
391391
head, _ := newTestHead(t, chunkRange, compression.None, true)
392-
head.opts.EnableOOONativeHistograms.Store(true)
393392
t.Cleanup(func() { require.NoError(t, head.Close()) })
394393

395394
ctx := context.Background()
@@ -495,7 +494,6 @@ func testOOOHeadChunkReader_Chunk(t *testing.T, scenario sampleTypeScenario) {
495494
opts.OutOfOrderCapMax = 5
496495
opts.OutOfOrderTimeWindow = 120 * time.Minute.Milliseconds()
497496
opts.EnableNativeHistograms = true
498-
opts.EnableOOONativeHistograms = true
499497

500498
s1 := labels.FromStrings("l", "v1")
501499
minutes := func(m int64) int64 { return m * time.Minute.Milliseconds() }
@@ -906,7 +904,6 @@ func testOOOHeadChunkReader_Chunk_ConsistentQueryResponseDespiteOfHeadExpanding(
906904
opts.OutOfOrderCapMax = 5
907905
opts.OutOfOrderTimeWindow = 120 * time.Minute.Milliseconds()
908906
opts.EnableNativeHistograms = true
909-
opts.EnableOOONativeHistograms = true
910907

911908
s1 := labels.FromStrings("l", "v1")
912909
minutes := func(m int64) int64 { return m * time.Minute.Milliseconds() }

‎tsdb/querier_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -1507,8 +1507,6 @@ func TestPopulateWithTombSeriesIterators(t *testing.T) {
15071507
expectedMinMaxTimes: []minMaxTimes{{7, 12}, {11, 16}, {10, 203}},
15081508
},
15091509
{
1510-
// This case won't actually happen until OOO native histograms is implemented.
1511-
// Issue: https://github.com/prometheus/prometheus/issues/11220.
15121510
name: "int histogram iterables with counter resets",
15131511
samples: [][]chunks.Sample{
15141512
{
@@ -1578,8 +1576,6 @@ func TestPopulateWithTombSeriesIterators(t *testing.T) {
15781576
skipChunkTest: true,
15791577
},
15801578
{
1581-
// This case won't actually happen until OOO native histograms is implemented.
1582-
// Issue: https://github.com/prometheus/prometheus/issues/11220.
15831579
name: "float histogram iterables with counter resets",
15841580
samples: [][]chunks.Sample{
15851581
{
@@ -1649,8 +1645,6 @@ func TestPopulateWithTombSeriesIterators(t *testing.T) {
16491645
skipChunkTest: true,
16501646
},
16511647
{
1652-
// This case won't actually happen until OOO native histograms is implemented.
1653-
// Issue: https://github.com/prometheus/prometheus/issues/11220.
16541648
name: "iterables with mixed encodings and counter resets",
16551649
samples: [][]chunks.Sample{
16561650
{

0 commit comments

Comments
 (0)
Please sign in to comment.