diff --git a/app/models/concerns/advisory_locks.rb b/app/models/concerns/advisory_locks.rb index a1c434a74..222ffd5fb 100644 --- a/app/models/concerns/advisory_locks.rb +++ b/app/models/concerns/advisory_locks.rb @@ -8,7 +8,9 @@ module AdvisoryLocks def with_advisory_lock(lock_type) raise "Cannot lock unpersisted instances" unless persisted? && id.present? ActiveRecord::Base.connection.execute("SELECT pg_advisory_lock(#{lock_type}, #{id})") - yield + ActiveRecord::Base.uncached do + yield + end ensure ActiveRecord::Base.connection.execute("SELECT pg_advisory_unlock(#{lock_type}, #{id})") end