-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add support for read/write timeouts #375
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
Comments
Does https://godoc.org/github.com/go-sql-driver/mysql#RegisterDial help? |
That is for the dialer only then. The driver indeed does not support proper read / write timeouts currently. |
I don't believe so as the deadlines are absolute times which are set on each read/write. |
Related: #372 |
A little convoluted, but: net.Conn is an interface. A long one, but still an interface. |
Doing socket reads/writes without a timeout is not really safe ever, so the common case should be to set a timeout, even if it is a long one. |
Dead must early, then we can handle it . if the connection broken ,just tell us it broken, then we can reconnect by init new connection. I have made issue report #392 |
How about set IPConn.SetReadDeadline for the connections ? such as 30 seconds (can be configured)if no response, then close connections |
libmysqlclient (official client library written in C++) have I'm +1 to adding |
I can see this issue open for long times. and i faced problem like this. so i should do something, to help my self out. |
FYI, Go 1.6 have new API: Setting it short (e.g. 1minute) may help to avoid some network troubles. |
We using Golang 1.3 and 1.4. so we can not waiting for 1.6 golang release |
methane, I don't get your comment. The driver is broken, it should correctly set timeouts. Don't blame the end user here. |
@arnehormann
each time when the deadline runs out (yes, it will also output two lines each time, that are duplicated). Super annoying when you've set a deadline for 30seconds and it starts to spam the logs. It's solved with 👍 for proper read/write timeouts in the driver. |
The mysql driver code doesn't have any read/write deadlines. Thats bad as poor network conditions can lead to connections hanging forever. We had, for example, this one:
goroutine 8585754 [IO wait, 6382 minutes]:
net.(_pollDesc).Wait(0xc2097f2f40, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:84 +0x47
net.(_pollDesc).WaitRead(0xc2097f2f40, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:89 +0x43
net.(_netFD).Read(0xc2097f2ee0, 0xc2109a2000, 0x1000, 0x1000, 0x0, 0x7f74e732fe70, 0xc20a474c80)
/usr/local/go/src/net/fd_unix.go:242 +0x40f
net.(_conn).Read(0xc208955d10, 0xc2109a2000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:121 +0xdc
github.com/go-sql-driver/mysql.(_buffer).fill(0xc21074e480, 0x4, 0x0, 0x0)
/source/.gopack/vendor/src/github.com/go-sql-driver/mysql/buffer.go:55 +0x28e
github.com/go-sql-driver/mysql.(_buffer).readNext(0xc21074e480, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0)
/source/.gopack/vendor/src/github.com/go-sql-driver/mysql/buffer.go:76 +0x68
github.com/go-sql-driver/mysql.(_mysqlConn).readPacket(0xc209ab0280, 0x0, 0x0, 0x0, 0x0, 0x0)
/source/.gopack/vendor/src/github.com/go-sql-driver/mysql/packets.go:28 +0x7b
github.com/go-sql-driver/mysql.(_mysqlConn).readInitPacket(0xc209ab0280, 0x0, 0x0, 0x0, 0x0, 0x0)
/source/.gopack/vendor/src/github.com/go-sql-driver/mysql/packets.go:146 +0x72
github.com/go-sql-driver/mysql.(_MySQLDriver).Open(0x15ee208, 0xc20802d6c6, 0x35, 0x0, 0x0, 0x0, 0x0)
/source/.gopack/vendor/src/github.com/go-sql-driver/mysql/driver.go:54 +0x3f5
database/sql.(_DB).conn(0xc20841d400, 0xc210aef100, 0x0, 0x0)
/usr/local/go/src/database/sql/sql.go:664 +0x506
database/sql.(_DB).query(0xc20841d400, 0x107aab0, 0x67, 0xc20c53d5f8, 0x1, 0x1, 0x7f74c71ac6b8, 0x0, 0x0)
/usr/local/go/src/database/sql/sql.go:933 +0x43
database/sql.(_DB).Query(0xc20841d400, 0x107aab0, 0x67, 0xc20c53d5f8, 0x1, 0x1, 0x40f1cc, 0x0, 0x0)
/usr/local/go/src/database/sql/sql.go:924 +0xa6
database/sql.(*DB).QueryRow(0xc20841d400, 0x107aab0, 0x67, 0xc20c53d5f8, 0x1, 0x1, 0x40f98f)
/usr/local/go/src/database/sql/sql.go:1002 +0x66
The text was updated successfully, but these errors were encountered: