{"action":"created","issue":{"url":"https://api.github.com/repos/jackc/pgx/issues/93","labels_url":"https://api.github.com/repos/jackc/pgx/issues/93/labels{/name}","comments_url":"https://api.github.com/repos/jackc/pgx/issues/93/comments","events_url":"https://api.github.com/repos/jackc/pgx/issues/93/events","html_url":"https://github.com/jackc/pgx/issues/93","id":106266641,"number":93,"title":"Possible rxMsg bug","user":{"login":"josephglanville","id":605591,"avatar_url":"https://avatars.githubusercontent.com/u/605591?v=3","gravatar_id":"","url":"https://api.github.com/users/josephglanville","html_url":"https://github.com/josephglanville","followers_url":"https://api.github.com/users/josephglanville/followers","following_url":"https://api.github.com/users/josephglanville/following{/other_user}","gists_url":"https://api.github.com/users/josephglanville/gists{/gist_id}","starred_url":"https://api.github.com/users/josephglanville/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josephglanville/subscriptions","organizations_url":"https://api.github.com/users/josephglanville/orgs","repos_url":"https://api.github.com/users/josephglanville/repos","events_url":"https://api.github.com/users/josephglanville/events{/privacy}","received_events_url":"https://api.github.com/users/josephglanville/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2015-09-14T03:47:10Z","updated_at":"2015-10-26T17:15:35Z","closed_at":null,"body":"Hi,\r\n\r\nI have been trying to track down a mysterious hang and I think it may be a pgx bug.\r\nHere is a stack trace of the goroutine that is hung:\r\n\r\n```\r\ngoroutine 97 [IO wait, 18 minutes]:\r\nnet.(*pollDesc).Wait(0xc20813a990, 0x72, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/net/fd_poll_runtime.go:84 +0x47\r\nnet.(*pollDesc).WaitRead(0xc20813a990, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/net/fd_poll_runtime.go:89 +0x43\r\nnet.(*netFD).Read(0xc20813a930, 0xc20819a000, 0x2000, 0x2000, 0x0, 0x7f028754edb0, 0xc20800b8b0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/net/fd_unix.go:242 +0x40f\r\nnet.(*conn).Read(0xc208036e08, 0xc20819a000, 0x2000, 0x2000, 0x0, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/net/net.go:121 +0xdc\r\nbufio.(*Reader).Read(0xc20813e900, 0xc20819a000, 0x2000, 0x2000, 0x5e, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/bufio/bufio.go:164 +0x13a\r\nio.(*LimitedReader).Read(0xc2081b8060, 0xc20819a000, 0x2000, 0x2000, 0x5e, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/io/io.go:408 +0xce\r\nio/ioutil.devNull.ReadFrom(0x0, 0x7f0287550bd8, 0xc2081b8060, 0x1ea, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/io/ioutil/ioutil.go:151 +0xb1\r\nio/ioutil.(*devNull).ReadFrom(0xc20800a2f0, 0x7f0287550bd8, 0xc2081b8060, 0x7f0287550c28, 0x0, 0x0)\r\n        <autogenerated>:9 +0xbb\r\nio.Copy(0x7f028754ecb0, 0xc20800a2f0, 0x7f0287550bd8, 0xc2081b8060, 0x0, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/io/io.go:358 +0x13d\r\nio.CopyN(0x7f028754ecb0, 0xc20800a2f0, 0x7f0287550430, 0xc20813e900, 0x5062, 0x16, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/io/io.go:327 +0x113\r\ngithub.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx.(*msgReader).rxMsg(0xc2080b3710, 0x0, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx/msg_reader.go:36 +0xa7\r\ngithub.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx.(*Conn).rxMsg(0xc2080b3200, 0x0, 0xc2080b3710, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx/conn.go:923 +0x84\r\ngithub.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx.(*Conn).Prepare(0xc2080b3200, 0x0, 0x0, 0xc2081abd60, 0x91, 0xc208135680, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx/conn.go:496 +0xcf6\r\ngithub.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx.(*Conn).Query(0xc2080b3200, 0xc2081abd60, 0x91, 0xc208111b20, 0x2, 0x2, 0x2, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx/query.go:428 +0x2c2\r\ngithub.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx.(*ConnPool).Query(0xc2080b00e0, 0xc2081abd60, 0x91, 0xc208111b20, 0x2, 0x2, 0x91, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx/conn_pool.go:196 +0x149\r\ngithub.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx.(*ConnPool).QueryRow(0xc2080b00e0, 0xc2081abd60, 0x91, 0xc208111b20, 0x2, 0x2, 0x3)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/Godeps/_workspace/src/github.com/jackc/pgx/conn_pool.go:210 +0x5a\r\ngithub.com/flynn/flynn/pkg/postgres.(*DB).QueryRow(0xc20808f4e0, 0xc2081abd60, 0x91, 0xc208111b20, 0x2, 0x2, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/pkg/postgres/postgres.go:137 +0x7e\r\nmain.selectApp(0x7f0287553a10, 0xc20808f4e0, 0xc20813b1fa, 0x24, 0x0, 0x0, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/controller/app.go:128 +0x275\r\nmain.(*AppRepo).Get(0xc20812a2a0, 0xc20813b1fa, 0x24, 0x0, 0x0, 0x0, 0x0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/controller/app.go:136 +0x8c\r\nmain.func·009(0x7f02875538a8, 0xc20812bd40, 0x7f02875538e8, 0xc20812bb60, 0xc2081a12b0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/controller/controller.go:352 +0xdd\r\ngithub.com/flynn/flynn/pkg/httphelper.HandlerFunc.ServeHTTP(0xc20801ec80, 0x7f02875538a8, 0xc20812bd40, 0x7f02875538e8, 0xc20812bb60, 0xc2081a12b0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/pkg/httphelper/httphelper.go:101 +0x55\r\ngithub.com/flynn/flynn/pkg/httphelper.func·002(0x7f02875538e8, 0xc20812bb60, 0xc2081a12b0, 0xc208135640, 0x2, 0x2)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/pkg/httphelper/httphelper.go:108 +0xcb\r\ngithub.com/flynn/flynn/Godeps/_workspace/src/github.com/julienschmidt/httprouter.(*Router).ServeHTTP(0xc20801e640, 0x7f02875538e8, 0xc20812bb60, 0xc2081a12b0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/Godeps/_workspace/src/github.com/julienschmidt/httprouter/router.go:276 +0x188\r\nmain.func·008(0x7f02875538e8, 0xc20812bb60, 0xc2081a12b0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/controller/controller.go:303 +0x44b\r\nnet/http.HandlerFunc.ServeHTTP(0xc20801ef40, 0x7f02875538e8, 0xc20812bb60, 0xc2081a12b0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/net/http/server.go:1265 +0x41\r\ngithub.com/flynn/flynn/pkg/httphelper.func·004(0x7f02875538e8, 0xc20812bb60, 0xc2081a12b0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/pkg/httphelper/request_logger.go:34 +0x8a0\r\nnet/http.HandlerFunc.ServeHTTP(0xc20812ec30, 0x7f02875538e8, 0xc20812bb60, 0xc2081a12b0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/net/http/server.go:1265 +0x41\r\ngithub.com/flynn/flynn/pkg/httphelper.func·003(0x7f0287553830, 0xc2081abb80, 0xc2081a12b0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/pkg/httphelper/httphelper.go:121 +0x25c\r\nnet/http.HandlerFunc.ServeHTTP(0xc20801ef60, 0x7f0287553830, 0xc2081abb80, 0xc2081a12b0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/net/http/server.go:1265 +0x41\r\nnet/http.serverHandler.ServeHTTP(0xc208034ae0, 0x7f0287553830, 0xc2081abb80, 0xc2081a12b0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/net/http/server.go:1703 +0x19a\r\nnet/http.(*conn).serve(0xc2081abae0)\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/net/http/server.go:1204 +0xb57\r\ncreated by net/http.(*Server).Serve\r\n        /home/ubuntu/go/src/github.com/flynn/flynn/util/_toolchain/go/src/net/http/server.go:1751 +0x35e\r\n```\r\n\r\nBy the looks of it we tried to read when there were no bytes to read causing it to block on IO or something similar.\r\nHave you encountered this before and is there any debugging code I could insert to work out if this is pgx issue or application code issue? I can reliably reproduce.\r\n\r\nThat said, it could still be a race condition because it has managed to get through my test without errors before but I can reproduce 9/10 times."},"comment":{"url":"https://api.github.com/repos/jackc/pgx/issues/comments/151213526","html_url":"https://github.com/jackc/pgx/issues/93#issuecomment-151213526","issue_url":"https://api.github.com/repos/jackc/pgx/issues/93","id":151213526,"user":{"login":"titanous","id":13026,"avatar_url":"https://avatars.githubusercontent.com/u/13026?v=3","gravatar_id":"","url":"https://api.github.com/users/titanous","html_url":"https://github.com/titanous","followers_url":"https://api.github.com/users/titanous/followers","following_url":"https://api.github.com/users/titanous/following{/other_user}","gists_url":"https://api.github.com/users/titanous/gists{/gist_id}","starred_url":"https://api.github.com/users/titanous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/titanous/subscriptions","organizations_url":"https://api.github.com/users/titanous/orgs","repos_url":"https://api.github.com/users/titanous/repos","events_url":"https://api.github.com/users/titanous/events{/privacy}","received_events_url":"https://api.github.com/users/titanous/received_events","type":"User","site_admin":false},"created_at":"2015-10-26T17:15:34Z","updated_at":"2015-10-26T17:15:34Z","body":"We have `ssl_renegotiation_limit` set to 0 on all of our servers. We did spot this bug a week ago happening consistently on what appeared to be a relatively slow server (not owned by us), but were not able to replicate on a slow EC2 instance."}}