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

[BUG] Race condition in metric.DefaultMetricSearcher #488

Open
sczyh30 opened this issue Oct 11, 2022 · 0 comments
Open

[BUG] Race condition in metric.DefaultMetricSearcher #488

sczyh30 opened this issue Oct 11, 2022 · 0 comments
Assignees
Labels
good first issue Good for newcomers kind/bug Something isn't working

Comments

@sczyh30
Copy link
Member

sczyh30 commented Oct 11, 2022

Issue Description

Type: bug report

Describe what happened

Race condition was detected in metric.DefaultMetricSearcher:

WARNING: DATA RACE
Read at 0x00c000510f00 by goroutine 59:
  github.com/alibaba/sentinel-golang/core/log/metric.(*DefaultMetricSearcher).getOffsetStartAndFileIdx()
      /Users/sczyh30/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.3/core/log/metric/searcher.go:101 +0x106
  github.com/alibaba/sentinel-golang/core/log/metric.(*DefaultMetricSearcher).searchOffsetAndRead()
      /Users/sczyh30/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.3/core/log/metric/searcher.go:71 +0x12a
  github.com/alibaba/sentinel-golang/core/log/metric.(*DefaultMetricSearcher).FindByTimeAndResource()
      /Users/sczyh30/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.3/core/log/metric/searcher.go:53 +0xc7
   ...

Previous write at 0x00c000510f00 by goroutine 31:
  github.com/alibaba/sentinel-golang/core/log/metric.(*DefaultMetricSearcher).findOffsetToStart()
      /Users/sczyh30/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.3/core/log/metric/searcher.go:165 +0x5ca
  github.com/alibaba/sentinel-golang/core/log/metric.(*DefaultMetricSearcher).searchOffsetAndRead()
      /Users/sczyh30/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.3/core/log/metric/searcher.go:80 +0x1fd
  github.com/alibaba/sentinel-golang/core/log/metric.(*DefaultMetricSearcher).FindByTimeAndResource()
      /Users/sczyh30/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.3/core/log/metric/searcher.go:53 +0xc7
  ...

Describe what you expected to happen

No race condition.

How to reproduce it (as minimally and precisely as possible)

Run a demo and invoke the search function of the MetricSearcher concurrently.

Tell us your environment

Sentinel Go v1.0.3

Anything else we need to know?

NONE

@sczyh30 sczyh30 added kind/bug Something isn't working good first issue Good for newcomers labels Oct 11, 2022
@binbin0325 binbin0325 self-assigned this Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants