From c59101c4d0f343821444cd0ada55667ce4d56f6a Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Wed, 9 Aug 2023 13:38:32 -0500 Subject: [PATCH] Blocks grabbing the publishing lock are uncached --- app/models/concerns/advisory_locks.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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