Skip to content

PingContext not cancel when ctx deadline #1005

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

Closed
zjmnssy opened this issue Sep 26, 2019 · 5 comments
Closed

PingContext not cancel when ctx deadline #1005

zjmnssy opened this issue Sep 26, 2019 · 5 comments

Comments

@zjmnssy
Copy link

zjmnssy commented Sep 26, 2019

Issue description

when i specially use a unavailable mysql server address to test PingContext, PingContext not cancel when ctx deadline, and every time it will cost 21 seconds when return error of " dial tcp 192.168.31.123:3306: connect: connection refused", but it should return error of "context canceled" after my ctx timeout.

Example code

ctx, cancel := context.WithTimeout(context.Background(), time.Duration(3)*time.Second)
defer cancel()

err = db.PingContext(ctx)
if err != nil {
    return
}
@methane
Copy link
Member

methane commented Sep 27, 2019

Have you tried master branch?

@zjmnssy
Copy link
Author

zjmnssy commented Sep 27, 2019

Have you tried master branch?

image
this is my go mod file, i found PingContext func is in go/src/database/sql/sql.go , it maybe not because of go-sql-driver problem ?

@methane
Copy link
Member

methane commented Sep 27, 2019

#823 implements Ping but it is not included in 1.4 series and v1.5 is not released yet.
So you need to try master branch, instead of latest release.

@zjmnssy
Copy link
Author

zjmnssy commented Sep 28, 2019

#823 implements Ping but it is not included in 1.4 series and v1.5 is not released yet.
So you need to try master branch, instead of latest release.

ok, I will try.

@zjmnssy
Copy link
Author

zjmnssy commented Sep 28, 2019

#823 implements Ping but it is not included in 1.4 series and v1.5 is not released yet.
So you need to try master branch, instead of latest release.

ok, I will try.

yes,when use master, the problem not exist, thank you!

@methane methane closed this as completed Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants