census-instrumentation / opencensus-service

OpenCensus service allows OpenCensus libraries to export to an exporter service rather than having to link vendor-specific exports.
Apache License 2.0
153 stars 63 forks source link

receiver/prometheus: Test_jobGC data race #638

Closed odeke-em closed 1 year ago

odeke-em commented 4 years ago

Just noticed at https://travis-ci.org/census-instrumentation/opencensus-service/builds/654680902#L1937

--- FAIL: Test_jobGC (0.05s)
    metrics_adjuster_test.go:348: Error: JobGC: job 1, round 2- metrics timeseries empty due to job-level gc - expected: [], actual [metric_descriptor:<name:"CUMULATIVE_DOUBLE" description:"description CUMULATIVE_DOUBLE" type:CUMULATIVE_DOUBLE label_keys:<key:"k1" description:"description: k1" > label_keys:<key:"k2" description:"description: k2" > > timeseries:<start_timestamp:<nanos:1000000 > label_values:<value:"v1" has_value:true > label_values:<value:"v2" has_value:true > points:<timestamp:<nanos:4000000 > double_value:55 > > timeseries:<start_timestamp:<nanos:1000000 > label_values:<value:"v10" has_value:true > label_values:<value:"v20" has_value:true > points:<timestamp:<nanos:4000000 > double_value:60 > >  metric_descriptor:<name:"CUMULATIVE_DISTRIBUTION" description:"description CUMULATIVE_DISTRIBUTION" type:CUMULATIVE_DISTRIBUTION label_keys:<key:"k1" description:"description: k1" > label_keys:<key:"k2" description:"description: k2" > > timeseries:<start_timestamp:<nanos:1000000 > label_values:<value:"v1" has_value:true > label_values:<value:"v2" has_value:true > points:<timestamp:<nanos:4000000 > distribution_value:<count:26 sum:52 bucket_options:<explicit:<bounds:1 bounds:2 bounds:4 > > buckets:<count:5 > buckets:<count:6 > buckets:<count:7 > buckets:<count:8 > > > > timeseries:<start_timestamp:<nanos:1000000 > label_values:<value:"v10" has_value:true > label_values:<value:"v20" has_value:true > points:<timestamp:<nanos:4000000 > distribution_value:<count:71 sum:80 bucket_options:<explicit:<bounds:1 bounds:2 bounds:4 > > buckets:<count:15 > buckets:<count:46 > buckets:<count:3 > buckets:<count:7 > > > > ]
==================
WARNING: DATA RACE
Read at 0x00c0002e5968 by goroutine 65:
  github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal.(*JobsMap).gc()
      /home/travis/gopath/src/github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal/metrics_adjuster.go:131 +0x283
Previous write at 0x00c0002e5968 by goroutine 63:
  github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal.(*timeseriesMap).get()
      /home/travis/gopath/src/github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal/metrics_adjuster.go:73 +0x16b
  github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal.(*MetricsAdjuster).adjustMetricTimeseries()
      /home/travis/gopath/src/github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal/metrics_adjuster.go:223 +0x1c5
  github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal.(*MetricsAdjuster).adjustMetric()
      /home/travis/gopath/src/github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal/metrics_adjuster.go:214 +0xde
  github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal.(*MetricsAdjuster).AdjustMetrics()
      /home/travis/gopath/src/github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal/metrics_adjuster.go:192 +0x1b4
  github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal.runScript()
      /home/travis/gopath/src/github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal/metrics_adjuster_test.go:346 +0x2ba
  github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal.Test_jobGC()
      /home/travis/gopath/src/github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal/metrics_adjuster_test.go:320 +0x18b8
  testing.tRunner()
      /home/travis/.gimme/versions/go1.12.17.linux.amd64/src/testing/testing.go:865 +0x163
Goroutine 65 (running) created at:
  github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal.(*JobsMap).maybeGC()
      /home/travis/gopath/src/github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal/metrics_adjuster.go:144 +0x13c
  github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal.(*JobsMap).get()
      /home/travis/gopath/src/github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal/metrics_adjuster.go:155 +0x4cf
  github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal.Test_jobGC()
      /home/travis/gopath/src/github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver/internal/metrics_adjuster_test.go:318 +0x1809
  testing.tRunner()
      /home/travis/.gimme/versions/go1.12.17.linux.amd64/src/testing/testing.go:865 +0x163
Goroutine 63 (finished) created at:
  testing.(*T).Run()
      /home/travis/.gimme/versions/go1.12.17.linux.amd64/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/travis/.gimme/versions/go1.12.17.linux.amd64/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/travis/.gimme/versions/go1.12.17.linux.amd64/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/travis/.gimme/versions/go1.12.17.linux.amd64/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/travis/.gimme/versions/go1.12.17.linux.amd64/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:152 +0x334
==================
odeke-em commented 4 years ago

Found from PR https://github.com/census-instrumentation/opencensus-service/pull/637

dashpole commented 1 year ago

This repository is now archived, and is succeeded by https://github.com/open-telemetry/opentelemetry-collector.