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 8334977
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/pg-locks-monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ 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|
# meta locks with duplicate data
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 +26,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

3 comments on commit 8334977

@gstokkink
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pawurb good to see virtualxid locks being filtered out by default 😄

@pawurb
Copy link
Owner Author

@pawurb pawurb commented on 8334977 Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, they turned out to be duplicate and noisy

@gstokkink
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, hence my suggesting so in #2 (comment) 👍

Please sign in to comment.