{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/10886","labels_url":"https://api.github.com/repos/golang/go/issues/10886/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/10886/comments","events_url":"https://api.github.com/repos/golang/go/issues/10886/events","html_url":"https://github.com/golang/go/issues/10886","id":77298511,"number":10886,"title":"database/sql: Exec() never returns when IP is not reachable and maxOpenConns is reached","user":{"login":"joew1","id":12461704,"avatar_url":"https://avatars.githubusercontent.com/u/12461704?v=3","gravatar_id":"","url":"https://api.github.com/users/joew1","html_url":"https://github.com/joew1","followers_url":"https://api.github.com/users/joew1/followers","following_url":"https://api.github.com/users/joew1/following{/other_user}","gists_url":"https://api.github.com/users/joew1/gists{/gist_id}","starred_url":"https://api.github.com/users/joew1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joew1/subscriptions","organizations_url":"https://api.github.com/users/joew1/orgs","repos_url":"https://api.github.com/users/joew1/repos","events_url":"https://api.github.com/users/joew1/events{/privacy}","received_events_url":"https://api.github.com/users/joew1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"bradfitz","id":2621,"avatar_url":"https://avatars.githubusercontent.com/u/2621?v=3","gravatar_id":"","url":"https://api.github.com/users/bradfitz","html_url":"https://github.com/bradfitz","followers_url":"https://api.github.com/users/bradfitz/followers","following_url":"https://api.github.com/users/bradfitz/following{/other_user}","gists_url":"https://api.github.com/users/bradfitz/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfitz/subscriptions","organizations_url":"https://api.github.com/users/bradfitz/orgs","repos_url":"https://api.github.com/users/bradfitz/repos","events_url":"https://api.github.com/users/bradfitz/events{/privacy}","received_events_url":"https://api.github.com/users/bradfitz/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/24","html_url":"https://github.com/golang/go/milestones/Go1.6","labels_url":"https://api.github.com/repos/golang/go/milestones/24/labels","id":1096159,"number":24,"title":"Go1.6","description":"","creator":{"login":"josharian","id":67496,"avatar_url":"https://avatars.githubusercontent.com/u/67496?v=3","gravatar_id":"","url":"https://api.github.com/users/josharian","html_url":"https://github.com/josharian","followers_url":"https://api.github.com/users/josharian/followers","following_url":"https://api.github.com/users/josharian/following{/other_user}","gists_url":"https://api.github.com/users/josharian/gists{/gist_id}","starred_url":"https://api.github.com/users/josharian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josharian/subscriptions","organizations_url":"https://api.github.com/users/josharian/orgs","repos_url":"https://api.github.com/users/josharian/repos","events_url":"https://api.github.com/users/josharian/events{/privacy}","received_events_url":"https://api.github.com/users/josharian/received_events","type":"User","site_admin":false},"open_issues":326,"closed_issues":121,"state":"open","created_at":"2015-05-05T02:39:06Z","updated_at":"2015-09-14T12:05:29Z","due_on":"2016-01-31T08:00:00Z","closed_at":null},"comments":10,"created_at":"2015-05-17T12:21:42Z","updated_at":"2015-09-14T15:00:56Z","closed_at":null,"body":"With go1.4.2, maxOpenConn set to 2, and an unreachable IP:\r\n    - two Exec() returns an error\r\n    - but the third Exec() never returns\r\n\r\n```go\r\nimport \"database/sql\"\r\nimport _ \"github.com/go-sql-driver/mysql\"\r\n...\r\ndb := sql.Open(\"mysql\", \"root:password@tcp(1.2.3.4:3306)/mysql?timeout=15s\")\r\ndb.SetMaxOpenConn(2)\r\ndb.SetMaxIdleConns(0)\r\nfor i := 0; i < 3; i++ {\r\ngo func() {\r\n_, err := db.Exec(\"SELECT SLEEP(5)\")\r\n  if err != nil {\r\n    log.Println(err)\r\n  }\r\n  log.Println(\"Done\")\r\n  }\r\n}\r\n...\r\n```\r\n\r\nAdding a call to db.maybeOpenNewConnections() after database/sql/sql.go:667 seems to fix this issue. But I'm not sure whether this is the correct fix or not.  Please help.  Thanks.\r\n\r\n```\r\n664 ci, err := db.driver.Open(db.dsn)\r\n665 if err != nil {\r\n666 db.mu.Lock()\r\n667 db.numOpen-- // correct for earlier optimism\r\n       db.maybeOpenNewConnections()\r\n668 db.mu.Unlock()\r\n669 return nil, err\r\n670 }\r\n```"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/140108111","html_url":"https://github.com/golang/go/issues/10886#issuecomment-140108111","issue_url":"https://api.github.com/repos/golang/go/issues/10886","id":140108111,"user":{"login":"gopherbot","id":8566911,"avatar_url":"https://avatars.githubusercontent.com/u/8566911?v=3","gravatar_id":"","url":"https://api.github.com/users/gopherbot","html_url":"https://github.com/gopherbot","followers_url":"https://api.github.com/users/gopherbot/followers","following_url":"https://api.github.com/users/gopherbot/following{/other_user}","gists_url":"https://api.github.com/users/gopherbot/gists{/gist_id}","starred_url":"https://api.github.com/users/gopherbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gopherbot/subscriptions","organizations_url":"https://api.github.com/users/gopherbot/orgs","repos_url":"https://api.github.com/users/gopherbot/repos","events_url":"https://api.github.com/users/gopherbot/events{/privacy}","received_events_url":"https://api.github.com/users/gopherbot/received_events","type":"User","site_admin":false},"created_at":"2015-09-14T15:00:56Z","updated_at":"2015-09-14T15:00:56Z","body":"CL https://golang.org/cl/14547 mentions this issue."}}