Data race in Praefect command caused by global logging instance
We have a data race in our test suite in cmd/praefect
that is caused by the global logging instance. We should refactor the code to avoid this global variable and instead pass it around either as a parameter or embedded in structs.
https://gitlab.com/gitlab-org/gitaly/-/jobs/3066897464
WARNING: DATA RACE
Write at 0x000005569f90 by goroutine 85:
gitlab.com/gitlab-org/gitaly/v15/cmd/praefect.trackRepositories.Exec()
/builds/gitlab-org/gitaly/cmd/praefect/subcmd_track_repositories.go:79 +0x15e
gitlab.com/gitlab-org/gitaly/v15/cmd/praefect.TestAddRepositories_Exec.func3.1()
/builds/gitlab-org/gitaly/cmd/praefect/subcmd_track_repositories_test.go:325 +0xe0e
testing.tRunner()
/usr/local/go/src/testing/testing.go:1439 +0x213
testing.(*T).Run.func1()
/usr/local/go/src/testing/testing.go:1486 +0x47
Previous read at 0x000005569f90 by goroutine 42:
[failed to restore the stack]
Goroutine 85 (running) created at:
testing.(*T).Run()
/usr/local/go/src/testing/testing.go:1486 +0x724
gitlab.com/gitlab-org/gitaly/v15/cmd/praefect.TestAddRepositories_Exec.func3()
/builds/gitlab-org/gitaly/cmd/praefect/subcmd_track_repositories_test.go:279 +0x75d
testing.tRunner()
/usr/local/go/src/testing/testing.go:1439 +0x213
testing.(*T).Run.func1()
/usr/local/go/src/testing/testing.go:1486 +0x47