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(blooms): Fix findGaps when ownership goes to MaxUInt64 and that is covered by existing meta #12558

Merged

Conversation

salvacorts
Copy link
Contributor

What this PR does / why we need it:

If a meta and ownership tange covers till the end of the FP key-space (MaxUInt64), the current implementation of findGaps overflows and the keyspace covered by that meta is misreported as a gap:

leftBound = min(clippedMeta.Max+1, ownershipRange.Max+1)

In more detail:

leftBound = min(clippedMeta.Max+1, ownershipRange.Max+1)
// since we've already ensured that the meta is within the ownership range,
// we know the xor will be of length zero (when the meta is equal to the ownership range)
// or 1 (when the meta is a subset of the ownership range)
xors := searchRange.Unless(*clippedMeta)
if len(xors) == 0 {
// meta is equal to the ownership range. This means the meta
// covers this entire section of the ownership range.
continue
}
gaps = append(gaps, xors[0])
}
if leftBound <= ownershipRange.Max {
// There is a gap between the last meta and the end of the ownership range.
gaps = append(gaps, v1.NewBounds(leftBound, ownershipRange.Max))
}

If we only have one meta spanning the whole keyspace:

  • leftBound = min(clippedMeta.Max+1, ownershipRange.Max+1) Here clippedMeta.Max is MaxUint64 so +1 makes this 0
  • if len(xors) == 0 { is true so we end the loop
  • if leftBound <= ownershipRange.Max { since leftBound is 0 we get inside here and add the gap.

This PR fixes this by taking care of the overflows.

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

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
  • 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 marked this pull request as ready for review April 10, 2024 15:22
@salvacorts salvacorts requested a review from a team as a code owner April 10, 2024 15:22
Copy link
Contributor

@chaudum chaudum left a comment

Choose a reason for hiding this comment

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

lgtm

@salvacorts salvacorts merged commit 0ee2a61 into main Apr 17, 2024
12 checks passed
@salvacorts salvacorts deleted the salvacorts/fix-overflow-single-bloom-compactor-ownership branch April 17, 2024 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants