tikv / tikv/pd

Data race in CI

Open
#5,028 0 comments 0 reactions 0 assignees View on GitHub
type/ci
Dominant language
Go
Stars
1.2k
Forks
783
Avg merge
5d 21h
Merged PRs (30d)
36

Description

## Flaky Test

### Which jobs are failing
```
==================
WARNING: DATA RACE
Write at 0x00c000f97930 by goroutine 237:
reflect.Value.SetString()
/opt/hostedtoolcache/go/1.18.0/x64/src/reflect/value.go:2291 +0x90
encoding/json.(*decodeState).literalStore()
/opt/hostedtoolcache/go/1.18.0/x64/src/encoding/json/decode.go:966 +0xa29
encoding/json.(*decodeState).value()
/opt/hostedtoolcache/go/1.18.0/x64/src/encoding/json/decode.go:387 +0x24e
encoding/json.(*decodeState).array()
/opt/hostedtoolcache/go/1.18.0/x64/src/encoding/json/decode.go:561 +0x9ee
encoding/json.(*decodeState).value()
/opt/hostedtoolcache/go/1.18.0/x64/src/encoding/json/decode.go:363 +0x128
encoding/json.(*decodeState).object()
/opt/hostedtoolcache/go/1.18.0/x64/src/encoding/json/decode.go:774 +0x11e4
encoding/json.(*decodeState).value()
/opt/hostedtoolcache/go/1.18.0/x64/src/encoding/json/decode.go:373 +0xb2
encoding/json.(*decodeState).unmarshal()
/opt/hostedtoolcache/go/1.18.0/x64/src/encoding/json/decode.go:180 +0x3d6
encoding/json.Unmarshal()
/opt/hostedtoolcache/go/1.18.0/x64/src/encoding/json/decode.go:107 +0x225
github.com/tikv/pd/server/schedulers.(*hotRegionSchedulerConfig).handleSetConfig()
/home/runner/work/pd/pd/server/schedulers/hot_region_config.go:[314](https://github.com/tikv/pd/runs/6585977310?check_suite_focus=true#step:5:315) +0x28b
github.com/tikv/pd/server/schedulers.(*hotRegionSchedulerConfig).handleSetConfig-fm()
:1 +0x57
net/http.HandlerFunc.ServeHTTP()
/opt/hostedtoolcache/go/1.18.0/x64/src/net/http/server.go:2084 +0x4d
github.com/gorilla/mux.(*Router).ServeHTTP()
/home/runner/go/pkg/mod/github.com/gorilla/mux@v1.7.4/mux.go:210 +0x361
github.com/tikv/pd/server/schedulers.(*hotRegionSchedulerConfig).ServeHTTP()
/home/runner/work/pd/pd/server/schedulers/hot_region_config.go:292 +0x275
github.com/tikv/pd/server/schedulers.(*hotScheduler).ServeHTTP()
/home/runner/work/pd/pd/server/schedulers/hot_region.go:132 +0x79
net/http.StripPrefix.func1()
/opt/hostedtoolcache/go/1.18.0/x64/src/net/http/server.go:2127 +0x56c
net/http.HandlerFunc.ServeHTTP()
/opt/hostedtoolcache/go/1.18.0/x64/src/net/http/server.go:2084 +0x4d
net/http.(*ServeMux).ServeHTTP()
/opt/hostedtoolcache/go/1.18.0/x64/src/net/http/server.go:2462 +0xc5
github.com/tikv/pd/server/api.(*schedulerConfigHandler).GetSchedulerConfig()
/home/runner/work/pd/pd/server/api/scheduler.go:330 +0x199
github.com/tikv/pd/server/api.(*schedulerConfigHandler).GetSchedulerConfig-fm()
:1 +0x57
github.com/urfave/negroni.WrapFunc.func1()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:56 +0x56
github.com/urfave/negroni.HandlerFunc.ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:29 +0x57
github.com/urfave/negroni.middleware.ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:38 +0x130
github.com/urfave/negroni.middleware.ServeHTTP-fm()
:1 +0x84
github.com/tikv/pd/server/api.(*auditMiddleware).ServeHTTP()
/home/runner/work/pd/pd/server/api/middleware.go:120 +0x401
github.com/urfave/negroni.middleware.ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:38 +0x130
github.com/urfave/negroni.middleware.ServeHTTP-fm()
:1 +0x84
github.com/tikv/pd/server/api.(*requestInfoMiddleware).ServeHTTP()
/home/runner/work/pd/pd/server/api/middleware.go:60 +0x1111
github.com/urfave/negroni.middleware.ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:38 +0x130
github.com/urfave/negroni.(*Negroni).ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:96 +0x1b8
github.com/gorilla/mux.(*Router).ServeHTTP()
/home/runner/go/pkg/mod/github.com/gorilla/mux@v1.7.4/mux.go:210 +0x361
github.com/urfave/negroni.Wrap.func1()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:46 +0x69
github.com/urfave/negroni.HandlerFunc.ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:29 +0x57
github.com/urfave/negroni.middleware.ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:38 +0x130
github.com/urfave/negroni.middleware.ServeHTTP-fm()
:1 +0x84
github.com/tikv/pd/pkg/apiutil/serverapi.(*redirector).ServeHTTP()
/home/runner/work/pd/pd/pkg/apiutil/serverapi/middleware.go:93 +0x17c
github.com/urfave/negroni.middleware.ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:38 +0x130
github.com/urfave/negroni.middleware.ServeHTTP-fm()
:1 +0x84
github.com/tikv/pd/pkg/apiutil/serverapi.(*runtimeServiceValidator).ServeHTTP()
/home/runner/work/pd/pd/pkg/apiutil/serverapi/middleware.go:53 +0x12c
github.com/urfave/negroni.middleware.ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:38 +0x130
github.com/urfave/negroni.(*Negroni).ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:96 +0x1b8
github.com/gorilla/mux.(*Router).ServeHTTP()
/home/runner/go/pkg/mod/github.com/gorilla/mux@v1.7.4/mux.go:210 +0x361
github.com/gorilla/mux.(*Router).ServeHTTP()
/home/runner/go/pkg/mod/github.com/gorilla/mux@v1.7.4/mux.go:210 +0x361
github.com/urfave/negroni.Wrap.func1()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:46 +0x69
github.com/urfave/negroni.HandlerFunc.ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:29 +0x57
github.com/urfave/negroni.middleware.ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:38 +0x130
github.com/urfave/negroni.middleware.ServeHTTP-fm()
:1 +0x84
github.com/urfave/negroni.(*Recovery).ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/recovery.go:193 +0xed
github.com/urfave/negroni.middleware.ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:38 +0x130
github.com/urfave/negroni.(*Negroni).ServeHTTP()
/home/runner/go/pkg/mod/github.com/urfave/negroni@v0.3.0/negroni.go:96 +0x1b8
net/http.(*ServeMux).ServeHTTP()
/opt/hostedtoolcache/go/1.18.0/x64/src/net/http/server.go:2462 +0xc5
go.etcd.io/etcd/embed.(*accessController).ServeHTTP()
/home/runner/go/pkg/mod/go.etcd.io/etcd@v0.5.0-alpha.5.0.2019102[317](https://github.com/tikv/pd/runs/6585977310?check_suite_focus=true#step:5:318)1146-3cf2f69b5738/embed/serve.go:[359](https://github.com/tikv/pd/runs/6585977310?check_suite_focus=true#step:5:360) +0x93d
net/http.serverHandler.ServeHTTP()
/opt/hostedtoolcache/go/1.18.0/x64/src/net/http/server.go:2916 +0x896
net/http.(*conn).serve()
/opt/hostedtoolcache/go/1.18.0/x64/src/net/http/server.go:1966 +0xbaa
net/http.(*Server).Serve.func3()
/opt/hostedtoolcache/go/1.18.0/x64/src/net/http/server.go:3071 +0x58

Previous read at 0x00c000f97930 by goroutine 76:
github.com/tikv/pd/server/schedulers.prioritiesToDim()
/home/runner/work/pd/pd/server/schedulers/hot_region.go:1262 +0x84
github.com/tikv/pd/server/schedulers.(*balanceSolver).init()
/home/runner/work/pd/pd/server/schedulers/hot_region.go:422 +0xa3c
github.com/tikv/pd/server/schedulers.newBalanceSolver()
/home/runner/work/pd/pd/server/schedulers/hot_region.go:455 +0x157
github.com/tikv/pd/server/schedulers.(*hotScheduler).balanceHotReadRegions()
/home/runner/work/pd/pd/server/schedulers/hot_region.go:264 +0xc7
github.com/tikv/pd/server/schedulers.(*hotScheduler).dispatch()
/home/runner/work/pd/pd/server/schedulers/hot_region.go:167 +0x204
github.com/tikv/pd/server/schedulers.(*hotScheduler).Schedule()
/home/runner/work/pd/pd/server/schedulers/hot_region.go:152 +0x224
github.com/tikv/pd/server/cluster.(*scheduleController).Schedule()
/home/runner/work/pd/pd/server/cluster/coordinator.go:891 +0x104
github.com/tikv/pd/server/cluster.(*coordinator).runScheduler()
/home/runner/work/pd/pd/server/cluster/coordinator.go:808 +0x405
github.com/tikv/pd/server/cluster.(*coordinator).addScheduler.func2()
/home/runner/work/pd/pd/server/cluster/coordinator.go:641 +0x47

Goroutine 237 (running) created at:
net/http.(*Server).Serve()
/opt/hostedtoolcache/go/1.18.0/x64/src/net/http/server.go:3071 +0x80c
go.etcd.io/etcd/embed.(*serveCtx).serve.func3()
/home/runner/go/pkg/mod/go.etcd.io/etcd@v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738/embed/serve.go:135 +0x58

Goroutine 76 (running) created at:
github.com/tikv/pd/server/cluster.(*coordinator).addScheduler()
/home/runner/work/pd/pd/server/cluster/coordinator.go:641 +0x35e
github.com/tikv/pd/server/cluster.(*coordinator).run()
/home/runner/work/pd/pd/server/cluster/coordinator.go:[402](https://github.com/tikv/pd/runs/6585977310?check_suite_focus=true#step:5:403) +0x19da
github.com/tikv/pd/server/cluster.(*coordinator).runUntilStop()
/home/runner/work/pd/pd/server/cluster/coordinator.go:305 +0x44
github.com/tikv/pd/server/cluster.(*RaftCluster).runCoordinator()
/home/runner/work/pd/pd/server/cluster/cluster.go:[440](https://github.com/tikv/pd/runs/6585977310?check_suite_focus=true#step:5:441) +0xdd
github.com/tikv/pd/server/cluster.(*RaftCluster).Start.func2()
/home/runner/work/pd/pd/server/cluster/cluster.go:274 +0x39
==================
```

### CI link
https://github.com/tikv/pd/runs/6585977310?check_suite_focus=true

### Reason for failure (if possible)

### Anything else

Contributor guide

Open the contributing guide

Research direction

Start with the race report at server/schedulers/hot_region_config.go:314 and the concurrent read in server/schedulers/hot_region.go:1262. Use the linked CI run and race detector output to trace the interaction between configuration updates and scheduler execution. Done means the reported data race no longer occurs in CI.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.