pghero 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pghero might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/app/controllers/pg_hero/home_controller.rb +2 -0
- data/app/views/pg_hero/home/index.html.erb +59 -0
- data/lib/pghero.rb +39 -0
- data/lib/pghero/version.rb +1 -1
- data/pghero.gemspec +1 -1
- data/{gemfiles → test/gemfiles}/activerecord31.gemfile +1 -1
- data/{gemfiles → test/gemfiles}/activerecord32.gemfile +1 -1
- data/{gemfiles → test/gemfiles}/activerecord40.gemfile +1 -1
- metadata +14 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb4fc6839e13e1fcb1d5e1ca1dee05c34b215dc2
|
4
|
+
data.tar.gz: c362762b0b918bbb786adc12c185b20f4bbf9562
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4604d456402f86697ba18e0ffa261ce4747cb3eb9e9284c8b35ef8e1e9ce6856745a6b6f43fbbd3b510ea6c138fbc31ca475a9b0e2ac3ab5f92d60796244c84e
|
7
|
+
data.tar.gz: 422a78d125a1ad063e50823cead73194acf7aeb82ebab57b01d3680ef1eb7f5d6c2d9263909b7bd58c512d937a42f30cb32bb99e9dfcfcf419a9283ae5ab3ca3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
<% if @transaction_id_danger.any? %>
|
2
|
+
<div class="alert alert-danger">
|
3
|
+
Database shutdown imminent due to transaction ID wraparound failure
|
4
|
+
</div>
|
5
|
+
<div class="content">
|
6
|
+
<p>For each table, run:</p>
|
7
|
+
<code><pre>VACUUM FREEZE VERBOSE table</pre></code>
|
8
|
+
<p><%= link_to "Read more", "http://www.postgresql.org/docs/9.1/static/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND", target: "_blank" %></p>
|
9
|
+
<table class="table">
|
10
|
+
<thead>
|
11
|
+
<tr>
|
12
|
+
<th>Table</th>
|
13
|
+
<th style="width: 20%;">Transactions Before Shutdown</th>
|
14
|
+
</tr>
|
15
|
+
</thead>
|
16
|
+
<tbody>
|
17
|
+
<% @transaction_id_danger.each do |query| %>
|
18
|
+
<tr>
|
19
|
+
<td><%= query["table"] %></td>
|
20
|
+
<td><%= number_with_delimiter(query["transactions_before_shutdown"]) %></td>
|
21
|
+
</tr>
|
22
|
+
<% end %>
|
23
|
+
</tbody>
|
24
|
+
</table>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
27
|
+
|
1
28
|
<div id="status">
|
2
29
|
<% if @replica %>
|
3
30
|
<div class="alert alert-<%= @good_replication_lag ? "success" : "warning" %>">
|
@@ -31,6 +58,13 @@
|
|
31
58
|
<% end %>
|
32
59
|
<span class="tiny"><%= @total_connections %></span>
|
33
60
|
</div>
|
61
|
+
<div class="alert alert-<%= @autovacuum_danger.empty? ? "success" : "warning" %>">
|
62
|
+
<% if @autovacuum_danger.any? %>
|
63
|
+
<%= pluralize(@autovacuum_danger.size, "table") %> approaching autovacuum freeze max age
|
64
|
+
<% else %>
|
65
|
+
No autovacuum danger
|
66
|
+
<% end %>
|
67
|
+
</div>
|
34
68
|
<div class="alert alert-<%= @query_stats_enabled && @slow_queries.empty? ? "success" : "warning" %>">
|
35
69
|
<% if !@query_stats_enabled %>
|
36
70
|
Query stats must be enabled for slow queries
|
@@ -104,6 +138,31 @@
|
|
104
138
|
</div>
|
105
139
|
<% end %>
|
106
140
|
|
141
|
+
<% if @autovacuum_danger.any? %>
|
142
|
+
<div class="content">
|
143
|
+
<h1>Autovacuum Danger</h1>
|
144
|
+
<p>For each table, run:</p>
|
145
|
+
<code><pre>VACUUM FREEZE VERBOSE table</pre></code>
|
146
|
+
<p><%= link_to "Read more", "http://www.postgresql.org/docs/9.1/static/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND", target: "_blank" %></p>
|
147
|
+
<table class="table">
|
148
|
+
<thead>
|
149
|
+
<tr>
|
150
|
+
<th>Table</th>
|
151
|
+
<th style="width: 20%;">Transactions Before Autovacuum</th>
|
152
|
+
</tr>
|
153
|
+
</thead>
|
154
|
+
<tbody>
|
155
|
+
<% @autovacuum_danger.each do |query| %>
|
156
|
+
<tr>
|
157
|
+
<td><%= query["table"] %></td>
|
158
|
+
<td><%= number_with_delimiter(query["transactions_before_autovacuum"]) %></td>
|
159
|
+
</tr>
|
160
|
+
<% end %>
|
161
|
+
</tbody>
|
162
|
+
</table>
|
163
|
+
</div>
|
164
|
+
<% end %>
|
165
|
+
|
107
166
|
<% if !@query_stats_enabled %>
|
108
167
|
<div class="content">
|
109
168
|
<h1>Query Stats</h1>
|
data/lib/pghero.rb
CHANGED
@@ -308,6 +308,45 @@ module PgHero
|
|
308
308
|
SQL
|
309
309
|
end
|
310
310
|
|
311
|
+
# http://www.postgresql.org/docs/9.1/static/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND
|
312
|
+
# "the system will shut down and refuse to start any new transactions
|
313
|
+
# once there are fewer than 1 million transactions left until wraparound"
|
314
|
+
# warn when 10,000,000 transactions left
|
315
|
+
def transaction_id_danger
|
316
|
+
select_all <<-SQL
|
317
|
+
SELECT
|
318
|
+
c.oid::regclass::text AS table,
|
319
|
+
2146483648 - GREATEST(AGE(c.relfrozenxid), AGE(t.relfrozenxid)) AS transactions_before_shutdown
|
320
|
+
FROM
|
321
|
+
pg_class c
|
322
|
+
LEFT JOIN
|
323
|
+
pg_class t ON c.reltoastrelid = t.oid
|
324
|
+
WHERE
|
325
|
+
c.relkind = 'r'
|
326
|
+
AND (2146483648 - GREATEST(AGE(c.relfrozenxid), AGE(t.relfrozenxid))) < 10000000
|
327
|
+
ORDER BY
|
328
|
+
transactions_before_shutdown
|
329
|
+
SQL
|
330
|
+
end
|
331
|
+
|
332
|
+
def autovacuum_danger
|
333
|
+
select_all <<-SQL
|
334
|
+
SELECT
|
335
|
+
c.oid::regclass as table,
|
336
|
+
(SELECT setting FROM pg_settings WHERE name = 'autovacuum_freeze_max_age')::int -
|
337
|
+
GREATEST(AGE(c.relfrozenxid), AGE(t.relfrozenxid)) AS transactions_before_autovacuum
|
338
|
+
FROM
|
339
|
+
pg_class c
|
340
|
+
LEFT JOIN
|
341
|
+
pg_class t ON c.reltoastrelid = t.oid
|
342
|
+
WHERE
|
343
|
+
c.relkind = 'r'
|
344
|
+
AND (SELECT setting FROM pg_settings WHERE name = 'autovacuum_freeze_max_age')::int - GREATEST(AGE(c.relfrozenxid), AGE(t.relfrozenxid)) < 2000000
|
345
|
+
ORDER BY
|
346
|
+
transactions_before_autovacuum
|
347
|
+
SQL
|
348
|
+
end
|
349
|
+
|
311
350
|
def kill(pid)
|
312
351
|
execute("SELECT pg_terminate_backend(#{pid.to_i})").first["pg_terminate_backend"] == "t"
|
313
352
|
end
|
data/lib/pghero/version.rb
CHANGED
data/pghero.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features|guides)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "activerecord"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pghero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -109,9 +109,6 @@ files:
|
|
109
109
|
- app/views/pg_hero/home/system.html.erb
|
110
110
|
- app/views/pg_hero/home/tune.html.erb
|
111
111
|
- config/routes.rb
|
112
|
-
- gemfiles/activerecord31.gemfile
|
113
|
-
- gemfiles/activerecord32.gemfile
|
114
|
-
- gemfiles/activerecord40.gemfile
|
115
112
|
- guides/Docker.md
|
116
113
|
- guides/Heroku.md
|
117
114
|
- guides/Linux.md
|
@@ -125,6 +122,9 @@ files:
|
|
125
122
|
- lib/pghero/tasks.rb
|
126
123
|
- lib/pghero/version.rb
|
127
124
|
- pghero.gemspec
|
125
|
+
- test/gemfiles/activerecord31.gemfile
|
126
|
+
- test/gemfiles/activerecord32.gemfile
|
127
|
+
- test/gemfiles/activerecord40.gemfile
|
128
128
|
- test/pghero_test.rb
|
129
129
|
- test/test_helper.rb
|
130
130
|
homepage: https://github.com/ankane/pghero
|
@@ -147,11 +147,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
149
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.4.5
|
150
|
+
rubygems_version: 2.4.5.1
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: Database insights made easy
|
154
154
|
test_files:
|
155
|
+
- guides/Docker.md
|
156
|
+
- guides/Heroku.md
|
157
|
+
- guides/Linux.md
|
158
|
+
- guides/Query-Stats.md
|
159
|
+
- guides/Rails.md
|
160
|
+
- test/gemfiles/activerecord31.gemfile
|
161
|
+
- test/gemfiles/activerecord32.gemfile
|
162
|
+
- test/gemfiles/activerecord40.gemfile
|
155
163
|
- test/pghero_test.rb
|
156
164
|
- test/test_helper.rb
|
157
|
-
has_rdoc:
|