Skip to content

Commit

Permalink
Blocks grabbing the publishing lock are uncached
Browse files Browse the repository at this point in the history
  • Loading branch information
svevang committed Aug 9, 2023
1 parent 2052046 commit c59101c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/concerns/advisory_locks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c59101c

Please sign in to comment.