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 in the executor.buildMemTableReader #43118

Closed
Tracked by #41316
hawkingrei opened this issue Apr 18, 2023 · 1 comment · Fixed by #43431
Closed
Tracked by #41316

DATA RACE in the executor.buildMemTableReader #43118

hawkingrei opened this issue Apr 18, 2023 · 1 comment · Fixed by #43431
Assignees

Comments

@hawkingrei
Copy link
Member

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
Read at 0x00c06184fa21 by goroutine 265381:
  github.com/pingcap/tidb/executor.buildMemTableReader.func1()
      executor/mem_reader.go:208 +0x91
  github.com/pingcap/tidb/util/rowcodec.(*BytesDecoder).decodeToBytesInternal()
      util/rowcodec/decoder.go:407 +0x4ee
  github.com/pingcap/tidb/util/rowcodec.(*BytesDecoder).DecodeToBytes()
      util/rowcodec/decoder.go:462 +0x318
  github.com/pingcap/tidb/executor.(*memTableReader).getRowData()
      executor/mem_reader.go:304 +0x274
  github.com/pingcap/tidb/executor.(*memTableReader).decodeRowData()
      executor/mem_reader.go:282 +0xa4
  github.com/pingcap/tidb/executor.(*memTableReader).decodeRecordKeyValue()
      executor/mem_reader.go:277 +0xf6
  github.com/pingcap/tidb/executor.(*memTableReader).getMemRows.func1()
      executor/mem_reader.go:247 +0xda
  github.com/pingcap/tidb/executor.iterTxnMemBuffer()
      executor/mem_reader.go:413 +0x3e3
  github.com/pingcap/tidb/executor.(*memTableReader).getMemRows()
      executor/mem_reader.go:245 +0x4e6
  github.com/pingcap/tidb/executor.(*UnionScanExec).open()
      executor/union_scan.go:117 +0x4ed
  github.com/pingcap/tidb/executor.(*UnionScanExec).Open()
      executor/union_scan.go:80 +0x210
  github.com/pingcap/tidb/executor.(*UnionExec).resultPuller()
      executor/executor.go:1926 +0x494
  github.com/pingcap/tidb/executor.(*UnionExec).initialize.func1()
      executor/executor.go:1896 +0x64
Previous write at 0x00c06184fa21 by goroutine 265383:
  github.com/pingcap/tidb/executor.buildMemTableReader.func1()
      executor/mem_reader.go:209 +0xb1
  github.com/pingcap/tidb/util/rowcodec.(*BytesDecoder).decodeToBytesInternal()
      util/rowcodec/decoder.go:407 +0x4ee
  github.com/pingcap/tidb/util/rowcodec.(*BytesDecoder).DecodeToBytes()
      util/rowcodec/decoder.go:462 +0x318
  github.com/pingcap/tidb/executor.(*memTableReader).getRowData()
      executor/mem_reader.go:304 +0x274
  github.com/pingcap/tidb/executor.(*memTableReader).decodeRowData()
      executor/mem_reader.go:282 +0xa4
  github.com/pingcap/tidb/executor.(*memTableReader).decodeRecordKeyValue()
      executor/mem_reader.go:277 +0xf6
  github.com/pingcap/tidb/executor.(*memTableReader).getMemRows.func1()
      executor/mem_reader.go:247 +0xda
  github.com/pingcap/tidb/executor.iterTxnMemBuffer()
      executor/mem_reader.go:413 +0x3e3
  github.com/pingcap/tidb/executor.(*memTableReader).getMemRows()
      executor/mem_reader.go:245 +0x4e6
  github.com/pingcap/tidb/executor.(*UnionScanExec).open()
      executor/union_scan.go:117 +0x4ed
  github.com/pingcap/tidb/executor.(*UnionScanExec).Open()
      executor/union_scan.go:80 +0x210
  github.com/pingcap/tidb/executor.(*UnionExec).resultPuller()
      executor/executor.go:1926 +0x494
  github.com/pingcap/tidb/executor.(*UnionExec).initialize.func1()
      executor/executor.go:1896 +0x64
Goroutine 265381 (running) created at:
  github.com/pingcap/tidb/executor.(*UnionExec).initialize()
      executor/executor.go:1896 +0x4e6
  github.com/pingcap/tidb/executor.(*UnionExec).Next()
      executor/executor.go:1969 +0xca
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:326 +0x326
  github.com/pingcap/tidb/executor.(*SelectLockExec).Next()
      executor/executor.go:1225 +0xeb
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:326 +0x326
  github.com/pingcap/tidb/executor.(*DeleteExec).deleteSingleTableByChunk()
      executor/delete.go:112 +0x94b
  github.com/pingcap/tidb/executor.(*DeleteExec).Next()
      executor/delete.go:60 +0x12a
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:326 +0x326
  github.com/pingcap/tidb/executor.(*ExecStmt).next()
      executor/adapter.go:1194 +0x89
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor()
      executor/adapter.go:939 +0x4f9
  github.com/pingcap/tidb/executor.(*ExecStmt).handlePessimisticDML()
      executor/adapter.go:1000 +0x487
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay()
      executor/adapter.go:761 +0x2be
  github.com/pingcap/tidb/executor.(*ExecStmt).Exec()
      executor/adapter.go:564 +0xf87
  github.com/pingcap/tidb/session.runStmt()
      session/session.go:2347 +0x62f
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2204 +0x139c
  github.com/pingcap/tidb/testkit.(*TestKit).ExecWithContext()
      testkit/testkit.go:325 +0x8ae
  github.com/pingcap/tidb/testkit.(*TestKit).MustExecWithContext()
      testkit/testkit.go:133 +0xb7
  github.com/pingcap/tidb/testkit.(*TestKit).MustExec()
      testkit/testkit.go:128 +0x138
  github.com/pingcap/tidb/executor_test.TestIndexMergeInTransaction()
      executor/index_merge_reader_test.go:394 +0x1af4
  github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop()
      domain/domain.go:1581 +0xa8
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3325 +0x6d3
  github.com/pingcap/tidb/domain.(*Domain).GetSessionCache()
      domain/sysvar_cache.go:62 +0x5c
  github.com/pingcap/tidb/session.(*session).loadCommonGlobalVariablesIfNeeded()
      session/session.go:3672 +0x104
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2091 +0x145
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1626 +0x31b
  github.com/pingcap/tidb/domain.(*Domain).LoadPrivilegeLoop()
      domain/domain.go:1525 +0x130
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3318 +0x684
  github.com/pingcap/tidb/testkit.bootstrap()
      testkit/mockstore.go:85 +0xac
  github.com/pingcap/tidb/testkit.CreateMockStoreAndDomain()
      testkit/mockstore.go:70 +0xe9
  github.com/pingcap/tidb/testkit.CreateMockStore()
      testkit/mockstore.go:62 +0x3b1
  github.com/pingcap/tidb/executor_test.TestIndexMergeInTransaction()
      executor/index_merge_reader_test.go:242 +0x52
  testing.tRunner()
      GOROOT/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1629 +0x47
Goroutine 265383 (running) created at:
  github.com/pingcap/tidb/executor.(*UnionExec).initialize()
      executor/executor.go:1896 +0x4e6
  github.com/pingcap/tidb/executor.(*UnionExec).Next()
      executor/executor.go:1969 +0xca
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:326 +0x326
  github.com/pingcap/tidb/executor.(*SelectLockExec).Next()
      executor/executor.go:1225 +0xeb
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:326 +0x326
  github.com/pingcap/tidb/executor.(*DeleteExec).deleteSingleTableByChunk()
      executor/delete.go:112 +0x94b
  github.com/pingcap/tidb/executor.(*DeleteExec).Next()
      executor/delete.go:60 +0x12a
  github.com/pingcap/tidb/executor.Next()
      executor/executor.go:326 +0x326
  github.com/pingcap/tidb/executor.(*ExecStmt).next()
      executor/adapter.go:1194 +0x89
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor()
      executor/adapter.go:939 +0x4f9
  github.com/pingcap/tidb/executor.(*ExecStmt).handlePessimisticDML()
      executor/adapter.go:1000 +0x487
  github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay()
      executor/adapter.go:761 +0x2be
  github.com/pingcap/tidb/executor.(*ExecStmt).Exec()
      executor/adapter.go:564 +0xf87
  github.com/pingcap/tidb/session.runStmt()
      session/session.go:2347 +0x62f
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2204 +0x139c
  github.com/pingcap/tidb/testkit.(*TestKit).ExecWithContext()
      testkit/testkit.go:325 +0x8ae
  github.com/pingcap/tidb/testkit.(*TestKit).MustExecWithContext()
      testkit/testkit.go:133 +0xb7
  github.com/pingcap/tidb/testkit.(*TestKit).MustExec()
      testkit/testkit.go:128 +0x138
  github.com/pingcap/tidb/executor_test.TestIndexMergeInTransaction()
      executor/index_merge_reader_test.go:394 +0x1af4
  github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop()
      domain/domain.go:1581 +0xa8
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3325 +0x6d3
  github.com/pingcap/tidb/domain.(*Domain).GetSessionCache()
      domain/sysvar_cache.go:62 +0x5c
  github.com/pingcap/tidb/session.(*session).loadCommonGlobalVariablesIfNeeded()
      session/session.go:3672 +0x104
  github.com/pingcap/tidb/session.(*session).ExecuteStmt()
      session/session.go:2091 +0x145
  github.com/pingcap/tidb/session.(*session).ExecuteInternal()
      session/session.go:1626 +0x31b
  github.com/pingcap/tidb/domain.(*Domain).LoadPrivilegeLoop()
      domain/domain.go:1525 +0x130
  github.com/pingcap/tidb/session.BootstrapSession()
      session/session.go:3318 +0x684
  github.com/pingcap/tidb/testkit.bootstrap()
      testkit/mockstore.go:85 +0xac
  github.com/pingcap/tidb/testkit.CreateMockStoreAndDomain()
      testkit/mockstore.go:70 +0xe9
  github.com/pingcap/tidb/testkit.CreateMockStore()
      testkit/mockstore.go:62 +0x3b1
  github.com/pingcap/tidb/executor_test.TestIndexMergeInTransaction()
      executor/index_merge_reader_test.go:242 +0x52
  testing.tRunner()
      GOROOT/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      GOROOT/src/testing/testing.go:1629 +0x47
================== 

4. What is your TiDB version? (Required)

@hawkingrei hawkingrei added type/bug The issue is confirmed as a bug. component/test severity/moderate labels Apr 18, 2023
@tiancaiamao
Copy link
Contributor

Maybe we can change the GetColDefaultValue function signature to add a sqlMode parameter
To avoid change the SessionVars.sqlMode

@hawkingrei

@Ivy-YinSu Ivy-YinSu assigned Ivy-YinSu and hawkingrei and unassigned Ivy-YinSu Jul 11, 2023
@jebter jebter added the sig/sql-infra SIG: SQL Infra label Aug 22, 2023
ti-chi-bot bot pushed a commit that referenced this issue Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants