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

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

Closed
D3Hunter opened this issue Jan 17, 2025 · 0 comments · Fixed by #59020
Labels
affects-8.5 This bug affects the 8.5.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. severity/moderate type/bug The issue is confirmed as a bug.

Comments

@D3Hunter
Copy link
Contributor

D3Hunter commented Jan 17, 2025

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

@D3Hunter D3Hunter added affects-8.5 This bug affects the 8.5.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. severity/moderate type/bug The issue is confirmed as a bug. labels Jan 17, 2025
ti-chi-bot bot pushed a commit that referenced this issue Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-8.5 This bug affects the 8.5.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. severity/moderate type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant