Skip to content

tsdb: fix AppenderV2 metadata handling - #19912

Closed
aknuds1 wants to merge 5 commits into
prometheus:bwplotka/rw_receiver_appender_v2from
aknuds1:arve/bwplotka/rw_receiver_appender_v2
Closed

aknuds1 wants to merge 5 commits into
prometheus:bwplotka/rw_receiver_appender_v2from
aknuds1:arve/bwplotka/rw_receiver_appender_v2

Conversation

@aknuds1

@aknuds1 aknuds1 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

RW2 repeats series metadata for each append. With AppenderV2, a batched request could therefore write duplicate metadata WAL entries, while a stale-only request could omit metadata entirely.

  • Deduplicate metadata within a Head transaction while preserving real metadata transitions and rollback behavior.
  • Preserve metadata and append options on stale samples, including converted histogram markers; continue skipping inline exemplars on stale samples.

Regression coverage uses named, table-driven subtests for real HTTP receiver/TSDB/WAL paths, 1,000-sample metadata batches, stale metadata, mixed sample types, metadata transitions, and rollback.

Which issue(s) does the PR fix:

Follow-up to #19812, targeting its feature branch. Exemplar accounting is split into #19941.

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

Reviewers should verify clarity and quality.

[BUGFIX] TSDB: Deduplicate metadata within AppenderV2 transactions and preserve metadata on stale samples

@aknuds1
aknuds1 force-pushed the arve/bwplotka/rw_receiver_appender_v2 branch 3 times, most recently from 6be3702 to 71a89b4 Compare October 6, 2026 10:39
// It's up to the caller to decide if it's an ignorable error or not, plus
// it allows extra reporting (e.g. for Remote Write 2.0 X-Remote-Write-Written headers).
type AppendPartialError struct {
ExemplarErrors []error

@krajorama krajorama Oct 6, 2026 •

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.

I have been wondering about the error handling myself, due to grafana/mimir#16738

An idea I had was to not add a new field like ExemplarErrorIndexes, but allocate ExemplarErrors on first error right away at length(exemplars) , where exemplars is the input array. And then errors can be just assigned by index. The idea is that allocations are the most expensive operation so we'd want to avoid another allocation , plus possibly allocating due to append. WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This should now concern #19941 instead. Can you make the comment there?

@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.

Would you mind splitting this into two parts? One for exemplars and one for metadata? thanks!

@aknuds1
aknuds1 force-pushed the arve/bwplotka/rw_receiver_appender_v2 branch from 71a89b4 to e69b3a1 Compare October 6, 2026 14:36
@aknuds1 aknuds1 changed the title storage/remote: fix AppenderV2 metadata and exemplar accounting tsdb: fix AppenderV2 metadata handling Oct 6, 2026
@aknuds1

aknuds1 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

I've split into two PRs now @krajorama. This and #19941. I'll move this PR out of draft after I've looked it properly over.

@aknuds1
aknuds1 marked this pull request as ready for review October 6, 2026 18:23
@aknuds1
aknuds1 requested a review from krajorama October 6, 2026 18:24
@aknuds1

aknuds1 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

@krajorama @bwplotka PTAL.

@bwplotka

Copy link
Copy Markdown
Member

Thanks for this!

Do we need to fix metadata duplication within a single appender? See #20000 (comment) -- I don't think this ever practically happen. And even if somebody does it because protocol allows it, then let's duplicate - it's not a big deal vs additional code and structures to validate this. In this case we can just document?

Stale fix is valid.

Can we propose state fix as a separate PR to main (it's orthogonal to AppV2 RW)?

Again, I would only document duplication for now, but that can be separate fix as well

Then this PR could be closed?

@bwplotka
bwplotka deleted the branch prometheus:bwplotka/rw_receiver_appender_v2 October 14, 2026 11:37
@bwplotka bwplotka closed this Oct 14, 2026
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