postgres-vacuum-monitor 0.4.0 → 0.5.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: 3185d7bfa19acb621c7c7f67c3239fa51f2dc1cc0e654ff71f2c708f6b082923
4
- data.tar.gz: b78ffb48ba844d46d6dce24d2cf0fdb55f83805e17bdc7e5b6ede159666dfa1b
3
+ metadata.gz: e764680ab6a464db250c1c47b04cef57d9662760c388daf96bf73987f542ba2d
4
+ data.tar.gz: 6fca9d4989d2c9db092ff78a6ec2429053e0600b4ea1c31f1226d986c6cf20ef
5
5
  SHA512:
6
- metadata.gz: dd4e24cbb07c4b38f91fd16a0e0f9026ced4d6584d93ee25c6d8ab9a5249948ed0f75301b42568bb0c8d441ba356aa33fad372ed4def3e586255eee5e82fa035
7
- data.tar.gz: 8c154e6ad4867024f2676caa1aa467fceeba3c715c817264fac63c810ad1535aaf006733af304e395c96ea4cf6d7bc4bc2f88b6d81cdc67f45cc50663da36ebc
6
+ metadata.gz: 6477ea77d2c5b0d7e3f926ec794c69df057c7cc94026789e341c1e1318b8739e3d36d2eef26003b124ea7f63b10d74f6237ade609c6c2fa6d6986f399b6879df
7
+ data.tar.gz: 49b19ea6107c6771d7c3bce1690ba294cc8e0ecb9d378f0cb08afa574b6d99350c72201ced9390db7b2c55a516f4a6ce13b5dfa3638aa6bd2939160b6cc549d3
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
1
  # postgres-vacuum-monitor
2
+ ## v.0.5.0
3
+ - Renamed `LongQueries` event to `LongTransactions`.
4
+ - Renamed `LongTransactions.query` to `LongTransactions.most_recent_query` and added a
5
+ transaction `state` attribute.
6
+
2
7
  ## v.0.4.0
3
8
  - Add rails 6 support.
4
9
 
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  Postgres::Vacuum::Monitor provides queries that provide information about the number of dead tuples and long running queries.
9
9
  This information helps to diagnose and monitor two things:
10
10
  1) That the current auto vacuum settings are working and keeping up.
11
- 2) That there are no long running queries affecting the auto vacuuming daemon.
11
+ 2) That there are no long running transactions affecting the auto vacuuming daemon.
12
12
 
13
13
  ## Installation
14
14
 
@@ -44,14 +44,15 @@ class MetricsReporter
44
44
  end
45
45
  ```
46
46
 
47
- For long running queries, the event name is `LongQueries` and the attributes are:
47
+ For long running transactions, the event name is `LongTransactions` and the attributes are:
48
48
  ```ruby
49
49
  {
50
50
  database_name: # The name of the database.
51
- start_time: # When the query started .
51
+ start_time: # When the transaction started .
52
52
  running_time: # How long has it been running in seconds.
53
53
  application_name: # What's the application name that is running the query.
54
- query: # The offending query.
54
+ most_recent_query: # The last query started by the transaction
55
+ state: # The state of the transaction - either "active" or ""
55
56
  }
56
57
  ```
57
58
 
@@ -84,9 +85,9 @@ SELECT percentile(tuples_over_limit, 95) from AutoVacuumLagging facet table wher
84
85
  ```SQL
85
86
  SELECT percentile(dead_tuples) FROM AutoVacuumLagging facet table where appName = 'my-app' SINCE 1 DAY AGO TIMESERIES
86
87
  ```
87
- #### Long running queries
88
+ #### Long running transactions
88
89
  ```SQL
89
- SELECT application_name, query, running_time, start_time FROM LongQueries
90
+ SELECT application_name, state, most_recent_query, running_time, start_time FROM LongTransactions
90
91
  ```
91
92
 
92
93
  #### Tables that need to be vacuumed
@@ -3,25 +3,26 @@ module Postgres
3
3
  module Jobs
4
4
  class MonitorJob
5
5
 
6
- AUTOVACUUM_QUERY_EVENT = 'AutoVacuumLagging'.freeze
7
- LONG_QUERIES = 'LongQueries'.freeze
6
+ AUTOVACUUM_LAGGING_EVENT = 'AutoVacuumLagging'.freeze
7
+ LONG_TRANSACTIONS = 'LongTransactions'.freeze
8
8
 
9
9
  def perform(*)
10
10
  with_each_db_name_and_connection do |name, connection|
11
- connection.execute(Postgres::Vacuum::Monitor::Query.long_running_queries).each do |row|
11
+ connection.execute(Postgres::Vacuum::Monitor::Query.long_running_transactions).each do |row|
12
12
  reporter_class.report_event(
13
- LONG_QUERIES,
13
+ LONG_TRANSACTIONS,
14
14
  database_name: name,
15
15
  start_time: row['xact_start'],
16
16
  running_time: row['seconds'],
17
17
  application_name: row['application_name'],
18
- query: row['query']
18
+ most_recent_query: row['query'],
19
+ state: row['state']
19
20
  )
20
21
  end
21
22
 
22
23
  connection.execute(Postgres::Vacuum::Monitor::Query.tables_eligible_vacuuming).each do |row|
23
24
  reporter_class.report_event(
24
- AUTOVACUUM_QUERY_EVENT,
25
+ AUTOVACUUM_LAGGING_EVENT,
25
26
  database_name: name,
26
27
  table: row['relation'],
27
28
  table_size: row['table_size'],
@@ -11,7 +11,7 @@ module Postgres
11
11
  MAX_AGE_SETTING = "'autovacuum_freeze_max_age'".freeze
12
12
  PG_CATALOG = "'pg_catalog'".freeze
13
13
 
14
- def long_running_queries
14
+ def long_running_transactions
15
15
  <<-SQL
16
16
  SELECT *
17
17
  FROM (
@@ -20,7 +20,8 @@ module Postgres
20
20
  xact_start,
21
21
  EXTRACT(EPOCH FROM (now() - xact_start)) AS seconds,
22
22
  application_name,
23
- query
23
+ query,
24
+ state
24
25
  FROM pg_stat_activity
25
26
  WHERE state IN (#{STATES.join(', ')})
26
27
  ORDER BY seconds DESC
@@ -1,7 +1,7 @@
1
1
  module Postgres
2
2
  module Vacuum
3
3
  module Monitor
4
- VERSION = '0.4.0'.freeze
4
+ VERSION = '0.5.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.4.0
4
+ version: 0.5.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: 2019-09-24 00:00:00.000000000 Z
11
+ date: 2020-02-06 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.4
198
+ rubygems_version: 3.0.6
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: Simple stats collector for postgres auto vacuumer.