pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.42k stars 5.85k forks source link

DATA RACE in the TestStillWriteConflictAfterRetry #57878

Open hawkingrei opened 2 days ago

hawkingrei commented 2 days ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

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

3. What did you see instead (Required)

==================
WARNING: DATA RACE
Write at 0x00c00b2a48a9 by goroutine 19499:
  github.com/tikv/client-go/v2/internal/unionstore/art.(*ART).setValue()
      external/com_github_tikv_client_go_v2/internal/unionstore/art/art.go:377 +0x32c
  github.com/tikv/client-go/v2/internal/unionstore/art.(*ART).Set()
      external/com_github_tikv_client_go_v2/internal/unionstore/art/art.go:124 +0x1b6
  github.com/tikv/client-go/v2/internal/unionstore.(*artDBWithContext).set()
      external/com_github_tikv_client_go_v2/internal/unionstore/memdb_art.go:51 +0x16e
  github.com/tikv/client-go/v2/internal/unionstore.(*artDBWithContext).UpdateFlags()
      external/com_github_tikv_client_go_v2/internal/unionstore/memdb_art.go:70 +0x8e
  github.com/tikv/client-go/v2/txnkv/transaction.(*KVTxn).lockKeys()
      external/com_github_tikv_client_go_v2/txnkv/transaction/txn.go:1547 +0x2c45
  github.com/tikv/client-go/v2/txnkv/transaction.(*KVTxn).LockKeysFunc()
      external/com_github_tikv_client_go_v2/txnkv/transaction/txn.go:1230 +0x1c6
  github.com/pingcap/tidb/pkg/store/driver/txn.(*tikvTxn).LockKeysFunc()
      pkg/store/driver/txn/txn_driver.go:106 +0x174
  github.com/pingcap/tidb/pkg/session.(*LazyTxn).LockKeysFunc()
      pkg/session/txn.go:482 +0x38b
  github.com/pingcap/tidb/pkg/session.(*LazyTxn).LockKeys()
      pkg/session/txn.go:457 +0x7a
  github.com/pingcap/tidb/pkg/executor.doLockKeys()
      pkg/executor/select.go:369 +0x30c
  github.com/pingcap/tidb/pkg/executor.(*SelectLockExec).Next()
      pkg/executor/select.go:298 +0x84e
  github.com/pingcap/tidb/pkg/executor/internal/exec.Next()
      pkg/executor/internal/exec/executor.go:460 +0x3a8
  github.com/pingcap/tidb/pkg/executor/unionexec.(*UnionExec).resultPuller()
      pkg/executor/unionexec/union.go:164 +0x98b
  github.com/pingcap/tidb/pkg/executor/unionexec.(*UnionExec).initialize.gowrap1()
      pkg/executor/unionexec/union.go:117 +0x5d
Previous read at 0x00c00b2a48a9 by goroutine 19498:
  github.com/tikv/client-go/v2/internal/unionstore/art.(*ART).Dirty()
      external/com_github_tikv_client_go_v2/internal/unionstore/art/art.go:414 +0x57
  github.com/tikv/client-go/v2/internal/unionstore.(*artDBWithContext).Dirty()
      <autogenerated>:1 +0x17
  github.com/tikv/client-go/v2/txnkv/transaction.(*KVTxn).IsReadOnly()
      external/com_github_tikv_client_go_v2/txnkv/transaction/txn.go:1699 +0x5e
  github.com/pingcap/tidb/pkg/store/driver/txn.(*tikvTxn).IsReadOnly()
      <autogenerated>:1 +0x3e
  github.com/pingcap/tidb/pkg/session.(*LazyTxn).IsReadOnly()
      <autogenerated>:1 +0x46
  github.com/pingcap/tidb/pkg/executor.(*PointGetExecutor).get()
      pkg/executor/point_get.go:647 +0xfc
  github.com/pingcap/tidb/pkg/executor.(*PointGetExecutor).getAndLock()
      pkg/executor/point_get.go:560 +0x2bd
  github.com/pingcap/tidb/pkg/executor.(*PointGetExecutor).Next()
      pkg/executor/point_get.go:393 +0x11cd
  github.com/pingcap/tidb/pkg/executor/internal/exec.Next()
      pkg/executor/internal/exec/executor.go:460 +0x3a8
  github.com/pingcap/tidb/pkg/executor.(*SelectLockExec).Next()
      pkg/executor/select.go:247 +0xdb
  github.com/pingcap/tidb/pkg/executor/internal/exec.Next()
      pkg/executor/internal/exec/executor.go:460 +0x3a8
  github.com/pingcap/tidb/pkg/executor/unionexec.(*UnionExec).resultPuller()
      pkg/executor/unionexec/union.go:164 +0x98b
  github.com/pingcap/tidb/pkg/executor/unionexec.(*UnionExec).initialize.gowrap1()
      pkg/executor/unionexec/union.go:117 +0x5d
Goroutine 19499 (running) created at:
  github.com/pingcap/tidb/pkg/executor/unionexec.(*UnionExec).initialize()
      pkg/executor/unionexec/union.go:117 +0x525
  github.com/pingcap/tidb/pkg/executor/unionexec.(*UnionExec).Next()
      pkg/executor/unionexec/union.go:190 +0xb9
  github.com/pingcap/tidb/pkg/executor/internal/exec.Next()
      pkg/executor/internal/exec/executor.go:460 +0x3a8
  github.com/pingcap/tidb/pkg/executor/aggregate.(*HashAggExec).fetchChildData()
      pkg/executor/aggregate/agg_hash_executor.go:479 +0x2bb
  github.com/pingcap/tidb/pkg/executor/aggregate.(*HashAggExec).prepare4ParallelExec.gowrap1()
      pkg/executor/aggregate/agg_hash_executor.go:558 +0x5d
Goroutine 19498 (running) created at:
  github.com/pingcap/tidb/pkg/executor/unionexec.(*UnionExec).initialize()
      pkg/executor/unionexec/union.go:117 +0x525
  github.com/pingcap/tidb/pkg/executor/unionexec.(*UnionExec).Next()
      pkg/executor/unionexec/union.go:190 +0xb9
  github.com/pingcap/tidb/pkg/executor/internal/exec.Next()
      pkg/executor/internal/exec/executor.go:460 +0x3a8
  github.com/pingcap/tidb/pkg/executor/aggregate.(*HashAggExec).fetchChildData()
      pkg/executor/aggregate/agg_hash_executor.go:479 +0x2bb
  github.com/pingcap/tidb/pkg/executor/aggregate.(*HashAggExec).prepare4ParallelExec.gowrap1()
      pkg/executor/aggregate/agg_hash_executor.go:558 +0x5d
================== 

https://tiprow.hawkingrei.com/view/gs/pingcapprow/logs/tidb_data_race/1863452190752903168#1:build-log.txt%3A59411

4. What is your TiDB version? (Required)

jebter commented 1 day ago

@cfzjywxk PTAL