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: use nanosecond precision for timestamp in compacted tsdb index file names #12502

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

sandeepsukhani
Copy link
Contributor

What this PR does / why we need it:
Do the same changes as PR #11277, i.e., have a creation timestamp in compacted index files with nanosecond precision instead of seconds. I had only made that change for boltdb-shipper and skipped changing tsdb since tsdb index file names have checksums in them. However, as seen in issue #12500, we can hit the bug if compaction happens twice in the same unix second, and it ends up having the same contents in the compacted index(hence the same checksum as well).

Which issue(s) this PR fixes:
Fixes #12500

Checklist

  • Tests updated

@sandeepsukhani sandeepsukhani requested a review from a team as a code owner April 8, 2024 10:06
@@ -79,7 +79,7 @@ func (i SingleTenantTSDBIdentifier) Hash(h hash.Hash32) (err error) {
func (i SingleTenantTSDBIdentifier) str() string {
return fmt.Sprintf(
"%d-%s-%d-%d-%x.tsdb",
i.TS.Unix(),
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.

SGTM. Can you also get an approval from blooms folks? I wonder if we do any filename parsing assuming it's seconds precision anywhere.

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. As far as I can tell, blooms only use ParseSingleTenantTSDBPath.

@sandeepsukhani sandeepsukhani merged commit be501c2 into main Apr 8, 2024
12 checks passed
@sandeepsukhani sandeepsukhani deleted the tsdb-compaction-ns-precision branch April 8, 2024 11:11
sandeepsukhani added a commit that referenced this pull request Apr 8, 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.

Compacted TSDB data lost because S3 object name not unique between compaction and retention
3 participants