{"action":"created","issue":{"url":"https://api.github.com/repos/tgriesser/knex/issues/1688","repository_url":"https://api.github.com/repos/tgriesser/knex","labels_url":"https://api.github.com/repos/tgriesser/knex/issues/1688/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/knex/issues/1688/comments","events_url":"https://api.github.com/repos/tgriesser/knex/issues/1688/events","html_url":"https://github.com/tgriesser/knex/issues/1688","id":178877764,"number":1688,"title":"Available connections is suddenly 0 without recovering in 0.12","user":{"login":"dagingaa","id":284996,"avatar_url":"https://avatars.githubusercontent.com/u/284996?v=3","gravatar_id":"","url":"https://api.github.com/users/dagingaa","html_url":"https://github.com/dagingaa","followers_url":"https://api.github.com/users/dagingaa/followers","following_url":"https://api.github.com/users/dagingaa/following{/other_user}","gists_url":"https://api.github.com/users/dagingaa/gists{/gist_id}","starred_url":"https://api.github.com/users/dagingaa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dagingaa/subscriptions","organizations_url":"https://api.github.com/users/dagingaa/orgs","repos_url":"https://api.github.com/users/dagingaa/repos","events_url":"https://api.github.com/users/dagingaa/events{/privacy}","received_events_url":"https://api.github.com/users/dagingaa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-23T13:28:41Z","updated_at":"2016-09-23T13:51:54Z","closed_at":null,"body":"Hi all!\r\n\r\nWe're seeing a weird issue recently, where available connections suddenly drop to 0 without being able to recover on one of our servers. Other servers are chugging along nicely, but every once in a while this happens. The consequence is that database queues grow indefinitely and the usual `Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?` is thrown all over the place. I've checked our code for nasty transactions as suggested, but we don't have any that could explain suddenly locking up 10 database connections.\r\n\r\n*In New Relic we see the following pattern for available connections*:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/284996/18786905/985c4e08-81a0-11e6-9962-bf86440921e6.png)\r\n\r\nAs you can see, one second we have 10 available, and the next 0. This does not get fixed until I restart the process, which is what you see when it goes back up to 10. This happens suddenly and seemingly without any obvious causes. However, we are handling a lot of traffic on these machines, so the log can be quite chaotic, especially since we're most likely looking for that one code path that went wrong, needle in a haystack, if you will.\r\n\r\nTo me, this looks like Knex suddenly mass disconnects, but we only see this problem on one server fleet, and not on the other fleet. These run different code, which suggest the error lies with our code and not Knex, but at this point I'm desperate to find a solution. I have read through thousand of lines of code looking for a culprit, to no avail. We can bandaid the problem by marking the server as unhealthy, but I would much rather understand why this happens, and how we can avoid it in the future.\r\n\r\nHas anyone seen anything like this before? Any hunches to where I should continue looking?\r\n\r\nTo help debug this issue, I'm attaching some code examples of how we do transactions today, perhaps we're doing something horribly wrong there and I'm just not picking up on it.\r\n\r\n```\r\n.transaction((t) => {\r\n    return Promise.all([\r\n        t.delete().from(\"table1\").where(\"field\", fieldValue),\r\n        t.delete().from(\"table2\").where(\"field\", fieldValue)\r\n    ]);\r\n})\r\n```\r\n\r\nThank you to whoever took the time to read through it, all help is appreciated!"},"comment":{"url":"https://api.github.com/repos/tgriesser/knex/issues/comments/249198825","html_url":"https://github.com/tgriesser/knex/issues/1688#issuecomment-249198825","issue_url":"https://api.github.com/repos/tgriesser/knex/issues/1688","id":249198825,"user":{"login":"tgriesser","id":154748,"avatar_url":"https://avatars.githubusercontent.com/u/154748?v=3","gravatar_id":"","url":"https://api.github.com/users/tgriesser","html_url":"https://github.com/tgriesser","followers_url":"https://api.github.com/users/tgriesser/followers","following_url":"https://api.github.com/users/tgriesser/following{/other_user}","gists_url":"https://api.github.com/users/tgriesser/gists{/gist_id}","starred_url":"https://api.github.com/users/tgriesser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgriesser/subscriptions","organizations_url":"https://api.github.com/users/tgriesser/orgs","repos_url":"https://api.github.com/users/tgriesser/repos","events_url":"https://api.github.com/users/tgriesser/events{/privacy}","received_events_url":"https://api.github.com/users/tgriesser/received_events","type":"User","site_admin":false},"created_at":"2016-09-23T13:51:53Z","updated_at":"2016-09-23T13:51:53Z","body":"What database are you using? "}}
{"actor":{"display_login":"tgriesser"}}