Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 各位大佬,想请教下Race Enabled:false 这个配置是啥
[Test Environment for TiDB] Testing
[TiDB Version] V5.1.2
[Reproduction Path] After executing tiup install tidb-lightning
, execute tiup tidb-lightning -V
, and the last line of the output indicates Race Enabled: false
[Encountered Issue: Phenomenon and Impact] None
[Resource Configuration]
[Attachment: Screenshot/Log/Monitoring]
Dear experts, in the output result after tiup tidb-lightning -V
, there is a line Race Enabled: false. I checked and found that it means Go’s data race detection is not enabled. I would like to ask what this parameter specifically does and what impact enabling or disabling it has.
“Race Enabled” refers to whether TiDB Lightning has enabled Go’s data race detector. A data race occurs when two or more goroutines concurrently access the same variable, with at least one access being a write operation. Without proper synchronization, this can lead to undefined behavior such as crashes, deadlocks, and data corruption.
Go provides a built-in data race detection tool called the Data Race Detector. Enabling the Data Race Detector helps developers identify data race issues early during development and testing, thereby improving the stability and reliability of the program.
In TiDB Lightning, enabling the Data Race Detector helps developers identify data race issues early during development and testing, thereby improving the stability and reliability of the program. However, enabling the Data Race Detector can impact the program’s performance, so it is not recommended to enable it in a production environment.
In TiUP, the Race Enabled
parameter indicates whether TiDB Lightning has enabled Go’s data race detection. If the output shows Race Enabled: false
, it means TiDB Lightning has not enabled data race detection. If you need to enable data race detection during development and testing, you can set the RACE=1
environment variable. For example:
RACE=1 tiup tidb-lightning -V
Note that it is not recommended to enable data race detection in a production environment because it can impact the program’s performance.