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

tidb_client: improve behavior when no alive tidb instance #900

Merged
merged 6 commits into from
May 7, 2021

Conversation

unbyte
Copy link
Contributor

@unbyte unbyte commented Apr 25, 2021

closes #899

image

image

@unbyte unbyte marked this pull request as draft April 25, 2021 14:10
@unbyte unbyte marked this pull request as ready for review April 26, 2021 07:02
@unbyte unbyte changed the title tidb_client: check active conn before send and improve error msg tidb_client: improve behavior when no alive tidb instance Apr 26, 2021
pkg/tidb/forwarder.go Show resolved Hide resolved
pkg/tidb/forwarder.go Outdated Show resolved Hide resolved
f.statusProxy.updateRemotes(nil)
}
} else {
if err == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

errorx.IsOfType(err, ErrNoAliveTiDB) is a legacy code and is always false, so I simply remove entire err != nil block

Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

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

The rest LGTM. /cc @shhdgit PTAL

pkg/tidb/forwarder.go Show resolved Hide resolved
@shhdgit
Copy link
Member

shhdgit commented Apr 27, 2021

LGTM.

Copy link
Contributor

@HunDunDM HunDunDM left a comment

Choose a reason for hiding this comment

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

rest LGTM

@@ -111,7 +111,10 @@ func (c *Client) OpenSQLConn(user string, pass string) (*gorm.DB, error) {
if overrideEndpoint != "" {
addr = overrideEndpoint
} else {
addr = fmt.Sprintf("127.0.0.1:%d", c.forwarder.sqlPort)
var err error
if addr, err = c.forwarder.getEndpointAddr(c.forwarder.sqlPort); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

how about getSQLEndpointAddr?

@@ -158,10 +164,19 @@ func (c *Client) SendGetRequest(path string) ([]byte, error) {
if overrideEndpoint != "" {
addr = overrideEndpoint
} else {
addr = fmt.Sprintf("127.0.0.1:%d", c.forwarder.statusPort)
var err error
if addr, err = c.forwarder.getEndpointAddr(c.forwarder.statusPort); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

how about getStatusEndpointAddr?

@@ -118,6 +113,14 @@ func (f *Forwarder) pollingForTiDB() {
}
}

func (f *Forwarder) getEndpointAddr(port int) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • HunDunDM

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@breezewish breezewish merged commit 1a1296d into pingcap:master May 7, 2021
shhdgit pushed a commit to shhdgit/tidb-dashboard that referenced this pull request May 12, 2021
shhdgit pushed a commit to shhdgit/tidb-dashboard that referenced this pull request May 12, 2021
breezewish pushed a commit that referenced this pull request May 12, 2021
* fix(ttlcache): goroutine leak (#892)
* tidb: forwarder only uses tidb whose status is Up (#893)
* keyviz: Add tips for enabled config (#901)
* ui: rocksdb fields (#896)
* monitoring: setup sentry (#895)
* tidb_client: improve behavior when no alive tidb instance (#900)
* feat(stmt): support config maximum number of stmt kept in memory (#914)
* feat: debug api (#898)
* ui: Improve settings description for Statement (#920)
* feat(ui): add tiflash profiling option (#859)
* ui: Add a warning for the debug API (#922)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading log and incorrect connection when no TiDB is available
5 participants