postgres-vacuum-monitor 0.3.1 → 0.3.2
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 +3 -0
- data/README.md +2 -0
- data/lib/postgres/vacuum/jobs/monitor_job.rb +33 -18
- 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: d73b82c8aa8fbc2cf16b5685a23b67069b5ff8b41ff37d8b7db91aa69fac3b28
|
4
|
+
data.tar.gz: 2ea1469236728dc0c60637739c59b2de265c86bc7116e33185cba0972d1fe06f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8d61553c2c18274abbae680870b814a9f87093ae06e8fd55cd9201b86264abd44bd82f05ddb320ce64b2edae7d30a14a879b56bd4f856825bbb6ac9a497398a
|
7
|
+
data.tar.gz: 77d63951bded8bf220ae133a518ebf1d862e84a83253eaa37462f6998b599896de255514391ef0e67ae4baf5c04f7b9af6104d658383a054b11e54bd5bce3301
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -47,6 +47,7 @@ end
|
|
47
47
|
For long running queries, the event name is `LongQueries` and the attributes are:
|
48
48
|
```ruby
|
49
49
|
{
|
50
|
+
database_name: # The name of the database.
|
50
51
|
start_time: # When the query started .
|
51
52
|
running_time: # How long has it been running in seconds.
|
52
53
|
application_name: # What's the application name that is running the query.
|
@@ -58,6 +59,7 @@ For auto vacuum the attributes are the following:
|
|
58
59
|
|
59
60
|
```ruby
|
60
61
|
{
|
62
|
+
database_name: # The name of the database.
|
61
63
|
table: # Table name.
|
62
64
|
table_size: # How big is the table.
|
63
65
|
dead_tuples: # How many dead tuples are in the table.
|
@@ -7,24 +7,28 @@ module Postgres
|
|
7
7
|
LONG_QUERIES = 'LongQueries'.freeze
|
8
8
|
|
9
9
|
def perform(*)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
10
|
+
with_each_db_name_and_connection do |name, connection|
|
11
|
+
connection.execute(Postgres::Vacuum::Monitor::Query.long_running_queries).each do |row|
|
12
|
+
reporter_class.report_event(
|
13
|
+
LONG_QUERIES,
|
14
|
+
database_name: name,
|
15
|
+
start_time: row['xact_start'],
|
16
|
+
running_time: row['seconds'],
|
17
|
+
application_name: row['application_name'],
|
18
|
+
query: row['query']
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
connection.execute(Postgres::Vacuum::Monitor::Query.tables_eligible_vacuuming).each do |row|
|
23
|
+
reporter_class.report_event(
|
24
|
+
AUTOVACUUM_QUERY_EVENT,
|
25
|
+
database_name: name,
|
26
|
+
table: row['relation'],
|
27
|
+
table_size: row['table_size'],
|
28
|
+
dead_tuples: row['dead_tuples'].to_i,
|
29
|
+
tuples_over_limit: row['dead_tuples'].to_i - row['autovacuum_vacuum_tuples'].to_i
|
30
|
+
)
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
true
|
@@ -39,6 +43,17 @@ module Postgres
|
|
39
43
|
@reporter_class_name
|
40
44
|
end
|
41
45
|
|
46
|
+
def with_each_db_name_and_connection
|
47
|
+
databases = Set.new
|
48
|
+
ActiveRecord::Base.connection_handler.connection_pools.map do |connection_pool|
|
49
|
+
db_name = connection_pool.spec.config[:database]
|
50
|
+
# activerecord allocates a connection pool per call to establish_connection
|
51
|
+
# multiple pools might interact with the same database so we use the
|
52
|
+
# database name to dedup
|
53
|
+
connection_pool.with_connection { |conn| yield(db_name, conn) } if databases.add?(db_name)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
42
57
|
ConfigurationError = Class.new(StandardError)
|
43
58
|
end
|
44
59
|
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.3.
|
4
|
+
version: 0.3.2
|
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-
|
11
|
+
date: 2019-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
|
-
rubygems_version: 3.0.
|
196
|
+
rubygems_version: 3.0.4
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: Simple stats collector for postgres auto vacuumer.
|