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

test: Fix race condition in LogQL test #12247

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

bboreham
Copy link
Contributor

@bboreham bboreham commented Mar 18, 2024

What this PR does / why we need it:
Fix a race condition in LogQL test.
The iterators used in TestStepEvaluator_Error were shared across goroutines, leading to a warning from the race detector. Instead, return a new data structure each time.

Also revert #12223 and #12225 which were a previous change to remove the warning, but negatively impact performance.

goos: darwin
goarch: arm64
pkg: github.com/grafana/loki/pkg/logql
                                            │ before.txt  │             after.txt             │
                                            │   sec/op    │   sec/op     vs base              │
_RangeVectorIteratorCompare/streaming_agg-8   4.791µ ± 1%   4.793µ ± 3%       ~ (p=0.937 n=6)
_RangeVectorIteratorCompare/batch_agg-8       6.760µ ± 2%   6.589µ ± 1%  -2.53% (p=0.009 n=6)
_RangeVectorIterator-8                        4.855µ ± 1%   4.758µ ± 2%       ~ (p=0.121 n=6)
geomean                                       5.397µ        5.316µ       -1.50%

                                            │  before.txt  │             after.txt              │
                                            │     B/op     │     B/op      vs base              │
_RangeVectorIteratorCompare/streaming_agg-8   3.872Ki ± 0%   3.856Ki ± 0%  -0.40% (p=0.002 n=6)
_RangeVectorIteratorCompare/batch_agg-8       33.99Ki ± 0%   33.97Ki ± 0%  -0.06% (p=0.002 n=6)
_RangeVectorIterator-8                        3.880Ki ± 0%   3.856Ki ± 0%  -0.60% (p=0.002 n=6)
geomean                                       7.993Ki        7.965Ki       -0.35%

                                            │ before.txt │            after.txt             │
                                            │ allocs/op  │ allocs/op   vs base              │
_RangeVectorIteratorCompare/streaming_agg-8   65.00 ± 0%   63.00 ± 0%  -3.08% (p=0.002 n=6)
_RangeVectorIteratorCompare/batch_agg-8       39.00 ± 0%   37.00 ± 0%  -5.13% (p=0.002 n=6)
_RangeVectorIterator-8                        66.00 ± 0%   64.00 ± 0%  -3.03% (p=0.002 n=6)
geomean                                       55.10        53.04       -3.75%

Which issue(s) this PR fixes:
Part of #8586

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • NA Documentation added
  • Tests updated
  • NA CHANGELOG.md updated

This reverts commit 3dd5b70.
We don't want atomic iterators.
…)"

This reverts commit 60dcee1.
We don't want atomic iterators.
@bboreham bboreham requested a review from a team as a code owner March 18, 2024 16:46
This leads to warnings from the race detector.
Instead, return a new data structure each time.
@bboreham bboreham changed the title Fix race condition in LogQL test test: Fix race condition in LogQL test Mar 18, 2024
Copy link
Member

@na-- na-- left a comment

Choose a reason for hiding this comment

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

Thank you for catching and fixing this! 🙇

@cyriltovena cyriltovena merged commit 9621d5c into grafana:main Mar 19, 2024
11 checks passed
@bboreham bboreham deleted the series-iterator-sharing branch March 19, 2024 15:48
edsoncelio pushed a commit to edsoncelio/loki that referenced this pull request Mar 22, 2024
rhnasc pushed a commit to inloco/loki that referenced this pull request Apr 12, 2024
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