Skip to content

tsdb: plumb st for histograms through wal/wbl - #18804

Merged
ywwg merged 11 commits into
mainfrom
owilliams/st-in-wal
Jun 18, 2026
Merged

ywwg merged 11 commits into
mainfrom
owilliams/st-in-wal

Conversation

@ywwg

@ywwg ywwg commented May 27, 2026 •

Copy link
Copy Markdown
Member

Histogram and float-histogram samples now carry their start timestamp
from the AppenderV2.Append entry point all the way into the in-memory
series, matching what counters already do.

Histogram chunk encoding still drops ST until PR #18609 lands, so new AI-genned (and human-checked) tests are overly complex. Once chunk encoding goes in, they can be simplified.

Part of #17790.

Signed-off-by: Owen Williams [email protected]

Release notes for end users (ALL commits must be considered).

[ENHANCEMENT] WAL/WBL support start time per sample for histogram types 

ywwg added 5 commits May 22, 2026 14:24
Histogram and float-histogram samples now carry their start timestamp
from the AppenderV2.Append entry point all the way into the in-memory
series, matching what counters already do.

Previously the v2 head built RefHistogramSample / RefFloatHistogramSample
records with ST hardcoded to 0, and the commit path passed 0 as the
first argument to memSeries.insert / appendHistogram /
appendFloatHistogram. PR #18221 added the ST field to the records and
the st parameter to memSeries; this commit fills in the head side.

Histogram chunk encoding still drops ST until PR #18609 lands.

Part of #17790.

Signed-off-by: Owen Williams <[email protected]>
Add an st field to histogramRecord and populate it from the decoded
RefHistogramSample.ST / RefFloatHistogramSample.ST at every load site
(WAL loader, WBL loader, both for integer and float histograms). The
replay path then forwards s.st into memSeries.appendHistogram /
appendFloatHistogram / insert, matching the float path.

Part of #17790.

Signed-off-by: Owen Williams <[email protected]>
The agent's v2 appender already received an st parameter on Append but
dropped it when building RefHistogramSample / RefFloatHistogramSample.
Set ST on both record literals so histograms reach the agent WAL with
their start timestamp, matching the float counter behaviour.

Part of #17790.

Signed-off-by: Owen Williams <[email protected]>
Add four tests that verify start timestamps survive the v2 head and
agent WAL paths for histogram and float-histogram samples:

  TestHeadAppenderV2_Histogram_STInWAL
    head v2 append → commit → read raw WAL → assert ST per sample.
    Subtests cover integer/float histograms × EnableSTStorage on/off
    to lock in the V2-vs-V1 record-type gating.

  TestHeadAppender_STStorage_HistogramWALReplay
    head v2 append → close → reopen → assert series rehydrate and a
    post-replay append carries its new ST under the same series ref.

  TestHeadAppender_STStorage_HistogramWBLReplay
    OOO histogram append → assert WBL records carry V2 type with ST.

  TestDB_AppendV2_HistogramSTInWAL
    agent v2 append → close → read WAL → assert ST per sample, with
    varying ST values to exercise the V2 wire format's delta encoding.

Chunk-level ST assertions are deliberately omitted because the
histogram chunk encoder still drops ST pre-#18609; tests assert at the
WAL record boundary instead, which is the contract these commits
actually establish.

walSample (private agent test type) gains an st field; readWALSamples
now also decodes V2 and float-histogram record variants so existing
fixtures keep working while new tests can assert ST.

Part of #17790.

Signed-off-by: Owen Williams <[email protected]>
Signed-off-by: Owen Williams <[email protected]>
ywwg added 5 commits June 16, 2026 13:29
Signed-off-by: Owen Williams <[email protected]>
Signed-off-by: Owen Williams <[email protected]>
Signed-off-by: Owen Williams <[email protected]>
@ywwg
ywwg marked this pull request as ready for review June 16, 2026 17:58

@krajorama krajorama left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one nit comment

Comment thread tsdb/agent/db_append_v2_test.go Resolved
Signed-off-by: Owen Williams <[email protected]>
@ywwg
ywwg requested a review from krajorama June 17, 2026 14:19

@krajorama krajorama left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bwplotka bwplotka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ywwg
ywwg merged commit 505095b into main Jun 18, 2026
59 of 60 checks passed
@ywwg
ywwg deleted the owilliams/st-in-wal branch June 18, 2026 13:53
@ywwg ywwg mentioned this pull request Jun 18, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants