{"action":"created","issue":{"url":"https://api.github.com/repos/mperham/sidekiq/issues/3221","repository_url":"https://api.github.com/repos/mperham/sidekiq","labels_url":"https://api.github.com/repos/mperham/sidekiq/issues/3221/labels{/name}","comments_url":"https://api.github.com/repos/mperham/sidekiq/issues/3221/comments","events_url":"https://api.github.com/repos/mperham/sidekiq/issues/3221/events","html_url":"https://github.com/mperham/sidekiq/pull/3221","id":187534977,"number":3221,"title":"Use Rails executor if code reloading is disabled","user":{"login":"eugeneius","id":432189,"avatar_url":"https://avatars.githubusercontent.com/u/432189?v=3","gravatar_id":"","url":"https://api.github.com/users/eugeneius","html_url":"https://github.com/eugeneius","followers_url":"https://api.github.com/users/eugeneius/followers","following_url":"https://api.github.com/users/eugeneius/following{/other_user}","gists_url":"https://api.github.com/users/eugeneius/gists{/gist_id}","starred_url":"https://api.github.com/users/eugeneius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eugeneius/subscriptions","organizations_url":"https://api.github.com/users/eugeneius/orgs","repos_url":"https://api.github.com/users/eugeneius/repos","events_url":"https://api.github.com/users/eugeneius/events{/privacy}","received_events_url":"https://api.github.com/users/eugeneius/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-11-06T01:19:11Z","updated_at":"2016-11-06T17:02:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mperham/sidekiq/pulls/3221","html_url":"https://github.com/mperham/sidekiq/pull/3221","diff_url":"https://github.com/mperham/sidekiq/pull/3221.diff","patch_url":"https://github.com/mperham/sidekiq/pull/3221.patch"},"body":"We have to release the current thread's Active Record connection after performing each job, in case another thread is waiting to use it.\r\n\r\nOn Rails 4 and earlier, this is handled with [middleware](https://github.com/mperham/sidekiq/blob/v4.2.5/lib/sidekiq/middleware/server/active_record.rb). On Rails 5 in development mode, the reloader does it by [delegating to the executor](https://github.com/rails/rails/blob/v5.0.0.1/activesupport/lib/active_support/reloader.rb#L67-L69). However on Rails 5 in production mode, we're not adding the middleware or enabling the reloader, so connections will never be released.\r\n\r\nWe can call the executor directly to have it [release the connection for us](https://github.com/rails/rails/blob/v5.0.0.1/activerecord/lib/active_record/query_cache.rb#L48) in this case. By calling it inside the middleware stack, the job will be retried if the executor raises, avoiding the problem with lost jobs that led to the reloader being [disabled in production](https://github.com/mperham/sidekiq/commit/4b3d5edd1872d64adfea0c033feb10b859f2424a)."},"comment":{"url":"https://api.github.com/repos/mperham/sidekiq/issues/comments/258694299","html_url":"https://github.com/mperham/sidekiq/pull/3221#issuecomment-258694299","issue_url":"https://api.github.com/repos/mperham/sidekiq/issues/3221","id":258694299,"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":"2016-11-06T17:02:48Z","updated_at":"2016-11-06T17:02:48Z","body":"(It apparently didn't occur to anyone in #3154 😢, but if the reloader is in fact eating work / raising on things that aren't genuine application-level problems, I'd like to know about it, so we can fix it -- I'm not just suggesting \"retry until it goes through\", but until we know what was being raised, there isn't much to do.)"}}
{"actor":{"display_login":"matthewd"}}