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 · 2 comments · Fixed by #43431
Closed
Tracked by #41316

DATA RACE in the executor.buildMemTableReader #43118

hawkingrei opened this issue Apr 18, 2023 · 2 comments · Fixed by #43431
Assignees
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. component/test report/customer Customers have encountered this bug. severity/moderate sig/sql-infra SIG: SQL Infra 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)

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

@VelocityLight VelocityLight added the affects-7.1 This bug affects the 7.1.x(LTS) versions. label May 4, 2023
@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
@Defined2014 Defined2014 added the affects-6.5 This bug affects the 6.5.x(LTS) versions. label Aug 27, 2024
ti-chi-bot bot pushed a commit that referenced this issue Aug 29, 2024
@seiya-annie
Copy link

/report customer

@ti-chi-bot ti-chi-bot bot added the report/customer Customers have encountered this bug. label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. component/test report/customer Customers have encountered this bug. severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants