diff options
author | Samuel Cochran <sj26@sj26.com> | 2018-05-24 06:50:36 +1000 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2018-05-23 16:50:36 -0400 |
commit | 4d43b05881265ee02cb4b7ab37d7e1fa49559184 (patch) | |
tree | c8b373bc7b75fb4d65801ed6c3e786b886129bf3 /actionmailer | |
parent | 78a9de52ddccefd01af2b88c21450dc29386f029 (diff) | |
download | rails-4d43b05881265ee02cb4b7ab37d7e1fa49559184.tar.gz rails-4d43b05881265ee02cb4b7ab37d7e1fa49559184.tar.bz2 rails-4d43b05881265ee02cb4b7ab37d7e1fa49559184.zip |
Eager autoload mail gem when eager load is true (#32808)
* Eager autoload mail gem when eager load is true
We had a production issue where our Sidekiq worker threads all became
deadlocked while autoloading a file within the mail gem, required via
ActionMailer, despite setting our Rails applicaiton to eager load.
`Mail.eager_autoload!` exists and works great, ActionMailer just doesn't
call it during eager loading. Adding it to the ActionMailer Railtie's
eager_load_namespaces takes care of calling `Mail.eager_autoload!`
during the `eager_load!` initializer.
* 'Mail' isn't defined yet, use before_eager_load instead
* Make sure mail is loaded
* Move eager load of Mail into ActionMailer.eager_load!
[Samuel Cochran + Rafael Mendonça França]
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/CHANGELOG.md | 4 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer.rb | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md index 9fb2e44210..6d91d4fbd6 100644 --- a/actionmailer/CHANGELOG.md +++ b/actionmailer/CHANGELOG.md @@ -1,3 +1,7 @@ +* Ensure mail gem is eager autoloaded when eager load is true to prevent thread deadlocks. + + *Samuel Cochran* + * Perform email jobs in `assert_emails`. *Gannon McGibbon* diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb index fabbdd1b25..69eae65d60 100644 --- a/actionmailer/lib/action_mailer.rb +++ b/actionmailer/lib/action_mailer.rb @@ -52,6 +52,13 @@ module ActionMailer autoload :TestHelper autoload :MessageDelivery autoload :DeliveryJob + + def self.eager_load! + super + + require "mail" + Mail.eager_autoload! + end end autoload :Mime, "action_dispatch/http/mime_type" |