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

*: improve the format of the error log (#12155) #16182

Merged
merged 3 commits into from
Apr 9, 2020

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented Apr 8, 2020

cherry-pick #12155 to release-3.1


Signed-off-by: nolouch nolouch@gmail.com

What problem does this PR solve?

Fix #10586

  • Only print stack information in FATAL level, the most of the time the stack information for error is useless.
  • Use ErrorVerbose to control the stack information in error message

What is changed and how it works?

Check List

Tests

  • Unit test
    before:
[2019/09/11 16:20:46.454 +08:00] [INFO] [store.go:68] ["new store"] [path=tikv:///tmp/tidb]
[2019/09/11 16:20:46.454 +08:00] [INFO] [client.go:148] ["[pd] create pd client with endpoints"] [pd-address="[]"]
[2019/09/11 16:20:46.454 +08:00] [ERROR] [client.go:204] ["[pd] failed to get cluster id"] [error="rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = \"transport: Error while dialing dial tcp: missing address\""] [errorVerbose="rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = \"transport: Error while dialing dial tcp: missing address\"\ngithub.com/pingcap/pd/client.(*client).getMembers\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:239\ngithub.com/pingcap/pd/client.(*client).initClusterID\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:201\ngithub.com/pingcap/pd/client.(*client).initRetry\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:188\ngithub.com/pingcap/pd/client.NewClient\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:161\ngithub.com/pingcap/tidb/store/tikv.Driver.Open\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/tikv/kv.go:80\ngithub.com/pingcap/tidb/store.newStoreWithRetry.func1\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:69\ngithub.com/pingcap/tidb/util.RunWithRetry\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/util/misc.go:46\ngithub.com/pingcap/tidb/store.newStoreWithRetry\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:67\ngithub.com/pingcap/tidb/store.New\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:51\nmain.createStoreAndDomain\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/tidb-server/main.go:235\nmain.main\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/tidb-server/main.go:176\nruntime.main\n\t/usr/local/Cellar/go/1.13/libexec/src/runtime/proc.go:203\nruntime.goexit\n\t/usr/local/Cellar/go/1.13/libexec/src/runtime/asm_amd64.s:1357"] [stack="github.com/pingcap/log.Error\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/log@v0.0.0-20190307075452-bd41d9273596/global.go:42\ngithub.com/pingcap/pd/client.(*client).initClusterID\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:204\ngithub.com/pingcap/pd/client.(*client).initRetry\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:188\ngithub.com/pingcap/pd/client.NewClient\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:161\ngithub.com/pingcap/tidb/store/tikv.Driver.Open\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/tikv/kv.go:80\ngithub.com/pingcap/tidb/store.newStoreWithRetry.func1\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:69\ngithub.com/pingcap/tidb/util.RunWithRetry\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/util/misc.go:46\ngithub.com/pingcap/tidb/store.newStoreWithRetry\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:67\ngithub.com/pingcap/tidb/store.New\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:51\nmain.createStoreAndDomain\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/tidb-server/main.go:235\nmain.main\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/tidb-server/main.go:176\nruntime.main\n\t/usr/local/Cellar/go/1.13/libexec/src/runtime/proc.go:203"]
[2019/09/11 16:20:47.460 +08:00] [ERROR] [client.go:204] ["[pd] failed to get cluster id"] [error="rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = \"transport: Error while dialing dial tcp: missing address\""] [errorVerbose="rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = \"transport: Error while dialing dial tcp: missing address\"\ngithub.com/pingcap/pd/client.(*client).getMembers\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:239\ngithub.com/pingcap/pd/client.(*client).initClusterID\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:201\ngithub.com/pingcap/pd/client.(*client).initRetry\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:188\ngithub.com/pingcap/pd/client.NewClient\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:161\ngithub.com/pingcap/tidb/store/tikv.Driver.Open\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/tikv/kv.go:80\ngithub.com/pingcap/tidb/store.newStoreWithRetry.func1\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:69\ngithub.com/pingcap/tidb/util.RunWithRetry\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/util/misc.go:46\ngithub.com/pingcap/tidb/store.newStoreWithRetry\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:67\ngithub.com/pingcap/tidb/store.New\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:51\nmain.createStoreAndDomain\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/tidb-server/main.go:235\nmain.main\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/tidb-server/main.go:176\nruntime.main\n\t/usr/local/Cellar/go/1.13/libexec/src/runtime/proc.go:203\nruntime.goexit\n\t/usr/local/Cellar/go/1.13/libexec/src/runtime/asm_amd64.s:1357"] [stack="github.com/pingcap/log.Error\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/log@v0.0.0-20190307075452-bd41d9273596/global.go:42\ngithub.com/pingcap/pd/client.(*client).initClusterID\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:204\ngithub.com/pingcap/pd/client.(*client).initRetry\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:188\ngithub.com/pingcap/pd/client.NewClient\n\t/Users/nolouch/csn/program/go/pkg/mod/github.com/pingcap/pd@v0.0.0-20190712044914-75a1f9f3062b/client/client.go:161\ngithub.com/pingcap/tidb/store/tikv.Driver.Open\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/tikv/kv.go:80\ngithub.com/pingcap/tidb/store.newStoreWithRetry.func1\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:69\ngithub.com/pingcap/tidb/util.RunWithRetry\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/util/misc.go:46\ngithub.com/pingcap/tidb/store.newStoreWithRetry\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:67\ngithub.com/pingcap/tidb/store.New\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/store/store.go:51\nmain.createStoreAndDomain\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/tidb-server/main.go:235\nmain.main\n\t/Users/nolouch/csn/program/go/src/github.com/pingcap/tidb/tidb-server/main.go:176\nruntime.main\n\t/usr/local/Cellar/go/1.13/libexec/src/runtime/proc.go:203"]

after:

[2019/09/11 16:19:38.544 +08:00] [INFO] [store.go:68] ["new store"] [path=tikv:///tmp/tidb]
[2019/09/11 16:19:38.545 +08:00] [INFO] [client.go:148] ["[pd] create pd client with endpoints"] [pd-address="[]"]
[2019/09/11 16:19:38.549 +08:00] [ERROR] [client.go:204] ["[pd] failed to get cluster id"] [error="rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = \"transport: Error while dialing dial tcp: missing address\""]
[2019/09/11 16:19:39.549 +08:00] [ERROR] [client.go:204] ["[pd] failed to get cluster id"] [error="rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = \"transport: Error while dialing dial tcp: missing address\""]
[2019/09/11 16:19:40.550 +08:00] [ERROR] [client.go:204] ["[pd] failed to get cluster id"] [error="rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = \"transport: Error while dialing dial tcp: missing address\""]

Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 8, 2020

/run-all-tests

config/config.go Outdated Show resolved Hide resolved
Signed-off-by: nolouch <nolouch@gmail.com>
@nolouch
Copy link
Member

nolouch commented Apr 9, 2020

PTAL @zimulala @lysu

Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zimulala zimulala added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 9, 2020
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason zz-jason added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 9, 2020
@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 9, 2020

Your auto merge job has been accepted, waiting for 16053, 16226

@zz-jason zz-jason removed request for gregwebs and lysu April 9, 2020 06:35
@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 9, 2020

/run-all-tests

@sre-bot sre-bot merged commit b2d6f52 into pingcap:release-3.1 Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/config component/util status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/3.1-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants