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: Fix for how the loop sync is done #12941

Merged
merged 2 commits into from May 13, 2024
Merged

Conversation

paul1r
Copy link
Contributor

@paul1r paul1r commented May 11, 2024

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

go test -race -count=10 . -timeout 30s
==================
WARNING: DATA RACE
Write at 0x00c000213030 by goroutine 493:
  runtime.racewrite()
      <autogenerated>:1 +0x10
  github.com/grafana/loki/v3/pkg/storage/stores/shipper/indexshipper/downloads.(*tableManager).Stop()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/storage/stores/shipper/indexshipper/downloads/table_manager.go:156 +0x50
  github.com/grafana/loki/v3/pkg/storage/stores/shipper/indexshipper/downloads.buildTestTableManager.func2()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/storage/stores/shipper/indexshipper/downloads/table_manager_test.go:68 +0x3c
  runtime.deferreturn()
      /opt/homebrew/Cellar/go/1.22.2/libexec/src/runtime/panic.go:602 +0x5c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.22.2/libexec/src/testing/testing.go:1689 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.22.2/libexec/src/testing/testing.go:1742 +0x40

Previous read at 0x00c000213030 by goroutine 494:
  runtime.raceread()
      <autogenerated>:1 +0x10
  github.com/grafana/loki/v3/pkg/storage/stores/shipper/indexshipper/downloads.(*tableManager).loop()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/storage/stores/shipper/indexshipper/downloads/table_manager.go:120 +0x50
  github.com/grafana/loki/v3/pkg/storage/stores/shipper/indexshipper/downloads.NewTableManager.gowrap1()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/storage/stores/shipper/indexshipper/downloads/table_manager.go:114 +0x34

Goroutine 493 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.22.2/libexec/src/testing/testing.go:1742 +0x5e4
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.22.2/libexec/src/testing/testing.go:2161 +0x80
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.22.2/libexec/src/testing/testing.go:1689 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.22.2/libexec/src/testing/testing.go:2159 +0x6e0
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.22.2/libexec/src/testing/testing.go:2027 +0xb74
  main.main()
      _testmain.go:69 +0x294

Goroutine 494 (finished) created at:
  github.com/grafana/loki/v3/pkg/storage/stores/shipper/indexshipper/downloads.NewTableManager()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/storage/stores/shipper/indexshipper/downloads/table_manager.go:114 +0x400
  github.com/grafana/loki/v3/pkg/storage/stores/shipper/indexshipper/downloads.buildTestTableManager()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/storage/stores/shipper/indexshipper/downloads/table_manager_test.go:62 +0x2fc
  github.com/grafana/loki/v3/pkg/storage/stores/shipper/indexshipper/downloads.TestTableManager_cleanupCache()
      /Users/progers/dev/src/github.com/grafana/loki/pkg/storage/stores/shipper/indexshipper/downloads/table_manager_test.go:103 +0x44
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.22.2/libexec/src/testing/testing.go:1689 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.22.2/libexec/src/testing/testing.go:1742 +0x40
==================
--- FAIL: TestTableManager_cleanupCache (0.00s)
    testing.go:1398: race detected during execution of test
FAIL
FAIL	github.com/grafana/loki/v3/pkg/storage/stores/shipper/indexshipper/downloads	21.587s
FAIL

After fix:

 go test -race -count=10 . -timeout 30s
ok  	github.com/grafana/loki/v3/pkg/storage/stores/shipper/indexshipper/downloads	22.217s
progers@Pauls-MacBook-Pro downloads % 

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
    • 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

@paul1r paul1r requested a review from a team as a code owner May 11, 2024 11:11
@paul1r paul1r merged commit 5cd850e into main May 13, 2024
58 checks passed
@paul1r paul1r deleted the paul1r/index_shipper_data_race_fix branch May 13, 2024 11:38
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.

None yet

2 participants