isucon / isucon11-qualify

ISUCON11 予選 (ISUCONDITION)
https://isucon.net/archives/55821036.html
MIT License
166 stars 83 forks source link

[bench] data raceが検出される #1445

Open Nagarei opened 3 years ago

Nagarei commented 3 years ago

https://github.com/isucon/isucon11-qualify/pull/1428

↓これでは?


==================
WARNING: DATA RACE
Write at 0x00c000499030 by goroutine 31:
  runtime.closechan()
      /home/isucon/local/go/src/runtime/chan.go:355 +0x0
  github.com/isucon/isucandar/score.(*Score).Close()
      /home/isucon/go/pkg/mod/github.com/isucon/isucandar@v0.0.0-20210821075549-ee64d0785035/score/score.go:82 +0xa8
  github.com/isucon/isucandar/score.(*Score).collect.func1()
      /home/isucon/go/pkg/mod/github.com/isucon/isucandar@v0.0.0-20210821075549-ee64d0785035/score/score.go:56 +0x64

Previous read at 0x00c000499030 by goroutine 124:
  runtime.chansend()
      /home/isucon/local/go/src/runtime/chan.go:158 +0x0
  github.com/isucon/isucandar/score.(*Score).Add()
      /home/isucon/go/pkg/mod/github.com/isucon/isucandar@v0.0.0-20210821075549-ee64d0785035/score/score.go:74 +0xe5
  github.com/isucon/isucandar.(*BenchmarkStep).AddScore()
      /home/isucon/go/pkg/mod/github.com/isucon/isucandar@v0.0.0-20210821075549-ee64d0785035/benchmark_step.go:37 +0x1d2
  github.com/isucon/isucon11-qualify/bench/scenario.(*Scenario).postConditionNumReporter.func1()
      /home/isucon/bench_new/scenario/posting.go:72 +0x186
  github.com/isucon/isucon11-qualify/bench/scenario.(*Scenario).postConditionNumReporter()
      /home/isucon/bench_new/scenario/posting.go:90 +0xf0
  github.com/isucon/isucon11-qualify/bench/scenario.(*Scenario).Load.func2()
      /home/isucon/bench_new/scenario/load.go:92 +0x56

Goroutine 31 (running) created at:
  github.com/isucon/isucandar/score.(*Score).collect()
      /home/isucon/go/pkg/mod/github.com/isucon/isucandar@v0.0.0-20210821075549-ee64d0785035/score/score.go:54 +0x64

Goroutine 124 (running) created at:
  github.com/isucon/isucon11-qualify/bench/scenario.(*Scenario).Load()
      /home/isucon/bench_new/scenario/load.go:89 +0x49d
  github.com/isucon/isucandar.LoadScenario.Load-fm()
      /home/isucon/go/pkg/mod/github.com/isucon/isucandar@v0.0.0-20210821075549-ee64d0785035/benchmark_scenario.go:17 +0x79
  github.com/isucon/isucandar.(*Benchmark).Start.func3.1.1()
      /home/isucon/go/pkg/mod/github.com/isucon/isucandar@v0.0.0-20210821075549-ee64d0785035/benchmark.go:126 +0x5b
  github.com/isucon/isucandar.panicWrapper()
      /home/isucon/go/pkg/mod/github.com/isucon/isucandar@v0.0.0-20210821075549-ee64d0785035/benchmark.go:204 +0xd2
  github.com/isucon/isucandar.(*Benchmark).Start.func3.1()
      /home/isucon/go/pkg/mod/github.com/isucon/isucandar@v0.0.0-20210821075549-ee64d0785035/benchmark.go:126 +0xd2
  github.com/isucon/isucandar/parallel.(*Parallel).Do.func1()
      /home/isucon/go/pkg/mod/github.com/isucon/isucandar@v0.0.0-20210821075549-ee64d0785035/parallel/parallel.go:68 +0xa7
==================
Nagarei commented 3 years ago

close(s.queue)と、s.queue <- tagで競合している

Nagarei commented 3 years ago

困りはするけどCloseが呼ばれるのはmainのctxが終了したときなのでデッドロックとは関係が無さそうなのと、デバッグコードが影響していそう