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

DATA RACE at the memChangeHook #39400

Closed
hawkingrei opened this issue Nov 25, 2022 · 0 comments · Fixed by #39411
Closed

DATA RACE at the memChangeHook #39400

hawkingrei opened this issue Nov 25, 2022 · 0 comments · Fixed by #39411
Labels
component/test severity/major type/bug The issue is confirmed as a bug.

Comments

@hawkingrei
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

==================
WARNING: DATA RACE
Read at 0x00c001fc5e48 by goroutine 172060:
  github.com/tikv/client-go/v2/internal/unionstore.(*memdbArena).onMemChange()
      external/com_github_tikv_client_go_v2/internal/unionstore/memdb_arena.go:135 +0x2dc
  github.com/tikv/client-go/v2/internal/unionstore.(*memdbArena).enlarge()
      external/com_github_tikv_client_go_v2/internal/unionstore/memdb_arena.go:131 +0x2cb
  github.com/tikv/client-go/v2/internal/unionstore.(*memdbArena).alloc()
      external/com_github_tikv_client_go_v2/internal/unionstore/memdb_arena.go:106 +0x84
  github.com/tikv/client-go/v2/internal/unionstore.(*nodeAllocator).allocNode()
      external/com_github_tikv_client_go_v2/internal/unionstore/memdb_arena.go:251 +0x53
  github.com/tikv/client-go/v2/internal/unionstore.(*MemDB).allocNode()
      external/com_github_tikv_client_go_v2/internal/unionstore/memdb.go:787 +0xe4
  github.com/tikv/client-go/v2/internal/unionstore.(*MemDB).traverse()
      external/com_github_tikv_client_go_v2/internal/unionstore/memdb.go:408 +0x369
  github.com/tikv/client-go/v2/internal/unionstore.(*MemDB).set()
      external/com_github_tikv_client_go_v2/internal/unionstore/memdb.go:333 +0x1ae
  github.com/tikv/client-go/v2/internal/unionstore.(*MemDB).UpdateFlags()
      external/com_github_tikv_client_go_v2/internal/unionstore/memdb.go:248 +0x1ba6
  github.com/tikv/client-go/v2/txnkv/transaction.(*KVTxn).LockKeys()
      external/com_github_tikv_client_go_v2/txnkv/transaction/txn.go:811 +0x1ac7
  github.com/pingcap/tidb/store/driver/txn.(*tikvTxn).LockKeys()
      store/driver/txn/txn_driver.go:75 +0x105
  github.com/pingcap/tidb/session.(*LazyTxn).LockKeys()
      session/txn.go:442 +0x22e
  github.com/pingcap/tidb/executor.doLockKeys()
      executor/executor.go:1275 +0x30d
  github.com/pingcap/tidb/executor.(*SelectLockExec).Next()
      executor/executor.go:1207 +0x78f
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:329 +0x5c3
  github.com/pingcap/tidb/executor.(*UnionExec).resultPuller()
      executor/executor.go:1853 +0x8e9
  github.com/pingcap/tidb/executor.(*UnionExec).initialize.func1()
      executor/executor.go:1806 +0x64
Previous write at 0x00c001fc5e48 by goroutine 172058:
  sync/atomic.StoreInt64()
      src/runtime/race_amd64.s:237 +0xb
  sync/atomic.StorePointer()
      GOROOT/src/runtime/atomic_pointer.go:51 +0x44
  github.com/tikv/client-go/v2/txnkv/transaction.(*KVTxn).SetMemoryFootprintChangeHook()
      external/com_github_tikv_client_go_v2/txnkv/transaction/txn.go:959 +0x8b
  github.com/pingcap/tidb/store/driver/txn.(*tikvTxn).SetMemoryFootprintChangeHook()
      <autogenerated>:1 +0x29
  github.com/pingcap/tidb/session.(*LazyTxn).SetMemoryFootprintChangeHook()
      session/txn.go:205 +0xc8
  github.com/pingcap/tidb/session.(*session).SetMemoryFootprintChangeHook()
      session/session.go:3677 +0x85
  github.com/pingcap/tidb/session.(*session).Txn()
      session/session.go:2512 +0x79
  github.com/pingcap/tidb/executor.doLockKeys()
      executor/executor.go:1264 +0x165
  github.com/pingcap/tidb/executor.(*SelectLockExec).Next()
      executor/executor.go:1207 +0x78f
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:329 +0x5c3
  github.com/pingcap/tidb/executor.(*UnionExec).resultPuller()
      executor/executor.go:1853 +0x8e9
  github.com/pingcap/tidb/executor.(*UnionExec).initialize.func1()
      executor/executor.go:1806 +0x64
Goroutine 172060 (running) created at:
  github.com/pingcap/tidb/executor.(*UnionExec).initialize()
      executor/executor.go:1806 +0x4d7
  github.com/pingcap/tidb/executor.(*UnionExec).Next()
      executor/executor.go:1879 +0xca
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:329 +0x5c3
  github.com/pingcap/tidb/executor.(*HashAggExec).fetchChildData()
      executor/aggregate.go:814 +0x325
  github.com/pingcap/tidb/executor.(*HashAggExec).prepare4ParallelExec.func3()
      executor/aggregate.go:851 +0x64
Goroutine 172058 (running) created at:
  github.com/pingcap/tidb/executor.(*UnionExec).initialize()
      executor/executor.go:1806 +0x4d7
  github.com/pingcap/tidb/executor.(*UnionExec).Next()
      executor/executor.go:1879 +0xca
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:329 +0x5c3
  github.com/pingcap/tidb/executor.(*HashAggExec).fetchChildData()
      executor/aggregate.go:814 +0x325
  github.com/pingcap/tidb/executor.(*HashAggExec).prepare4ParallelExec.func3()
      executor/aggregate.go:851 +0x64
================== 

2. What did you expect to see? (Required)

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

@hawkingrei hawkingrei added the type/bug The issue is confirmed as a bug. label Nov 25, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 may-affects-6.4 labels Nov 28, 2022
@hawkingrei hawkingrei removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 may-affects-6.4 labels Nov 28, 2022
ti-chi-bot pushed a commit that referenced this issue Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/test severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants