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

v12 chunk format handling in retention #5254

Merged

Conversation

sandeepsukhani
Copy link
Contributor

What this PR does / why we need it:
While applying retention, compactor looks for chunk ids in specific formats. If it can't find any chunks it drops the whole table.
Since the recent v12 chunk id format is not recognized by the compactor, it drops the whole table while applying retention on table using v12 schema.

This PR makes the retention code aware of v12 chunk id format and adds a safety mechanism to fail the retention operation when it can't find any chunk ids in the table.

Checklist

  • Tests updated

Also add some tests and safety mechanism to avoid dropping whole table when we cant find any chunks
@sandeepsukhani sandeepsukhani requested a review from a team as a code owner January 27, 2022 14:22
Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

Thanks for the quick PR. I'm worried about maintaining two distinct code paths for chunk key parsing in the repo because it makes it easy to forget one, diverge implementations, etc. Instead, I'd like to maintain one way to read chunks in pkg/storage/chunk which should help prevent these kind of issues in the future.

if i == 0 {
return nil, nil, nil, false

// v12+ chunk id format `<user>/<fprint>/<start>:<end>:<checksum>`
Copy link
Member

Choose a reason for hiding this comment

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

I think we should standardize the internal functions used to parse chunks in pkg/storage/chunk so we don't have to maintain two versions, but that can be left for a later pr.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes ! +1 Let's add an issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

@sandeepsukhani sandeepsukhani merged commit 9fdcacf into grafana:main Jan 27, 2022
sandeepsukhani added a commit to sandeepsukhani/loki that referenced this pull request Jan 27, 2022
Also add some tests and safety mechanism to avoid dropping whole table when we cant find any chunks
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.

4 participants