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

use default retention period to check user index may have expired chunks when user does not have custom retention #5261

Merged

Conversation

sandeepsukhani
Copy link
Contributor

What this PR does / why we need it:
When checking whether user specific index tables may have any expired chunks, we were using the smallest overall retention period instead of the smallest default retention period.

This causes us to unnecessarily download user index tables in some cases, for e.g:
We have a default config of 30d, user1 has a custom stream retention of 24h and user2 has no retention config.
Here the overall smallest retention period is 24h and the smallest default retention is 30d.
When checking if user2's index table may have expired chunks based on table interval, we should be considering 30d retention and not 24h.

Checklist

  • Tests updated

…nks when user does not have custom retention
tenantsRetention *TenantsRetention
latestRetentionStartTime model.Time
tenantsRetention *TenantsRetention
// overallLatestRetentionStartTime holds latest retention start time considering both default and per user retention config.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// overallLatestRetentionStartTime holds latest retention start time considering both default and per user retention config.
// overallLatestRetentionStartTime holds latest retention start time for all users considering both default and per user retention config.

// findLatestRetentionStartTime returns the latest retention start time overall and by each user.
func findLatestRetentionStartTime(now model.Time, limits Limits) (model.Time, map[string]model.Time) {
// findLatestRetentionStartTime returns the latest retention start time overall, just default config and by each user.
func findLatestRetentionStartTime(now model.Time, limits Limits) (model.Time, model.Time, map[string]model.Time) {
Copy link
Contributor

@cyriltovena cyriltovena Jan 28, 2022

Choose a reason for hiding this comment

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

nit: I'm not happy with the return here anymore. I think in the future we should make that a struct with proper names, this would avoid confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, pushed this change

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

@sandeepsukhani sandeepsukhani merged commit 37fcbf9 into grafana:main Jan 28, 2022
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