Commit e68a547b authored by Sean McGivern's avatar Sean McGivern

Merge branch 'rails5-autoload' into 'master'

[Rails5] Permit concurrent loads

Closes #48263

See merge request gitlab-org/gitlab-ce!20473
parents 078c824f fdfc8d04
......@@ -21,7 +21,17 @@ module DeclarativePolicy
cache = opts[:cache] || {}
key = Cache.policy_key(user, subject)
cache[key] ||= class_for(subject).new(user, subject, opts)
cache[key] ||=
if Gitlab.rails5?
# to avoid deadlocks in multi-threaded environment when
# autoloading is enabled, we allow concurrent loads,
# https://gitlab.com/gitlab-org/gitlab-ce/issues/48263
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
class_for(subject).new(user, subject, opts)
end
else
class_for(subject).new(user, subject, opts)
end
end
def class_for(subject)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment