postgres-vacuum-monitor 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 592f695cd74785fd4ab69842efe03d5e22a9cebb5ffbaeb5fe04464e0115374b
4
- data.tar.gz: 5e7742f52d74cd2abd69befbbf7e66359b108a811bbaba50fa5b36889793681c
3
+ metadata.gz: 4a0a495f163ac1fa4a6f94f70ec5696f18bb7fa21c1d3c4d14112a851cce02da
4
+ data.tar.gz: 6fb8e82c0a402713cae34316c223c61fc69b3794e65b50c4eaaccb4c21842073
5
5
  SHA512:
6
- metadata.gz: d5a79c0d3bcea4003b28dd74ca89aea9c89e0a55219a66712db91709c35995615fa0d965288210cd09261b1f1be66c8dc710701498c1ca4a9e56f7e08893e478
7
- data.tar.gz: bd177531dd058f581a3a4c325a1a3fc283fd74c05780bab7bff1c3e541a71fff5d848c03d76546432b931f030b243800aaea382bc4a16cdb932c771ac6b8c8fe
6
+ metadata.gz: d0549c01be8daf6157d6d576f46ac2b0181f06118972d9b6d1b5d2e7006fc07a1de042fee185f21587f823d2c4b0fee4ed308b3bd09057a6a970a6a7b7a9ba71
7
+ data.tar.gz: 4da8027e9b3eff11a63866c171310c6393405eca2bc07e3c40f953ca769fc7b30d2192e4a83913adfdadb82d0b05451e16a5dca5f48c752f5a2375ca1124602d
@@ -1,4 +1,8 @@
1
1
  # postgres-vacuum-monitor
2
+
3
+ ## v.0.8.0
4
+ - Also report on queries that are being blocked by another process.
5
+
2
6
  ## v.0.7.0
3
7
  - Lower the default `LongTransactions` threshold from 1 hour to 5 minutes and make this configurable via
4
8
  the `long_running_transaction_threshold_seconds` setting.
@@ -5,6 +5,7 @@ module Postgres
5
5
 
6
6
  AUTOVACUUM_LAGGING_EVENT = 'AutoVacuumLagging'.freeze
7
7
  LONG_TRANSACTIONS = 'LongTransactions'.freeze
8
+ BLOCKED_QUERIES = 'BlockedQueries'.freeze
8
9
 
9
10
  def perform(*)
10
11
  with_each_db_name_and_connection do |name, connection|
@@ -33,6 +34,17 @@ module Postgres
33
34
  tuples_over_limit: row['dead_tuples'].to_i - row['autovacuum_vacuum_tuples'].to_i
34
35
  )
35
36
  end
37
+
38
+ connection.execute(Postgres::Vacuum::Monitor::Query.blocked_queries).each do |row|
39
+ reporter_class.report_event(
40
+ BLOCKED_QUERIES,
41
+ database_name: name,
42
+ blocked_pid: row['blocked_pid'],
43
+ blocked_statement: row['blocked_statement'],
44
+ blocking_pid: row['blocking_pid'],
45
+ current_statement_in_blocking_process: row['current_statement_in_blocking_process']
46
+ )
47
+ end
36
48
  end
37
49
 
38
50
  true
@@ -67,6 +67,36 @@ module Postgres
67
67
  ORDER BY age(relfrozenxid) DESC LIMIT 50;
68
68
  SQL
69
69
  end
70
+
71
+ def blocked_queries
72
+ # The query was taken from https://wiki.postgresql.org/wiki/Lock_Monitoring
73
+ <<-SQL
74
+ SELECT blocked_locks.pid AS blocked_pid,
75
+ blocked_activity.usename AS blocked_user,
76
+ blocking_locks.pid AS blocking_pid,
77
+ blocking_activity.usename AS blocking_user,
78
+ blocked_activity.query AS blocked_statement,
79
+ blocking_activity.query AS current_statement_in_blocking_process,
80
+ blocked_activity.application_name AS blocked_application,
81
+ blocking_activity.application_name AS blocking_application
82
+ FROM pg_catalog.pg_locks blocked_locks
83
+ JOIN pg_catalog.pg_stat_activity blocked_activity ON blocked_activity.pid = blocked_locks.pid
84
+ JOIN pg_catalog.pg_locks blocking_locks
85
+ ON blocking_locks.locktype = blocked_locks.locktype
86
+ AND blocking_locks.DATABASE IS NOT DISTINCT FROM blocked_locks.DATABASE
87
+ AND blocking_locks.relation IS NOT DISTINCT FROM blocked_locks.relation
88
+ AND blocking_locks.page IS NOT DISTINCT FROM blocked_locks.page
89
+ AND blocking_locks.tuple IS NOT DISTINCT FROM blocked_locks.tuple
90
+ AND blocking_locks.virtualxid IS NOT DISTINCT FROM blocked_locks.virtualxid
91
+ AND blocking_locks.transactionid IS NOT DISTINCT FROM blocked_locks.transactionid
92
+ AND blocking_locks.classid IS NOT DISTINCT FROM blocked_locks.classid
93
+ AND blocking_locks.objid IS NOT DISTINCT FROM blocked_locks.objid
94
+ AND blocking_locks.objsubid IS NOT DISTINCT FROM blocked_locks.objsubid
95
+ AND blocking_locks.pid != blocked_locks.pid
96
+ JOIN pg_catalog.pg_stat_activity blocking_activity ON blocking_activity.pid = blocking_locks.pid
97
+ WHERE NOT blocked_locks.GRANTED;
98
+ SQL
99
+ end
70
100
  end
71
101
  end
72
102
  end
@@ -1,7 +1,7 @@
1
1
  module Postgres
2
2
  module Vacuum
3
3
  module Monitor
4
- VERSION = '0.7.0'.freeze
4
+ VERSION = '0.8.0'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postgres-vacuum-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Garces
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-07 00:00:00.000000000 Z
11
+ date: 2020-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0'
197
197
  requirements: []
198
- rubygems_version: 3.0.6
198
+ rubygems_version: 3.0.4
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: Simple stats collector for postgres auto vacuumer.