Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove inspect delegation in lock mode
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Krage <[email protected]>
rkrage and Ryan Krage committed Nov 17, 2023
1 parent 3038d44 commit ccfe1d2
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/pg_ha_migrations/lock_mode.rb
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ class LockMode

attr_reader :mode

delegate :inspect, :to_s, to: :mode
delegate :to_s, to: :mode

def initialize(mode)
@mode = mode
2 changes: 1 addition & 1 deletion lib/pg_ha_migrations/safe_statements.rb
Original file line number Diff line number Diff line change
@@ -530,7 +530,7 @@ def safely_acquire_lock_for_table(table, mode: :access_exclusive, &block)
if nested_target_table != target_table
raise PgHaMigrations::InvalidMigrationError, "Nested lock detected! Cannot acquire lock on #{target_table.fully_qualified_name} while #{nested_target_table.fully_qualified_name} is locked."
elsif nested_target_table.mode < target_table.mode
raise PgHaMigrations::InvalidMigrationError, "Lock escalation detected! Cannot change lock level from #{nested_target_table.mode.inspect} to #{target_table.mode.inspect} for #{target_table.fully_qualified_name}."
raise PgHaMigrations::InvalidMigrationError, "Lock escalation detected! Cannot change lock level from :#{nested_target_table.mode} to :#{target_table.mode} for #{target_table.fully_qualified_name}."
end
else
Thread.current[__method__] = target_table

0 comments on commit ccfe1d2

Please sign in to comment.