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

fatal error: concurrent map read and map write from Config.Labels #45561

Closed
gengliqi opened this issue Jul 25, 2023 · 5 comments · Fixed by #45563
Closed

fatal error: concurrent map read and map write from Config.Labels #45561

gengliqi opened this issue Jul 25, 2023 · 5 comments · Fixed by #45563
Labels
affects-6.5 affects-7.1 component/pd report/customer Customers have encountered this bug. severity/major type/bug The issue is confirmed as a bug.

Comments

@gengliqi
Copy link
Contributor

Bug Report

fatal error: concurrent map read and map write

 goroutine 513 [running]:
 github.com/pingcap/tidb/config.(*Config).GetTiKVConfig(...)
 	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/config/config.go:312
 github.com/pingcap/tidb/sessionctx/variable.glob..func188({0xc04ef57a40?, 0xc001c01800?}, 0xc04e8fdcae?, {0xc04e8fdcae?, 0x2?})
 	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/sessionctx/variable/sysvar.go:1026 +0x33e
 github.com/pingcap/tidb/domain.(*Domain).rebuildSysVarCache(0xc000cefe00, {0x5025338, 0xc0008e2c80})
 	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/domain/sysvar_cache.go:147 +0x71e
 github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop.func1()
 	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/domain/domain.go:1415 +0x1ff
 created by github.com/pingcap/tidb/domain.(*Domain).LoadSysVarCacheLoop
 	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/domain/domain.go:1376 +0x172

tidb/server/http_handler.go

Lines 2221 to 2231 in b4183e1

if len(labels) > 0 {
cfg := *config.GetGlobalConfig()
if cfg.Labels == nil {
cfg.Labels = make(map[string]string, len(labels))
}
for k, v := range labels {
cfg.Labels[k] = v
}
config.StoreGlobalConfig(&cfg)
logutil.BgLogger().Info("update server labels", zap.Any("labels", cfg.Labels))
}

The code above wants to update Labels in Config. It copies the global config first and then changes the Labels in the copy.
However, the Labels is a map[string]string so the copy is shallow, which causes this data race.

@gengliqi gengliqi added the type/bug The issue is confirmed as a bug. label Jul 25, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 25, 2023

@gengliqi: The label(s) sig/sql-infra, severity/major cannot be applied. These labels are supported: fuzz/sqlancer, challenge-program, compatibility-breaker, first-time-contributor, contribution, require-LGT3, good first issue, correctness, duplicate, proposal, security, needs-more-info, needs-cherry-pick-release-5.2, needs-cherry-pick-release-5.3, needs-cherry-pick-release-5.4, needs-cherry-pick-release-6.0, needs-cherry-pick-release-6.1, needs-cherry-pick-release-6.2, needs-cherry-pick-release-6.3, needs-cherry-pick-release-6.4, needs-cherry-pick-release-6.5, needs-cherry-pick-release-6.6, needs-cherry-pick-release-7.0, needs-cherry-pick-release-7.1, needs-cherry-pick-release-7.2, affects-5.2, affects-5.3, affects-5.4, affects-6.0, affects-6.1, affects-6.2, affects-6.3, affects-6.4, affects-6.5, affects-6.6, affects-7.0, affects-7.1, affects-7.2, may-affects-5.2, may-affects-5.3, may-affects-5.4, may-affects-6.0, may-affects-6.1, may-affects-6.2, may-affects-6.3, may-affects-6.4, may-affects-6.5, may-affects-6.6, may-affects-7.0, may-affects-7.1, may-affects-7.2.

In response to this:

/label sig/sql-infra
/label severity/major

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@gengliqi
Copy link
Contributor Author

/severity major

@ti-chi-bot ti-chi-bot bot added severity/major may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Jul 25, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 25, 2023

@gengliqi: The label(s) sig/sql-infra, severity/major cannot be applied. These labels are supported: fuzz/sqlancer, challenge-program, compatibility-breaker, first-time-contributor, contribution, require-LGT3, good first issue, correctness, duplicate, proposal, security, needs-more-info, needs-cherry-pick-release-5.2, needs-cherry-pick-release-5.3, needs-cherry-pick-release-5.4, needs-cherry-pick-release-6.0, needs-cherry-pick-release-6.1, needs-cherry-pick-release-6.2, needs-cherry-pick-release-6.3, needs-cherry-pick-release-6.4, needs-cherry-pick-release-6.5, needs-cherry-pick-release-6.6, needs-cherry-pick-release-7.0, needs-cherry-pick-release-7.1, needs-cherry-pick-release-7.2, affects-5.2, affects-5.3, affects-5.4, affects-6.0, affects-6.1, affects-6.2, affects-6.3, affects-6.4, affects-6.5, affects-6.6, affects-7.0, affects-7.1, affects-7.2, may-affects-5.2, may-affects-5.3, may-affects-5.4, may-affects-6.0, may-affects-6.1, may-affects-6.2, may-affects-6.3, may-affects-6.4, may-affects-6.5, may-affects-6.6, may-affects-7.0, may-affects-7.1, may-affects-7.2.

In response to this:

/label sig/sql-infra
/label severity/major

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@jebter
Copy link

jebter commented Sep 21, 2023

/component pd

@seiya-annie
Copy link

/found customer

@ti-chi-bot ti-chi-bot bot added the report/customer Customers have encountered this bug. label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 affects-7.1 component/pd report/customer Customers have encountered this bug. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants