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

Wrong package level logger initialization timing #52883

Closed
lance6716 opened this issue Apr 25, 2024 · 0 comments · Fixed by #52885
Closed

Wrong package level logger initialization timing #52883

lance6716 opened this issue Apr 25, 2024 · 0 comments · Fixed by #52885
Labels
affects-8.1 component/ddl This issue is related to DDL of TiDB. severity/moderate type/bug The issue is confirmed as a bug.

Comments

@lance6716
Copy link
Contributor

in #52645 I added a package level logger

litLogger = logutil.BgLogger().With(zap.String(logutil.LogFieldCategory, "ddl-ingest"))

But when the variable is set, logutil.BgLogger() is not initialized yet. It prints to stdout instead

$ k logs tc-tidb-0 | more
start tidb-server ...
/tidb-server --store=tikv --advertise-address=xxx --host=0.0.0.0 --path=tc-pd:2379 --config=/etc/tidb/tidb.toml

[2024/04/25 09:30:59.400 +08:00] [INFO] [env.go:103] ["the ingest sorted directory"] [category=ddl-ingest] ["data path"=/tmp/tidb/tmp_ddl-4000]
[2024/04/25 09:30:59.400 +08:00] [INFO] [env.go:76] ["init global ingest backend environment finished"] [category=ddl-ingest] ["memory limitation"=17179869184] ["disk usage info"="disk usage: 336493137920/467794132992, backend usage: 0"] ["max open file number"=1073741816] ["lightning is initialized"=true]
[2024/04/25 09:31:06.145 +08:00] [INFO] [local.go:682] ["multi ingest support"] [category=ddl-ingest]
[2024/04/25 09:31:06.146 +08:00] [INFO] [local.go:704] ["TiKV server side free space check is enabled, so lightning will turn it off"] [category=ddl-ingest]
[2024/04/25 09:42:06.984 +08:00] [INFO] [local.go:682] ["multi ingest support"] [category=ddl-ingest]

we should set them after

func setupLog() {
cfg := config.GetGlobalConfig()
err := logutil.InitLogger(cfg.Log.ToLogConfig(), keyspace.WrapZapcoreWithKeyspace())
terror.MustNil(err)
// trigger internal http(s) client init.
util.InternalHTTPClient()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-8.1 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.

2 participants