postgres-vacuum-monitor 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +7 -6
- data/lib/postgres/vacuum/jobs/monitor_job.rb +7 -6
- data/lib/postgres/vacuum/monitor/query.rb +3 -2
- data/lib/postgres/vacuum/monitor/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e764680ab6a464db250c1c47b04cef57d9662760c388daf96bf73987f542ba2d
|
4
|
+
data.tar.gz: 6fca9d4989d2c9db092ff78a6ec2429053e0600b4ea1c31f1226d986c6cf20ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6477ea77d2c5b0d7e3f926ec794c69df057c7cc94026789e341c1e1318b8739e3d36d2eef26003b124ea7f63b10d74f6237ade609c6c2fa6d6986f399b6879df
|
7
|
+
data.tar.gz: 49b19ea6107c6771d7c3bce1690ba294cc8e0ecb9d378f0cb08afa574b6d99350c72201ced9390db7b2c55a516f4a6ce13b5dfa3638aa6bd2939160b6cc549d3
|
data/CHANGELOG.md
CHANGED
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
|
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
|
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
|
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
|
-
|
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
|
88
|
+
#### Long running transactions
|
88
89
|
```SQL
|
89
|
-
SELECT application_name,
|
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
|
-
|
7
|
-
|
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.
|
11
|
+
connection.execute(Postgres::Vacuum::Monitor::Query.long_running_transactions).each do |row|
|
12
12
|
reporter_class.report_event(
|
13
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
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
|
+
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:
|
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.
|
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.
|