Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make the tsdb filenames correctly reproducible from the identifier #12536

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

sandeepsukhani
Copy link
Contributor

What this PR does / why we need it:
In PR #12502, we updated tsdb code to use nanosecond precision in compacted file names.
However, this has caused problems in bloom compactor since the identifier generated while parsing tsdb filenames is not able to regenerate the original filename for old files with unix timestamp since it always uses nanoseconds for generating the filename.

I have fixed the issue by retaining the original timestamp from the file while parsing the names.

Checklist

  • Tests updated

@sandeepsukhani sandeepsukhani requested a review from a team as a code owner April 9, 2024 11:08
Copy link
Contributor

@salvacorts salvacorts left a comment

Choose a reason for hiding this comment

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

LGTM. Left a minor nit.

@@ -77,9 +81,13 @@ func (i SingleTenantTSDBIdentifier) Hash(h hash.Hash32) (err error) {

// str builds filename with format <file-creation-ts> + `-` + `compactor` + `-` + <oldest-chunk-start-ts> + `-` + <latest-chunk-end-ts> `-` + <index-checksum>
func (i SingleTenantTSDBIdentifier) str() string {
ts := i.origTS
if ts == 0 {
ts = i.TS.UnixNano()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I find this a bit hacky. I think a bool flag writeTSAsSecs would read better.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 9, 2024
@sandeepsukhani sandeepsukhani merged commit ec888ec into main Apr 9, 2024
12 checks passed
@sandeepsukhani sandeepsukhani deleted the reproducible-tsdb-name-from-identifier branch April 9, 2024 11:50
sandeepsukhani added a commit that referenced this pull request Apr 9, 2024
sandeepsukhani added a commit that referenced this pull request Apr 9, 2024
rhnasc pushed a commit to inloco/loki that referenced this pull request Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants