pingcap / pingcap/tidb

tidb-lightning: Inconsistent handling and checking of log file name

Open
#32,252 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

I noticed this when troubleshooting an issue where TiDB Lightning logging was misbehaving under TiDB Operator. TiDB Operator invokes tidb-lightning with --log-file="" (https://github.com/pingcap/tidb-operator/blob/master/charts/tidb-lightning/templates/scripts/_start_lightning.sh.tpl#L53) as well as lightning.file = "-" in the config file (https://github.com/pingcap/tidb-operator/blob/master/charts/tidb-lightning/values.yaml#L115).

It seems like tidb-lightning treats these differently? Or doesn't check them properly when setting up logging? In any case, in the following file one line uses "globalCfg.App.File" and a couple lines later "globalCfg.App.Config.File" is used instead:

https://github.com/pingcap/tidb/blob/cb8e65abcbd873b71ff81039ebc31b619830897d/br/cmd/tidb-lightning/main.go#L34

The result of this in the case of TiDB Operator seems to be that it outputs the line "Verbose debug logs will be written to" without a filename.

Contributor guide

Open the contributing guide

Research direction

Start in br/cmd/tidb-lightning/main.go at the logging setup around the referenced lines, comparing uses of globalCfg.App.File and globalCfg.App.Config.File. Run tidb-lightning with --log-file="" and lightning.file="-" to observe the logging behavior. Done means the two inputs are handled consistently and the verbose debug message does not omit its filename.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.