Skip to content

feat(storage)[PART4b]: add AppenderV2 to the rest of storage.Storage implementations + mock exemplar fix#17835

Merged
bwplotka merged 4 commits intomainfrom
bwplotka/a2-storage-support
Jan 16, 2026
Merged

feat(storage)[PART4b]: add AppenderV2 to the rest of storage.Storage implementations + mock exemplar fix#17835
bwplotka merged 4 commits intomainfrom
bwplotka/a2-storage-support

Conversation

@bwplotka
Copy link
Member

@bwplotka bwplotka commented Jan 12, 2026

Splitting work from #17675 into smaller PRs. This one starts requiring AppendableV2 implementation on ALL storage.Storage implementations; added AppendableV2 to the rest of easier implementations here. Where relevant AppendableV2 tests we added.

I also adjusted appendable mock to:

  • match series by labels not by ref in V1 exemplar flow
  • fix exemplar error injection, moving it before recording exemplar.

Related to #17632

Chained on top of PART4a #17834 [merged]

Does this PR introduce a user-facing change?

NONE

@bwplotka bwplotka force-pushed the bwplotka/a2-storage-support branch 2 times, most recently from 1b28a46 to 49ea7b0 Compare January 12, 2026 09:19
@bwplotka bwplotka force-pushed the bwplotka/a2-storage-support branch from 49ea7b0 to 1a80486 Compare January 12, 2026 13:31
@bwplotka bwplotka changed the title feat(storage)[PART4b]: add AppenderV2 to the rest of storage.Storage impl feat(storage)[PART4b]: add AppenderV2 to the rest of storage.Storage implementations Jan 13, 2026
Copy link
Contributor

@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

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

Please see comment.

Copy link
Contributor

@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

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

Just suggesting adding a doc comment for completeness.

Base automatically changed from bwplotka/a2-remote-1 to main January 14, 2026 13:48
…impl

Signed-off-by: bwplotka <bwplotka@gmail.com>
Signed-off-by: bwplotka <bwplotka@gmail.com>
@bwplotka bwplotka force-pushed the bwplotka/a2-storage-support branch from 1a80486 to 8a2921e Compare January 14, 2026 13:57
Signed-off-by: bwplotka <bwplotka@gmail.com>
@aknuds1 aknuds1 self-requested a review January 15, 2026 15:12
@bwplotka bwplotka force-pushed the bwplotka/a2-storage-support branch 3 times, most recently from 2fa1f39 to 051cdd6 Compare January 16, 2026 09:52
i := len(a.a.pendingSamples) - 1
for ; i >= 0; i-- { // Attach exemplars to the last matching sample.
if ref == storage.SeriesRef(a.a.pendingSamples[i].L.Hash()) {
if labels.Equal(l, a.a.pendingSamples[i].L) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is because some tests uses storage and storage does not use label hash, but atomic increment.

i := len(a.a.pendingSamples) - 1
for ; i >= 0; i-- { // Attach metadata to the last matching sample.
if ref == storage.SeriesRef(a.a.pendingSamples[i].L.Hash()) {
if labels.Equal(l, a.a.pendingSamples[i].L) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is because some tests uses storage and storage does not use label hash, but atomic increment.

// As per AppenderV2 interface, opts.Exemplar slice is unsafe for reuse.
es = make([]exemplar.Exemplar, len(opts.Exemplars))
copy(es, opts.Exemplars)
if a.a.appendExemplarsError != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is because in the previous code we were appending exemplar BEFORE we inject the error.

Copy link
Member

Choose a reason for hiding this comment

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

oh, woops

@bwplotka bwplotka changed the title feat(storage)[PART4b]: add AppenderV2 to the rest of storage.Storage implementations feat(storage)[PART4b]: add AppenderV2 to the rest of storage.Storage implementations + mock exemplar fix Jan 16, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds AppenderV2 support to additional storage implementations as part of the ongoing migration from Appender to AppenderV2 interface. It also includes fixes to the test storage mock for exemplar handling.

Changes:

  • Added AppenderV2 implementations to remote WriteStorage, Storage, fanout, and readyStorage
  • Fixed exemplar and metadata matching in test appender to use label comparison instead of ref-based matching
  • Fixed exemplar error injection timing in test appender to occur before sample recording
  • Added comprehensive tests for fanout AppenderV2 functionality

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
util/teststorage/appender.go Fixed exemplar/metadata matching to use labels.Equal instead of ref comparison; moved exemplar error injection before recording
tsdb/head_append_v2.go Added TODO comment for improving exemplar error messages
storage/remote/write.go Added AppenderV2 method to WriteStorage with timestampTrackerV2 implementation; refactored common tracker fields into baseTimestampTracker
storage/remote/storage.go Added AppenderV2 method that delegates to WriteStorage; added compile-time interface check
storage/interface_append.go Added ErrOrNil and Handle helper methods to AppendPartialError; added documentation about duplicate exemplar handling
storage/interface.go Updated Storage interface to require both Appendable and AppendableV2; added consistent deprecation warnings
storage/fanout_test.go Added comprehensive tests for fanout AppenderV2 including error scenarios; added TestFanoutAppenderV2 and TestFanoutSelectSorted_AppenderV2
storage/fanout.go Added AppenderV2 method to fanout; implemented fanoutAppenderV2 with partial error aggregation; fixed Rollback to return error instead of nil
cmd/prometheus/main.go Added AppenderV2 method to readyStorage with notReadyAppenderV2 implementation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@krajorama krajorama left a comment

Choose a reason for hiding this comment

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

LGTM

@bwplotka bwplotka merged commit c4b0da9 into main Jan 16, 2026
67 of 72 checks passed
@bwplotka bwplotka deleted the bwplotka/a2-storage-support branch January 16, 2026 13:04
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.

5 participants