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

Datarace in TestTSOKeyspaceGroupMerge #6721

Closed
lhy1024 opened this issue Jun 29, 2023 · 1 comment · Fixed by #6723
Closed

Datarace in TestTSOKeyspaceGroupMerge #6721

lhy1024 opened this issue Jun 29, 2023 · 1 comment · Fixed by #6723
Labels
type/ci The issue is related to CI.

Comments

@lhy1024
Copy link
Contributor

lhy1024 commented Jun 29, 2023

Flaky Test

Which jobs are failing

TestTSOKeyspaceGroupMerge

2023-06-29T12:00:49.5749865Z ==================
2023-06-29T12:00:49.5750143Z WARNING: DATA RACE
2023-06-29T12:00:49.5750477Z Write at 0x00c0077df1c0 by goroutine 90074:
2023-06-29T12:00:49.5751019Z   github.com/tikv/pd/pkg/tso.(*KeyspaceGroupManager).finishMergeKeyspaceGroup()
2023-06-29T12:00:49.5751730Z       /home/runner/work/pd/pd/pkg/tso/keyspace_group_manager.go:1152 +0x558
2023-06-29T12:00:49.5752278Z   github.com/tikv/pd/pkg/tso.(*KeyspaceGroupManager).mergingChecker()
2023-06-29T12:00:49.5752954Z       /home/runner/work/pd/pd/pkg/tso/keyspace_group_manager.go:1274 +0x34cf
2023-06-29T12:00:49.5753558Z   github.com/tikv/pd/pkg/tso.(*KeyspaceGroupManager).updateKeyspaceGroup.func2()
2023-06-29T12:00:49.5754379Z       /home/runner/work/pd/pd/pkg/tso/keyspace_group_manager.go:631 +0x96
2023-06-29T12:00:49.5754623Z 
2023-06-29T12:00:49.5754812Z Previous read at 0x00c0077df1c0 by goroutine 92722:
2023-06-29T12:00:49.5755478Z   github.com/tikv/pd/pkg/storage/endpoint.(*KeyspaceGroup).IsMerging()
2023-06-29T12:00:49.5756170Z       /home/runner/work/pd/pd/pkg/storage/endpoint/tso_keyspace_group.go:140 +0xf0
2023-06-29T12:00:49.5756722Z   github.com/tikv/pd/pkg/tso.(*KeyspaceGroupManager).checkTSOMerge()
2023-06-29T12:00:49.5757396Z       /home/runner/work/pd/pd/pkg/tso/keyspace_group_manager.go:1298 +0xfb
2023-06-29T12:00:49.5757954Z   github.com/tikv/pd/pkg/tso.(*KeyspaceGroupManager).HandleTSORequest()
2023-06-29T12:00:49.5758775Z       /home/runner/work/pd/pd/pkg/tso/keyspace_group_manager.go:962 +0x16f
2023-06-29T12:00:49.5759419Z   github.com/tikv/pd/tests/integrations/mcs/tso.(*tsoKeyspaceGroupManagerTestSuite).requestTSO()
2023-06-29T12:00:49.5760249Z       /home/runner/work/pd/pd/tests/integrations/mcs/tso/keyspace_group_manager_test.go:301 +0x158
2023-06-29T12:00:49.5761025Z   github.com/tikv/pd/tests/integrations/mcs/tso.(*tsoKeyspaceGroupManagerTestSuite).TestTSOKeyspaceGroupMerge.func2()
2023-06-29T12:00:49.5761892Z       /home/runner/work/pd/pd/tests/integrations/mcs/tso/keyspace_group_manager_test.go:640 +0x6f
2023-06-29T12:00:49.5762440Z   github.com/stretchr/testify/assert.Eventually.func1()
2023-06-29T12:00:49.5784167Z       /home/runner/go/pkg/mod/github.com/stretchr/[email protected]/assert/assertions.go:1737 +0x39
2023-06-29T12:00:49.5784559Z 
2023-06-29T12:00:49.5784750Z Goroutine 90074 (running) created at:
2023-06-29T12:00:49.5785359Z   github.com/tikv/pd/pkg/tso.(*KeyspaceGroupManager).updateKeyspaceGroup()
2023-06-29T12:00:49.5786096Z       /home/runner/work/pd/pd/pkg/tso/keyspace_group_manager.go:631 +0x718
2023-06-29T12:00:49.5786706Z   github.com/tikv/pd/pkg/tso.(*KeyspaceGroupManager).InitializeGroupWatchLoop.func1()
2023-06-29T12:00:49.5787412Z       /home/runner/work/pd/pd/pkg/tso/keyspace_group_manager.go:462 +0x116
2023-06-29T12:00:49.5788318Z   github.com/tikv/pd/pkg/utils/etcdutil.(*LoopWatcher).watch()
2023-06-29T12:00:49.5790143Z       /home/runner/work/pd/pd/pkg/utils/etcdutil/etcdutil.go:538 +0x1d32
2023-06-29T12:00:49.5790703Z   github.com/tikv/pd/pkg/utils/etcdutil.(*LoopWatcher).StartWatchLoop()
2023-06-29T12:00:49.5791353Z       /home/runner/work/pd/pd/pkg/utils/etcdutil/etcdutil.go:439 +0x484
2023-06-29T12:00:49.5791968Z   github.com/tikv/pd/pkg/tso.(*KeyspaceGroupManager).InitializeGroupWatchLoop.func5()
2023-06-29T12:00:49.5793268Z       /home/runner/work/pd/pd/pkg/tso/keyspace_group_manager.go:506 +0x39
2023-06-29T12:00:49.5795712Z 
2023-06-29T12:00:49.5795925Z Goroutine 92722 (finished) created at:
2023-06-29T12:00:49.5796364Z   github.com/stretchr/testify/assert.Eventually()
2023-06-29T12:00:49.5797098Z       /home/runner/go/pkg/mod/github.com/stretchr/[email protected]/assert/assertions.go:1737 +0x3a5
2023-06-29T12:00:49.5797616Z   github.com/stretchr/testify/require.Eventually()
2023-06-29T12:00:49.5798327Z       /home/runner/go/pkg/mod/github.com/stretchr/[email protected]/require/require.go:361 +0xb8
2023-06-29T12:00:49.5800973Z   github.com/stretchr/testify/require.(*Assertions).Eventually()
2023-06-29T12:00:49.5801788Z       /home/runner/go/pkg/mod/github.com/stretchr/[email protected]/require/require_forward.go:289 +0xc4
2023-06-29T12:00:49.5802325Z   github.com/tikv/pd/pkg/utils/testutil.Eventually()
2023-06-29T12:00:49.5803673Z       /home/runner/work/pd/pd/pkg/utils/testutil/testutil.go:63 +0x18e
2023-06-29T12:00:49.5806260Z   github.com/tikv/pd/tests/integrations/mcs/tso.(*tsoKeyspaceGroupManagerTestSuite).TestTSOKeyspaceGroupMerge()
2023-06-29T12:00:49.5807204Z       /home/runner/work/pd/pd/tests/integrations/mcs/tso/keyspace_group_manager_test.go:639 +0x174e
2023-06-29T12:00:49.5807639Z   runtime.call16()
2023-06-29T12:00:49.5808147Z       /opt/hostedtoolcache/go/1.20.1/x64/src/runtime/asm_amd64.s:728 +0x48
2023-06-29T12:00:49.5808538Z   reflect.Value.Call()
2023-06-29T12:00:49.5809102Z       /opt/hostedtoolcache/go/1.20.1/x64/src/reflect/value.go:370 +0xc7
2023-06-29T12:00:49.5809572Z   github.com/stretchr/testify/suite.Run.func1()
2023-06-29T12:00:49.5810246Z       /home/runner/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:197 +0x70d
2023-06-29T12:00:49.5810645Z   testing.tRunner()
2023-06-29T12:00:49.5811211Z       /opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1576 +0x216
2023-06-29T12:00:49.5811608Z   testing.(*T).Run.func1()
2023-06-29T12:00:49.5812180Z       /opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1629 +0x47
2023-06-29T12:00:49.5812526Z ==================

CI link

https://github.com/tikv/pd/actions/runs/5411854121/jobs/9835151920?pr=6720

Reason for failure (if possible)

Anything else

@lhy1024 lhy1024 added the type/ci The issue is related to CI. label Jun 29, 2023
@lhy1024
Copy link
Contributor Author

lhy1024 commented Jun 29, 2023

mergeTarget.MergeState = nil

I guess there maybe the same problem with checkTSOSplit

ti-chi-bot bot pushed a commit that referenced this issue Jun 30, 2023
…ce group manager (#6723)

close #6721

checkTSOMerge and checkTSOSplit will read from kgm.getKeyspaceGroupMeta

finishMergeKeyspaceGroup and finishSplitKeyspaceGroup will update kgm

so just return a copy to avoid data race

Signed-off-by: Bin Shi <[email protected]>
rleungx pushed a commit to rleungx/pd that referenced this issue Aug 2, 2023
…ce group manager (tikv#6723)

close tikv#6721

checkTSOMerge and checkTSOSplit will read from kgm.getKeyspaceGroupMeta

finishMergeKeyspaceGroup and finishSplitKeyspaceGroup will update kgm

so just return a copy to avoid data race

Signed-off-by: Bin Shi <[email protected]>
rleungx pushed a commit to rleungx/pd that referenced this issue Aug 2, 2023
…ce group manager (tikv#6723)

close tikv#6721

checkTSOMerge and checkTSOSplit will read from kgm.getKeyspaceGroupMeta

finishMergeKeyspaceGroup and finishSplitKeyspaceGroup will update kgm

so just return a copy to avoid data race

Signed-off-by: Bin Shi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/ci The issue is related to CI.
Projects
None yet
1 participant