Skip to content

Data race in TestMixedTSODeployment  #6635

@lhy1024

Description

@lhy1024

Flaky Test

Which jobs are failing

testing.go:1446: race detected during execution of test
--- FAIL: TestMixedTSODeployment (19.35s)

CI link

WARNING: DATA RACE
Read at 0x00c013969438 by goroutine 925857:
  github.com/tikv/pd/pkg/election.(*Leadership).Reset()
      /home/lhy1024/pd/pkg/election/leadership.go:233 +0x8d
  github.com/tikv/pd/pkg/member.(*EmbeddedEtcdMember).ResetLeader()
      /home/lhy1024/pd/pkg/member/member.go:262 +0x3d
  github.com/tikv/pd/tests.(*TestServer).ResignLeader()
      /home/lhy1024/pd/tests/cluster.go:190 +0xee
  github.com/tikv/pd/tests/integrations/tso.TestMixedTSODeployment.func2()
      /home/lhy1024/pd/tests/integrations/tso/client_test.go:446 +0x127

Previous write at 0x00c013969438 by goroutine 922036:
  github.com/tikv/pd/pkg/election.(*Leadership).Keep()
      /home/lhy1024/pd/pkg/election/leadership.go:140 +0xc5
  github.com/tikv/pd/pkg/member.(*EmbeddedEtcdMember).KeepLeader()
      /home/lhy1024/pd/pkg/member/member.go:186 +0x972
  github.com/tikv/pd/server.(*Server).campaignLeader()
      /home/lhy1024/pd/server/server.go:1567 +0x928
  github.com/tikv/pd/server.(*Server).leaderLoop()
      /home/lhy1024/pd/server/server.go:1537 +0x16a4
  github.com/tikv/pd/server.(*Server).startServerLoop.func1()
      /home/lhy1024/pd/server/server.go:598 +0x39
WARNING: DATA RACE
Write at 0x00c0120fc100 by goroutine 925857:
  sync/atomic.CompareAndSwapInt32()
      /usr/lib/go/src/runtime/race_amd64.s:310 +0xb
  sync/atomic.CompareAndSwapInt32()
      <autogenerated>:1 +0x1e
  context.(*cancelCtx).cancel()
      /usr/lib/go/src/context/context.go:460 +0xbd
  context.WithCancel.func1()
      /usr/lib/go/src/context/context.go:240 +0x54
  github.com/tikv/pd/pkg/election.(*Leadership).Reset()
      /home/lhy1024/pd/pkg/election/leadership.go:234 +0xb2
  github.com/tikv/pd/pkg/member.(*EmbeddedEtcdMember).ResetLeader()
      /home/lhy1024/pd/pkg/member/member.go:262 +0x3d
  github.com/tikv/pd/tests.(*TestServer).ResignLeader()
      /home/lhy1024/pd/tests/cluster.go:190 +0xee
  github.com/tikv/pd/tests/integrations/tso.TestMixedTSODeployment.func2()
      /home/lhy1024/pd/tests/integrations/tso/client_test.go:446 +0x127

Previous write at 0x00c0120fc100 by goroutine 922036:
  context.newCancelCtx()
      /usr/lib/go/src/context/context.go:297 +0x55
  context.withCancel()
      /usr/lib/go/src/context/context.go:275 +0x3a
  context.WithCancel()
      /usr/lib/go/src/context/context.go:239 +0x3a
  github.com/tikv/pd/pkg/election.(*Leadership).Keep()
      /home/lhy1024/pd/pkg/election/leadership.go:140 +0x5a
  github.com/tikv/pd/pkg/member.(*EmbeddedEtcdMember).KeepLeader()
      /home/lhy1024/pd/pkg/member/member.go:186 +0x972
  github.com/tikv/pd/server.(*Server).campaignLeader()
      /home/lhy1024/pd/server/server.go:1567 +0x928
  github.com/tikv/pd/server.(*Server).leaderLoop()
      /home/lhy1024/pd/server/server.go:1537 +0x16a4
  github.com/tikv/pd/server.(*Server).startServerLoop.func1()
      /home/lhy1024/pd/server/server.go:598 +0x39

Reason for failure (if possible)

when leadership is runing Keep to write keepAliveCancelFunc, if callback Reset will read and write keepAliveCancelFunc

Anything else

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-6.1This bug affects the 6.1.x(LTS) versions.affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.2type/ciThe issue is related to CI.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions