Skip to content

Commit

Permalink
Ignore virtualxid locks, and fix blocking duration
Browse files Browse the repository at this point in the history
  • Loading branch information
pawurb committed Oct 17, 2024
1 parent 3f86183 commit 8a338aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/pg-locks-monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ def self.snapshot!
if (age = lock.fetch("age"))
(ActiveSupport::Duration.parse(age).to_f * 1000) > configuration.locks_min_duration_ms
end
end.select(&configuration.locks_filter_proc)
end.select do |lock|
lock.fetch("locktype") != "virtualxid"
end
.select(&configuration.locks_filter_proc)
.first(configuration.locks_limit)

if locks.count > 0 && configuration.monitor_locks
Expand All @@ -22,7 +25,7 @@ def self.snapshot!

blocking = RailsPgExtras.blocking(in_format: :hash).select do |block|
if (age = block.fetch("blocking_duration"))
(ActiveSupport::Duration.parse(age).to_f * 1000) > configuration.locks_min_duration_ms
(ActiveSupport::Duration.parse(age).to_f * 1000) > configuration.blocking_min_duration_ms
end
end.select(&configuration.blocking_filter_proc)
.first(configuration.locks_limit)
Expand Down
2 changes: 1 addition & 1 deletion lib/pg_locks_monitor/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module PgLocksMonitor
VERSION = "0.3.1"
VERSION = "0.3.2"
end

0 comments on commit 8a338aa

Please sign in to comment.