refactor(tsdb/index): drop FormatV1 reader support#5158
Merged
simonswine merged 1 commit intoMay 15, 2026
Conversation
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.
0c7886b to
bd4e63b
Compare
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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 |
Contributor
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit bd4e63b. Configure here.
korniltsev-grafanista
approved these changes
May 15, 2026
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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
FormatV1constant andversionfield from Reader structpostingsV1map (V1-only offset table)ReadOffsetTableversionfield from Symbols struct, simplify Lookup/ReverseLookupVersion()to returnFormatV2directlyContext
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/indextests pass (70.2% coverage)✓
make lintclean✓ 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.
newReadernow rejects anything exceptFormatV2, removes theReader.version/postingsV1infrastructure, and always builds postings offsets viaReadOffsetTable.Simplifies symbols and series offset handling.
NewSymbolsno longer takes a version,Symbolslookup/reverse-lookup always uses the V2 offset-sampling approach,Reader.Version()is hardcoded toFormatV2, and series lookups (Series,SeriesBy,LabelNamesFor,LabelValueFor) always apply the 16-byte padding offset logic. Tests are updated to match the newNewSymbolssignature, and the memdb index package removes its unusedFormatV1constant and related branching.Reviewed by Cursor Bugbot for commit bd4e63b. Bugbot is set up for automated code reviews on this repo. Configure here.