pg-locks-monitor 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/lib/pg-locks-monitor.rb +2 -2
- data/lib/pg_locks_monitor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c15914dcf0512070ba0f629249a9743c04aad078d6f7dcd23a96acda248284f4
|
4
|
+
data.tar.gz: bbf242ededb3f441489be230e5e013d362c85b0964f34667a89b9ffe12589aa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c17edd2b3419837fd7e6f909ba8f7bf2878a28df97f0f80f0a2a12e5534188895d44f3897372445267ff8d524f1b1825d09c4a77b29ad8a991dedd4b71ba4dfb
|
7
|
+
data.tar.gz: a876c3894b680a8cc20bb29070d1e9dc8af6678cd09ed6293501ede52eecae134ddfb48b37d7441676f9a9f4499f8b0f2eba46108b963da19ebf8f6ef78992ee
|
data/README.md
CHANGED
@@ -133,14 +133,18 @@ Here's a sample lock notification:
|
|
133
133
|
"transactionid": null,
|
134
134
|
# bool indicating if the lock is already granted
|
135
135
|
"granted": true,
|
136
|
-
#
|
136
|
+
# mode of the acquired lock
|
137
137
|
"mode": "RowExclusiveLock",
|
138
138
|
# SQL query which acquired the lock
|
139
139
|
"query_snippet": "UPDATE \"users\" SET \"updated_at\" = $1 WHERE \"users\".\"id\" = $2 from/sidekiq_job:UserUpdater/",
|
140
140
|
# age of the lock
|
141
141
|
"age": "PT0.94945S",
|
142
142
|
# app that acquired the lock
|
143
|
-
"application": "bin/sidekiq"
|
143
|
+
"application": "bin/sidekiq",
|
144
|
+
# ID of the database where lock was acquired
|
145
|
+
"database": "84759327",
|
146
|
+
# type of the acquired lock
|
147
|
+
"locktype": "relation",
|
144
148
|
},
|
145
149
|
```
|
146
150
|
|
@@ -204,7 +208,7 @@ PgLocksMonitor.configure do |config|
|
|
204
208
|
# ...
|
205
209
|
|
206
210
|
config.blocking_filter_proc = -> (lock) {
|
207
|
-
lock.fetch("blocked_sql_app").downcase.include?("sidekiq")
|
211
|
+
!lock.fetch("blocked_sql_app").downcase.include?("sidekiq")
|
208
212
|
}
|
209
213
|
end
|
210
214
|
```
|
data/lib/pg-locks-monitor.rb
CHANGED
@@ -5,7 +5,7 @@ require "pg"
|
|
5
5
|
|
6
6
|
module PgLocksMonitor
|
7
7
|
def self.snapshot!
|
8
|
-
locks =
|
8
|
+
locks = RubyPgExtras.locks(
|
9
9
|
in_format: :hash,
|
10
10
|
).select do |lock|
|
11
11
|
if (age = lock.fetch("age"))
|
@@ -18,7 +18,7 @@ module PgLocksMonitor
|
|
18
18
|
configuration.notifier_class.call(locks)
|
19
19
|
end
|
20
20
|
|
21
|
-
blocking =
|
21
|
+
blocking = RubyPgExtras.blocking(in_format: :hash).select do |block|
|
22
22
|
(ActiveSupport::Duration.parse(block.fetch("blocking_duration")).to_f * 1000) > configuration.blocking_min_duration_ms
|
23
23
|
end.select(&configuration.blocking_filter_proc)
|
24
24
|
.first(configuration.locks_limit)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg-locks-monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-pg-extras
|