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: Add mutex and setter/getter for addresses in test #12793

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

paul1r
Copy link
Collaborator

@paul1r paul1r commented Apr 25, 2024

What this PR does / why we need it:
Before fix:

==================
WARNING: DATA RACE
Read at 0x00c0001e6c10 by goroutine 433:
  sort.StringSlice.Less()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/sort/sort.go:154 +0x6c
  sort.(*StringSlice).Less()
      <autogenerated>:1 +0x20
  sort.insertionSort()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/sort/zsortinterface.go:12 +0xd8
  sort.pdqsort()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/sort/zsortinterface.go:73 +0x2c8
  sort.Sort()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/sort/sort.go:51 +0x6c
  sort.Strings()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/sort/sort.go:176 +0x154
  github.com/grafana/loki/v3/pkg/bloomgateway.(*JumpHashClientPool).updateLoop()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/bloomgateway/client_pool.go:107 +0x140
  github.com/grafana/loki/v3/pkg/bloomgateway.NewJumpHashClientPool.func1()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/bloomgateway/client_pool.go:62 +0x58

Previous write at 0x00c0001e6c10 by goroutine 430:
  github.com/grafana/loki/v3/pkg/bloomgateway.TestJumpHashClientPool_UpdateLoop()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/bloomgateway/client_pool_test.go:28 +0x1f4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/testing/testing.go:1595 +0x1b0
  testing.(*T).Run.func1()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/testing/testing.go:1648 +0x40

Goroutine 433 (running) created at:
  github.com/grafana/loki/v3/pkg/bloomgateway.NewJumpHashClientPool()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/bloomgateway/client_pool.go:62 +0x4e4
  github.com/grafana/loki/v3/pkg/bloomgateway.TestJumpHashClientPool_UpdateLoop()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/bloomgateway/client_pool_test.go:23 +0xe4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/testing/testing.go:1595 +0x1b0
  testing.(*T).Run.func1()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/testing/testing.go:1648 +0x40

Goroutine 430 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/testing/testing.go:1648 +0x5e8
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/testing/testing.go:2054 +0x80
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/testing/testing.go:1595 +0x1b0
  testing.runTests()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/testing/testing.go:2052 +0x6e4
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.21.6/libexec/src/testing/testing.go:1925 +0x9ec
  main.main()
      _testmain.go:89 +0x294
==================

After fix:

go test -race -count=100 . -run TestJumpHashClientPool_UpdateLoop   
ok  	github.com/grafana/loki/v3/pkg/bloomgateway	21.858s

Which issue(s) this PR fixes:
Relates to: #8586

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

@paul1r paul1r requested a review from a team as a code owner April 25, 2024 15:12
@paul1r paul1r merged commit 4cc3a73 into main Apr 25, 2024
59 checks passed
@paul1r paul1r deleted the paul1r/jumpclient_pool_test_data_race branch April 25, 2024 16:00
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