uber-go / tally

A Go metrics interface with fast buffered metrics and third party reporters
MIT License
850 stars 116 forks source link

Datarace spotted on scope_registry.go and scope.go #259

Open marcaudefroy opened 6 months ago

marcaudefroy commented 6 months ago

Hello!

Thanks you very much for this lib. Very appreciate your work.

I use this lib on my project and when I ran it with -trace option, a datarace has been detected. Here the stack trace, I hope this will helps.

Have a good day!

WARNING: DATA RACE
Read at 0x00c00002c708 by goroutine 22:
  github.com/uber-go/tally/v4.(*scopeRegistry).reportInternalMetrics.func1()
      /go/pkg/mod/github.com/uber-go/tally/v4@v4.1.16/scope_registry.go:314 +0x144
  github.com/uber-go/tally/v4.(*scopeRegistry).ForEachScope()
      /go/pkg/mod/github.com/uber-go/tally/v4@v4.1.16/scope_registry.go:159 +0x18b
  github.com/uber-go/tally/v4.(*scopeRegistry).reportInternalMetrics()
      /go/pkg/mod/github.com/uber-go/tally/v4@v4.1.16/scope_registry.go:310 +0x309
  github.com/uber-go/tally/v4.(*scopeRegistry).CachedReport()
      /go/pkg/mod/github.com/uber-go/tally/v4@v4.1.16/scope_registry.go:137 +0x9c
  github.com/uber-go/tally/v4.(*scope).reportRegistry()
      /go/pkg/mod/github.com/uber-go/tally/v4@v4.1.16/scope.go:278 +0xdc
  github.com/uber-go/tally/v4.(*scope).reportLoopRun()
      /go/pkg/mod/github.com/uber-go/tally/v4@v4.1.16/scope.go:270 +0x4e
  github.com/uber-go/tally/v4.(*scope).reportLoop()
      /go/pkg/mod/github.com/uber-go/tally/v4@v4.1.16/scope.go:258 +0xce
  github.com/uber-go/tally/v4.newRootScope.func1()
      /go/pkg/mod/github.com/uber-go/tally/v4@v4.1.16/scope.go:198 +0x97

Previous write at 0x00c00002c708 by goroutine 16:
  github.com/uber-go/tally/v4.(*scope).Gauge()
      /go/pkg/mod/github.com/uber-go/tally/v4@v4.1.16/scope.go:341 +0x4e5
  go.temporal.io/sdk/contrib/tally.(*prometheusNamingScope).Gauge()
      /go/pkg/mod/go.temporal.io/sdk/contrib/tally@v0.2.0/prometheus.go:55 +0x51
  go.temporal.io/sdk/contrib/tally.metricsHandler.Gauge()
      /go/pkg/mod/go.temporal.io/sdk/contrib/tally@v0.2.0/handler.go:88 +0x6c
  go.temporal.io/sdk/contrib/tally.(*metricsHandler).Gauge()
      <autogenerated>:1 +0x1f
  go.temporal.io/sdk/internal.newNumPollerMetric()
      /go/pkg/mod/go.temporal.io/sdk@v1.26.1/internal/internal_task_pollers.go:175 +0xc6
  go.temporal.io/sdk/internal.newWorkflowTaskPoller()
      /go/pkg/mod/go.temporal.io/sdk@v1.26.1/internal/internal_task_pollers.go:298 +0x164
  go.temporal.io/sdk/internal.newWorkflowTaskWorkerInternal()
      /go/pkg/mod/go.temporal.io/sdk@v1.26.1/internal/internal_worker.go:311 +0xd2
  go.temporal.io/sdk/internal.newWorkflowWorkerInternal()
      /go/pkg/mod/go.temporal.io/sdk@v1.26.1/internal/internal_worker.go:299 +0x224
  go.temporal.io/sdk/internal.newWorkflowWorker()
      /go/pkg/mod/go.temporal.io/sdk@v1.26.1/internal/internal_worker.go:237 +0x1745
  go.temporal.io/sdk/internal.NewAggregatedWorker()
      /go/pkg/mod/go.temporal.io/sdk@v1.26.1/internal/internal_worker.go:1629 +0x150a
  go.temporal.io/sdk/internal.NewWorker()
      /go/pkg/mod/go.temporal.io/sdk@v1.26.1/internal/worker.go:292 +0x98
  go.temporal.io/sdk/worker.New()
      /go/pkg/mod/go.temporal.io/sdk@v1.26.1/worker/worker.go:245 +0x57c
  stash.ovh.net/domains/temporal-robots/workers.NewRegistries()
      /tmp/103126bf707e50fff449876c796c4e15/run/workers/workers.go:74 +0x4da
  stash.ovh.net/domains/temporal-robots.startWorkers()
      /tmp/103126bf707e50fff449876c796c4e15/run/main.go:102 +0x52e
  stash.ovh.net/domains/temporal-robots.main()
      /tmp/103126bf707e50fff449876c796c4e15/run/main.go:79 +0xbe4
  stash.ovh.net/domains/temporal-robots.TestIntegration()
      /tmp/103126bf707e50fff449876c796c4e15/run/main_test.go:9 +0x1c
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      /usr/local/go/src/testing/testing.go:1742 +0x44

Goroutine 22 (running) created at:
  github.com/uber-go/tally/v4.newRootScope()
      /go/pkg/mod/github.com/uber-go/tally/v4@v4.1.16/scope.go:196 +0xdbd
  github.com/uber-go/tally/v4.NewRootScope()
      /go/pkg/mod/github.com/uber-go/tally/v4@v4.1.16/scope.go:118 +0x4a4
  stash.ovh.net/domains/temporal-robots/workers.newPrometheusScope()
      /tmp/103126bf707e50fff449876c796c4e15/run/workers/client.go:85 +0x478
  stash.ovh.net/domains/temporal-robots/workers.NewTemporalClient()
      /tmp/103126bf707e50fff449876c796c4e15/run/workers/client.go:48 +0x9c4
  stash.ovh.net/domains/temporal-robots.main()
      /tmp/103126bf707e50fff449876c796c4e15/run/main.go:64 +0x777
  stash.ovh.net/domains/temporal-robots.TestIntegration()
      /tmp/103126bf707e50fff449876c796c4e15/run/main_test.go:9 +0x1c
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      /usr/local/go/src/testing/testing.go:1742 +0x44

Goroutine 16 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1742 +0x825
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:2161 +0x85
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1689 +0x21e
  testing.runTests()
      /usr/local/go/src/testing/testing.go:2159 +0x8be
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:2027 +0xf17
  main.main()
      _testmain.go:81 +0x2e4
kevindweb commented 4 months ago

This is solved by #257 , @vdarulis do you know when the next release will happen to avoid bumping to an unreleased commit?