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: Keep blocks referenced by newer metas #13614

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

salvacorts
Copy link
Contributor

What this PR does / why we need it:

This PR prevents the planner from deleting blocks from a outdated meta that is still referenced by an up to date meta.

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

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@salvacorts salvacorts changed the title Keep blocks referenced by newer metas fix: Keep blocks referenced by newer metas Jul 22, 2024
@salvacorts salvacorts added type/bug Somehing is not working as expected feature/blooms labels Jul 22, 2024
@@ -52,7 +52,7 @@ func (p *processor) processTasks(ctx context.Context, tasks []Task) error {
return nil
}

func (p *processor) processTasksForDay(ctx context.Context, tenant string, day config.DayTime, tasks []Task) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Go Lint CI was complaining so I fixed these here even though they are unrelated to the PR

@salvacorts salvacorts force-pushed the salvacorts/blooms/keep-blocks-present-in-newer-metas branch from 5d75907 to 696f798 Compare July 22, 2024 14:48
@salvacorts salvacorts force-pushed the salvacorts/blooms/keep-blocks-present-in-newer-metas branch from 696f798 to 6b0da35 Compare July 22, 2024 14:52
@salvacorts salvacorts marked this pull request as ready for review July 22, 2024 14:57
@salvacorts salvacorts requested a review from a team as a code owner July 22, 2024 14:57
Comment on lines +545 to +557
// Blocks are sorted within a meta, so we can find it with binary search
for _, meta := range metas {
// Search for the first block whose bound is >= than the target block min bound.
i := sort.Search(len(meta.Blocks), func(i int) bool {
return meta.Blocks[i].Cmp(uint64(block.Bounds.Max)) <= v1.Overlap
})

if i < len(meta.Blocks) && meta.Blocks[i] == block {
return true
}
}

return false
Copy link
Contributor

Choose a reason for hiding this comment

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

how many blocks are usually in a meta? it could be faster to just do a for loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’d leave the bin search:

  • If there are many blocks --> works better
  • If there are not that many, I don’t think there will be much difference moreover provided this is not on a critical path and is actually done after all the build process is done (or during the planning)

@salvacorts salvacorts merged commit 784e7d5 into main Jul 23, 2024
61 checks passed
@salvacorts salvacorts deleted the salvacorts/blooms/keep-blocks-present-in-newer-metas branch July 23, 2024 09:30
@grafanabot
Copy link
Collaborator

The backport to k212 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-13614-to-k212 origin/k212
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 784e7d562fedec7134c8ed4e2cee8ccb7049e271

When the conflicts are resolved, stage and commit the changes:

git add . && git cherry-pick --continue

If you have the GitHub CLI installed:

# Push the branch to GitHub:
git push --set-upstream origin backport-13614-to-k212
# Create the PR body template
PR_BODY=$(gh pr view 13614 --json body --template 'Backport 784e7d562fedec7134c8ed4e2cee8ccb7049e271 from #13614{{ "\n\n---\n\n" }}{{ index . "body" }}')
# Create the PR on GitHub
echo "${PR_BODY}" | gh pr create --title 'chore: [k212] fix: Keep blocks referenced by newer metas' --body-file - --label 'size/L' --label 'type/bug' --label 'feature/blooms' --label 'backport' --base k212 --milestone k212 --web

Or, if you don't have the GitHub CLI installed (we recommend you install it!):

# Push the branch to GitHub:
git push --set-upstream origin backport-13614-to-k212

# Create a pull request where the `base` branch is `k212` and the `compare`/`head` branch is `backport-13614-to-k212`.

# Remove the local backport branch
git switch main
git branch -D backport-13614-to-k212

@grafanabot
Copy link
Collaborator

The backport to k211 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-13614-to-k211 origin/k211
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 784e7d562fedec7134c8ed4e2cee8ccb7049e271

When the conflicts are resolved, stage and commit the changes:

git add . && git cherry-pick --continue

If you have the GitHub CLI installed:

# Push the branch to GitHub:
git push --set-upstream origin backport-13614-to-k211
# Create the PR body template
PR_BODY=$(gh pr view 13614 --json body --template 'Backport 784e7d562fedec7134c8ed4e2cee8ccb7049e271 from #13614{{ "\n\n---\n\n" }}{{ index . "body" }}')
# Create the PR on GitHub
echo "${PR_BODY}" | gh pr create --title 'chore: [k211] fix: Keep blocks referenced by newer metas' --body-file - --label 'size/L' --label 'type/bug' --label 'feature/blooms' --label 'backport' --base k211 --milestone k211 --web

Or, if you don't have the GitHub CLI installed (we recommend you install it!):

# Push the branch to GitHub:
git push --set-upstream origin backport-13614-to-k211

# Create a pull request where the `base` branch is `k211` and the `compare`/`head` branch is `backport-13614-to-k211`.

# Remove the local backport branch
git switch main
git branch -D backport-13614-to-k211

@grafanabot
Copy link
Collaborator

The backport to k212 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-13614-to-k212 origin/k212
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 784e7d562fedec7134c8ed4e2cee8ccb7049e271

When the conflicts are resolved, stage and commit the changes:

git add . && git cherry-pick --continue

If you have the GitHub CLI installed:

# Push the branch to GitHub:
git push --set-upstream origin backport-13614-to-k212
# Create the PR body template
PR_BODY=$(gh pr view 13614 --json body --template 'Backport 784e7d562fedec7134c8ed4e2cee8ccb7049e271 from #13614{{ "\n\n---\n\n" }}{{ index . "body" }}')
# Create the PR on GitHub
echo "${PR_BODY}" | gh pr create --title 'chore: [k212] fix: Keep blocks referenced by newer metas' --body-file - --label 'size/L' --label 'type/bug' --label 'feature/blooms' --label 'backport' --base k212 --milestone k212 --web

Or, if you don't have the GitHub CLI installed (we recommend you install it!):

# Push the branch to GitHub:
git push --set-upstream origin backport-13614-to-k212

# Create a pull request where the `base` branch is `k212` and the `compare`/`head` branch is `backport-13614-to-k212`.

# Remove the local backport branch
git switch main
git branch -D backport-13614-to-k212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blooms: Builder can delete blocks that are referenced in up-to-date metas
3 participants