Skip to content

potential data race on add index when other routine exit due to error but adjust worker size routine keeps running #59016

@D3Hunter

Description

@D3Hunter

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

the task sender routine A uses error group context

tidb/pkg/ddl/backfilling.go

Lines 1039 to 1040 in 889bf45

// generate task goroutine
eg.Go(func() error {

but the adjust worker size routine B uses parent ctx

tidb/pkg/ddl/backfilling.go

Lines 1074 to 1081 in 889bf45

// update the worker cnt goroutine
go func() {
ticker := time.NewTicker(UpdateDDLJobReorgCfgInterval)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return

so if A failed with error, cause error group context cancelled, B keeps running, so we might met potential data race in
closeBackfillWorkers(b.workers)

and
b.workers = append(b.workers, runner)

we should use the same context, and run together under the same group. introduced in #57468

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

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

master

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-8.5This bug affects the 8.5.x(LTS) versions.component/ddlThis issue is related to DDL of TiDB.severity/moderatetype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions