Skip to content

refactor(tsdb/index): drop FormatV1 reader support#5158

Merged
simonswine merged 1 commit into
grafana:mainfrom
simonswine:20260515_remove-v1-index-variant
May 15, 2026
Merged

refactor(tsdb/index): drop FormatV1 reader support#5158
simonswine merged 1 commit into
grafana:mainfrom
simonswine:20260515_remove-v1-index-variant

Conversation

@simonswine
Copy link
Copy Markdown
Contributor

@simonswine simonswine commented May 15, 2026

Summary

Remove all FormatV1-specific code paths and infrastructure from index reader. System has only written V2 indexes since Phlare v0.1.0, V1 paths were never needed. Follow up to #5155

Details

  • Remove FormatV1 constant and version field from Reader struct
  • Remove postingsV1 map (V1-only offset table)
  • Simplify postings reading to V2-only path with ReadOffsetTable
  • Remove version field from Symbols struct, simplify Lookup/ReverseLookup
  • Update Version() to return FormatV2 directly
  • Remove version checks from Series, SeriesBy, LabelNamesFor, LabelValueFor, Postings, PostingsForLabelMatching

Context

Phlare v0.1.0+ only writes V2 indexes. V1 reader support is legacy code from before standardization. No production systems depend on V1 reading capability.

Test Results

pkg/phlaredb/tsdb/index tests pass (70.2% coverage)
make lint clean
✓ All affected reader methods validated

Risk Assessment

Negligible risk - V1 format never used in production Phlare. No migration needed.


Note

Medium Risk
Touches core TSDB index reading paths (symbols, postings, series ID offsets) and could break compatibility with any remaining V1 index files, but behavior for V2 should be unchanged and code is largely deletions/simplification.

Overview
Drops V1 index compatibility and makes the reader V2-only. newReader now rejects anything except FormatV2, removes the Reader.version/postingsV1 infrastructure, and always builds postings offsets via ReadOffsetTable.

Simplifies symbols and series offset handling. NewSymbols no longer takes a version, Symbols lookup/reverse-lookup always uses the V2 offset-sampling approach, Reader.Version() is hardcoded to FormatV2, and series lookups (Series, SeriesBy, LabelNamesFor, LabelValueFor) always apply the 16-byte padding offset logic. Tests are updated to match the new NewSymbols signature, and the memdb index package removes its unused FormatV1 constant and related branching.

Reviewed by Cursor Bugbot for commit bd4e63b. Bugbot is set up for automated code reviews on this repo. Configure here.

Remove all FormatV1-specific code paths and infrastructure from the index reader.
Phlare v0.1.0+ only writes V2 indexes, so V1 reader support is legacy code.

This includes:
- Remove FormatV1 constant and version field from Reader struct
- Remove postingsV1 map used for V1 format
- Simplify postings offset table reading to V2-only path with ReadOffsetTable
- Remove version field and version checks from Symbols struct
- Update Version() method to return FormatV2 directly

Keeps ReadOffsetTable as the main API for reading offset tables.
@simonswine simonswine force-pushed the 20260515_remove-v1-index-variant branch from 0c7886b to bd4e63b Compare May 15, 2026 10:49
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit bd4e63b. Configure here.

HeaderLen = 5

// FormatV1 represents 1 version of index.
FormatV1 = 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unused FormatV1 constant left as dead code

Low Severity

The FormatV1 constant was correctly removed from pkg/segmentwriter/memdb/index/index.go, but the equivalent FormatV1 constant in pkg/phlaredb/tsdb/index/index.go (lines 51–52) was left behind even though all its usages in that file were removed by this PR. It's now dead code with zero references inside the package or anywhere else in the repository.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bd4e63b. Configure here.

@simonswine simonswine merged commit e6bb0e8 into grafana:main May 15, 2026
33 checks passed
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.

2 participants