[BUG] Race condition in metric.DefaultMetricSearcher
sczyh30 opened this issue · 0 comments
sczyh30 commented
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