{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/19332","labels_url":"https://api.github.com/repos/rails/rails/issues/19332/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/19332/comments","events_url":"https://api.github.com/repos/rails/rails/issues/19332/events","html_url":"https://github.com/rails/rails/issues/19332","id":61642672,"number":19332,"title":"Connection leakage when inspecting exceptions across Threads","user":{"login":"halorgium","id":263,"avatar_url":"https://avatars.githubusercontent.com/u/263?v=3","gravatar_id":"","url":"https://api.github.com/users/halorgium","html_url":"https://github.com/halorgium","followers_url":"https://api.github.com/users/halorgium/followers","following_url":"https://api.github.com/users/halorgium/following{/other_user}","gists_url":"https://api.github.com/users/halorgium/gists{/gist_id}","starred_url":"https://api.github.com/users/halorgium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halorgium/subscriptions","organizations_url":"https://api.github.com/users/halorgium/orgs","repos_url":"https://api.github.com/users/halorgium/repos","events_url":"https://api.github.com/users/halorgium/events{/privacy}","received_events_url":"https://api.github.com/users/halorgium/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-14T16:46:54Z","updated_at":"2015-03-14T17:20:53Z","closed_at":null,"body":"We've been tracking an issue with Celluloid (https://github.com/celluloid/celluloid/issues/499) where an exception occurs inside ActiveRecord and is then handled by the core Celluloid actor as a crash. \r\nAs part of the handling, the exception is inspected which causes a connection to be checked out of the pool. Then the thread dies and orphans the connection. \r\n\r\nWas the assumption around `.inspect` (and `.table_exists?`) that these methods would be used inside Threads which already hold a checked-out connection?\r\nIn Celluloid, we run blocks of code inside separate Threads or Fibers to allow for pipelining and suspending. Because of this, any methods which only checkout connections are prone to leakage. \r\n\r\nIs this change an acceptable one? https://github.com/halorgium/rails/commit/8599bf2912215ba3e17568212bd3ff1c96dacf7f\r\nI note that many other methods are along a similar vein. \r\n\r\n/cc @tarcieri @nullstyle"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/80608139","html_url":"https://github.com/rails/rails/issues/19332#issuecomment-80608139","issue_url":"https://api.github.com/repos/rails/rails/issues/19332","id":80608139,"user":{"login":"matthewd","id":1034,"avatar_url":"https://avatars.githubusercontent.com/u/1034?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewd","html_url":"https://github.com/matthewd","followers_url":"https://api.github.com/users/matthewd/followers","following_url":"https://api.github.com/users/matthewd/following{/other_user}","gists_url":"https://api.github.com/users/matthewd/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewd/subscriptions","organizations_url":"https://api.github.com/users/matthewd/orgs","repos_url":"https://api.github.com/users/matthewd/repos","events_url":"https://api.github.com/users/matthewd/events{/privacy}","received_events_url":"https://api.github.com/users/matthewd/received_events","type":"User","site_admin":false},"created_at":"2015-03-14T17:20:53Z","updated_at":"2015-03-14T17:20:53Z","body":"Which Rails version are you using? 4.2 should reclaim the connection shortly after the owning thread dies.\r\n\r\nThat commit seems fine.. though as we are currently pretty free with our use of `connection`, I'm not sure whether I'd consider it a back-portable bug fix."}}