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 buffered iterator #9976

Merged
merged 2 commits into from
Jul 19, 2023
Merged

Fix buffered iterator #9976

merged 2 commits into from
Jul 19, 2023

Conversation

salvacorts
Copy link
Contributor

@salvacorts salvacorts commented Jul 19, 2023

What this PR does / why we need it:

In #9700, we added support for writing non-indexed labels from entries into chunks. This PR introduced two bugs:

  • When the buffered iterator is closed, the buffer to read metadata labels is put back into the pool but not set to nil. Subsequent uses of the iterator may write on top of the buffer that was put back on the pool. This may lead to inconsistent/incorrect results.
  • Inside the buffered iterator, we were not correctly handling EOFs while reading the number of labels and each label length. This was due to the lastAttemp variable not being reset.

This PR adds a new test for these two bugs and also fixes them.

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

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
    • If the change is worth mentioning in the release notes, add add-to-release-notes label
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_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

@salvacorts salvacorts marked this pull request as ready for review July 19, 2023 10:46
@salvacorts salvacorts requested a review from a team as a code owner July 19, 2023 10:46
Copy link
Contributor

@sandeepsukhani sandeepsukhani left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@vlad-diachenko vlad-diachenko 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 78aad0b into main Jul 19, 2023
@salvacorts salvacorts deleted the salvacorts/fix-buf-buffered-iterator branch July 19, 2023 12:59
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.

3 participants