{"action":"created","issue":{"url":"https://api.github.com/repos/go-sql-driver/mysql/issues/375","labels_url":"https://api.github.com/repos/go-sql-driver/mysql/issues/375/labels{/name}","comments_url":"https://api.github.com/repos/go-sql-driver/mysql/issues/375/comments","events_url":"https://api.github.com/repos/go-sql-driver/mysql/issues/375/events","html_url":"https://github.com/go-sql-driver/mysql/issues/375","id":111415589,"number":375,"title":"Add support for read/write timeouts","user":{"login":"newhook","id":10376697,"avatar_url":"https://avatars.githubusercontent.com/u/10376697?v=3","gravatar_id":"","url":"https://api.github.com/users/newhook","html_url":"https://github.com/newhook","followers_url":"https://api.github.com/users/newhook/followers","following_url":"https://api.github.com/users/newhook/following{/other_user}","gists_url":"https://api.github.com/users/newhook/gists{/gist_id}","starred_url":"https://api.github.com/users/newhook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/newhook/subscriptions","organizations_url":"https://api.github.com/users/newhook/orgs","repos_url":"https://api.github.com/users/newhook/repos","events_url":"https://api.github.com/users/newhook/events{/privacy}","received_events_url":"https://api.github.com/users/newhook/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/go-sql-driver/mysql/labels/enhancement","name":"enhancement","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-14T14:51:48Z","updated_at":"2015-10-14T15:17:24Z","closed_at":null,"body":"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:\r\n\r\ngoroutine 8585754 [IO wait, 6382 minutes]:\r\nnet.(*pollDesc).Wait(0xc2097f2f40, 0x72, 0x0, 0x0)\r\n\t/usr/local/go/src/net/fd_poll_runtime.go:84 +0x47\r\nnet.(*pollDesc).WaitRead(0xc2097f2f40, 0x0, 0x0)\r\n\t/usr/local/go/src/net/fd_poll_runtime.go:89 +0x43\r\nnet.(*netFD).Read(0xc2097f2ee0, 0xc2109a2000, 0x1000, 0x1000, 0x0, 0x7f74e732fe70, 0xc20a474c80)\r\n\t/usr/local/go/src/net/fd_unix.go:242 +0x40f\r\nnet.(*conn).Read(0xc208955d10, 0xc2109a2000, 0x1000, 0x1000, 0x0, 0x0, 0x0)\r\n\t/usr/local/go/src/net/net.go:121 +0xdc\r\ngithub.com/go-sql-driver/mysql.(*buffer).fill(0xc21074e480, 0x4, 0x0, 0x0)\r\n\t/source/.gopack/vendor/src/github.com/go-sql-driver/mysql/buffer.go:55 +0x28e\r\ngithub.com/go-sql-driver/mysql.(*buffer).readNext(0xc21074e480, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0)\r\n\t/source/.gopack/vendor/src/github.com/go-sql-driver/mysql/buffer.go:76 +0x68\r\ngithub.com/go-sql-driver/mysql.(*mysqlConn).readPacket(0xc209ab0280, 0x0, 0x0, 0x0, 0x0, 0x0)\r\n\t/source/.gopack/vendor/src/github.com/go-sql-driver/mysql/packets.go:28 +0x7b\r\ngithub.com/go-sql-driver/mysql.(*mysqlConn).readInitPacket(0xc209ab0280, 0x0, 0x0, 0x0, 0x0, 0x0)\r\n\t/source/.gopack/vendor/src/github.com/go-sql-driver/mysql/packets.go:146 +0x72\r\ngithub.com/go-sql-driver/mysql.(*MySQLDriver).Open(0x15ee208, 0xc20802d6c6, 0x35, 0x0, 0x0, 0x0, 0x0)\r\n\t/source/.gopack/vendor/src/github.com/go-sql-driver/mysql/driver.go:54 +0x3f5\r\ndatabase/sql.(*DB).conn(0xc20841d400, 0xc210aef100, 0x0, 0x0)\r\n\t/usr/local/go/src/database/sql/sql.go:664 +0x506\r\ndatabase/sql.(*DB).query(0xc20841d400, 0x107aab0, 0x67, 0xc20c53d5f8, 0x1, 0x1, 0x7f74c71ac6b8, 0x0, 0x0)\r\n\t/usr/local/go/src/database/sql/sql.go:933 +0x43\r\ndatabase/sql.(*DB).Query(0xc20841d400, 0x107aab0, 0x67, 0xc20c53d5f8, 0x1, 0x1, 0x40f1cc, 0x0, 0x0)\r\n\t/usr/local/go/src/database/sql/sql.go:924 +0xa6\r\ndatabase/sql.(*DB).QueryRow(0xc20841d400, 0x107aab0, 0x67, 0xc20c53d5f8, 0x1, 0x1, 0x40f98f)\r\n\t/usr/local/go/src/database/sql/sql.go:1002 +0x66"},"comment":{"url":"https://api.github.com/repos/go-sql-driver/mysql/issues/comments/148081450","html_url":"https://github.com/go-sql-driver/mysql/issues/375#issuecomment-148081450","issue_url":"https://api.github.com/repos/go-sql-driver/mysql/issues/375","id":148081450,"user":{"login":"arnehormann","id":1011413,"avatar_url":"https://avatars.githubusercontent.com/u/1011413?v=3","gravatar_id":"","url":"https://api.github.com/users/arnehormann","html_url":"https://github.com/arnehormann","followers_url":"https://api.github.com/users/arnehormann/followers","following_url":"https://api.github.com/users/arnehormann/following{/other_user}","gists_url":"https://api.github.com/users/arnehormann/gists{/gist_id}","starred_url":"https://api.github.com/users/arnehormann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arnehormann/subscriptions","organizations_url":"https://api.github.com/users/arnehormann/orgs","repos_url":"https://api.github.com/users/arnehormann/repos","events_url":"https://api.github.com/users/arnehormann/events{/privacy}","received_events_url":"https://api.github.com/users/arnehormann/received_events","type":"User","site_admin":false},"created_at":"2015-10-14T15:17:24Z","updated_at":"2015-10-14T15:17:24Z","body":"A little convoluted, but: net.Conn is an interface. A long one, but still an interface.\r\nThe dial function could return a wrapper which does all that stuff.\r\nIf it's a common problem, the driver could even provide the wrapper - or a \"does everything wrapper\" with configuration options to tweak all these settings. We could provide common profiles in the DSN to configure such a wrapper.\r\nDoing so keeps the code clean for the common/fast case but makes everything configurable.\r\nWould that suffice? We could probably also use something like it for #302 to make the fix optional per DSN and keep the legacy behavior otherwise..."}}