{"action":"created","issue":{"url":"https://api.github.com/repos/wealthsimple/pheme/issues/47","repository_url":"https://api.github.com/repos/wealthsimple/pheme","labels_url":"https://api.github.com/repos/wealthsimple/pheme/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/wealthsimple/pheme/issues/47/comments","events_url":"https://api.github.com/repos/wealthsimple/pheme/issues/47/events","html_url":"https://github.com/wealthsimple/pheme/pull/47","id":494066802,"node_id":"MDExOlB1bGxSZXF1ZXN0MzE3ODkzNDU5","number":47,"title":"Release connection between handling messages","user":{"login":"rperryng","id":6402435,"node_id":"MDQ6VXNlcjY0MDI0MzU=","avatar_url":"https://avatars2.githubusercontent.com/u/6402435?v=4","gravatar_id":"","url":"https://api.github.com/users/rperryng","html_url":"https://github.com/rperryng","followers_url":"https://api.github.com/users/rperryng/followers","following_url":"https://api.github.com/users/rperryng/following{/other_user}","gists_url":"https://api.github.com/users/rperryng/gists{/gist_id}","starred_url":"https://api.github.com/users/rperryng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rperryng/subscriptions","organizations_url":"https://api.github.com/users/rperryng/orgs","repos_url":"https://api.github.com/users/rperryng/repos","events_url":"https://api.github.com/users/rperryng/events{/privacy}","received_events_url":"https://api.github.com/users/rperryng/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2019-09-16T13:56:47Z","updated_at":"2019-09-16T15:01:04Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/wealthsimple/pheme/pulls/47","html_url":"https://github.com/wealthsimple/pheme/pull/47","diff_url":"https://github.com/wealthsimple/pheme/pull/47.diff","patch_url":"https://github.com/wealthsimple/pheme/pull/47.patch"},"body":"#### Why <!-- A short description of why this change is required -->\r\n1. [Using the `connection_pool_block` option opens and holds a DB transaction open](https://github.com/wealthsimple/pheme/blob/master/lib/pheme/queue_poller.rb#L142) for the [entire duration of the poll](https://github.com/wealthsimple/pheme/blob/master/lib/pheme/queue_poller.rb#L56)\r\n2. Sometimes the container that the poller is running on loses its database connection.\r\n3. Pheme catches an error about the lost DB connection, logs it, and will continuously try to to `handle_content` with the broken DB connection (since the `with_optional_connection_pool_block` hasn't finished yet, and so its still using the same transaction as the one it first acquired, even if its broken).\r\n\r\nThis gets a container stuck until redeploying.\r\nI think grabbing a new connection each time from the pool would get around this issue.\r\n\r\n\r\n#### What changed <!-- Summary of changes when modifying hundreds of lines -->\r\nObtain a DB connection from the pool every time when trying to `handle_content`\r\n\r\n\r\n<!--\r\nConsider adding the following sections:\r\n\r\n#### How I tested [ Bullets for test cases covered ]\r\n#### Next steps [ If your PR is part of a few or a WIP, give context to reviewers ]\r\n#### Screenshot [ An image is worth a thousand words ]\r\n#### Bug/Ticket tracker [ Unnecessary when prefixing branch with JIRA ticket, e.g. SECURITY-123-human-readable-thing ]\r\n-->\r\n"},"comment":{"url":"https://api.github.com/repos/wealthsimple/pheme/issues/comments/531817175","html_url":"https://github.com/wealthsimple/pheme/pull/47#issuecomment-531817175","issue_url":"https://api.github.com/repos/wealthsimple/pheme/issues/47","id":531817175,"node_id":"MDEyOklzc3VlQ29tbWVudDUzMTgxNzE3NQ==","user":{"login":"rperryng","id":6402435,"node_id":"MDQ6VXNlcjY0MDI0MzU=","avatar_url":"https://avatars2.githubusercontent.com/u/6402435?v=4","gravatar_id":"","url":"https://api.github.com/users/rperryng","html_url":"https://github.com/rperryng","followers_url":"https://api.github.com/users/rperryng/followers","following_url":"https://api.github.com/users/rperryng/following{/other_user}","gists_url":"https://api.github.com/users/rperryng/gists{/gist_id}","starred_url":"https://api.github.com/users/rperryng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rperryng/subscriptions","organizations_url":"https://api.github.com/users/rperryng/orgs","repos_url":"https://api.github.com/users/rperryng/repos","events_url":"https://api.github.com/users/rperryng/events{/privacy}","received_events_url":"https://api.github.com/users/rperryng/received_events","type":"User","site_admin":false},"created_at":"2019-09-16T15:01:04Z","updated_at":"2019-09-16T15:01:04Z","author_association":"NONE","body":"It shouldn't add any connection overhead.  The pool should be a collection of live db connections.  The pool just manages who has access to them at any single point in time - it's for thread synchronization.  ActiveRecord should be replacing connections as they die, something we aren't letting it do since we hold on to the first connection we get forever\r\n\r\nhttps://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html"}}
{"actor":{"display_login":"rperryng"}}