{"action":"created","issue":{"url":"https://api.github.com/repos/celluloid/celluloid/issues/499","labels_url":"https://api.github.com/repos/celluloid/celluloid/issues/499/labels{/name}","comments_url":"https://api.github.com/repos/celluloid/celluloid/issues/499/comments","events_url":"https://api.github.com/repos/celluloid/celluloid/issues/499/events","html_url":"https://github.com/celluloid/celluloid/issues/499","id":60888273,"number":499,"title":"ActiveRecord connections leaking when referencing an undefined local in a class method","user":{"login":"nullstyle","id":366,"avatar_url":"https://avatars.githubusercontent.com/u/366?v=3","gravatar_id":"","url":"https://api.github.com/users/nullstyle","html_url":"https://github.com/nullstyle","followers_url":"https://api.github.com/users/nullstyle/followers","following_url":"https://api.github.com/users/nullstyle/following{/other_user}","gists_url":"https://api.github.com/users/nullstyle/gists{/gist_id}","starred_url":"https://api.github.com/users/nullstyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nullstyle/subscriptions","organizations_url":"https://api.github.com/users/nullstyle/orgs","repos_url":"https://api.github.com/users/nullstyle/repos","events_url":"https://api.github.com/users/nullstyle/events{/privacy}","received_events_url":"https://api.github.com/users/nullstyle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-12T19:49:43Z","updated_at":"2015-03-12T21:00:24Z","closed_at":null,"body":"I couldn't easily decide if this is a celluloid or an activerecord issue, so I'm deciding to post this here first.  Apologies if this would better be submitted to activerecord's repo.\r\n\r\nRepro code: https://github.com/nullstyle/celluloid-ar-leaker\r\n\r\n## Overview\r\nWhen referencing an undefined local variable or calling an undefined method within\r\na class method defined on an ActiveRecord::Base subclass in the calling context of a\r\nCelluloid::Pool, ActiveRecord connection objects are not properly returned to the\r\nconnection pool.\r\n\r\n## Notes:\r\n\r\n- This behavior only exhibits itself with when in a class method of an AR::Base \r\n  subclass.  The following _does not trigger_ the leak:  Calling an instance method\r\n  on an AR::Base subclass, calling a class method on a non-AR::Base subclass,\r\n  calling a module method.\r\n\r\n- This behavior seems specific to the exception raised when referencing an undefined\r\n  local.  The following _does not trigger_ the leak: Referencing an undefined constant,\r\n  raising a NameError directly, raising any other Exception.\r\n\r\n- I was not able to re-produce this behavior using Thread or Fiber directly.\r\n- I did not test for reproduction on any other DB than postgresql.\r\n"},"comment":{"url":"https://api.github.com/repos/celluloid/celluloid/issues/comments/78615181","html_url":"https://github.com/celluloid/celluloid/issues/499#issuecomment-78615181","issue_url":"https://api.github.com/repos/celluloid/celluloid/issues/499","id":78615181,"user":{"login":"tarcieri","id":797,"avatar_url":"https://avatars.githubusercontent.com/u/797?v=3","gravatar_id":"","url":"https://api.github.com/users/tarcieri","html_url":"https://github.com/tarcieri","followers_url":"https://api.github.com/users/tarcieri/followers","following_url":"https://api.github.com/users/tarcieri/following{/other_user}","gists_url":"https://api.github.com/users/tarcieri/gists{/gist_id}","starred_url":"https://api.github.com/users/tarcieri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarcieri/subscriptions","organizations_url":"https://api.github.com/users/tarcieri/orgs","repos_url":"https://api.github.com/users/tarcieri/repos","events_url":"https://api.github.com/users/tarcieri/events{/privacy}","received_events_url":"https://api.github.com/users/tarcieri/received_events","type":"User","site_admin":false},"created_at":"2015-03-12T21:00:24Z","updated_at":"2015-03-12T21:00:24Z","body":"I'm not sure what to tell you besides \"don't do that\"?\r\n\r\nWhy are you calling undefined locals/methods in the first place?"}}