summaryrefslogtreecommitdiff
path: root/lib/declarative_policy.rb
diff options
context:
space:
mode:
authorMykhailo Formus <mikeformus@gmail.com>2018-07-12 09:55:01 +0000
committerMykhailo Formus <mikeformus@gmail.com>2018-07-12 09:55:01 +0000
commit7a21f39df92baaa88f9533316e7b19c9c70bd91e (patch)
tree090f49a7edc682c31ac29465205c16201bdbe03d /lib/declarative_policy.rb
parent331f8d71b2c778f10b926114caeb718bce7294d6 (diff)
parent767ccaa1725048cd2b27fbf1081cba3ba89d2926 (diff)
downloadgitlab-ce-mikeformus/gitlab-ce-qa-264.tar.gz
Merge branch 'master' into qa-264mikeformus/gitlab-ce-qa-264
Diffstat (limited to 'lib/declarative_policy.rb')
-rw-r--r--lib/declarative_policy.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/declarative_policy.rb b/lib/declarative_policy.rb
index 1dd2855063d..dda6cd38dcd 100644
--- a/lib/declarative_policy.rb
+++ b/lib/declarative_policy.rb
@@ -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)