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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5e3828da6d61a171d6af1ecc9034de182579a5e
4
- data.tar.gz: d08ceb5493d0a7c29e4fd3b22db85639c149a060
3
+ metadata.gz: bb4fc6839e13e1fcb1d5e1ca1dee05c34b215dc2
4
+ data.tar.gz: c362762b0b918bbb786adc12c185b20f4bbf9562
5
5
  SHA512:
6
- metadata.gz: 1f7c0ab03ccd8b006c008aab8b03e450ceff78dc3f93c01f95344d728702fcd66ddab051be832379fbac69b7d34243b3313d31309817b59fcc0d4efaff9058eb
7
- data.tar.gz: 77e2a5770ca6f840377ee14599cde25f34fe6cf32e4645494dfabfab7ed7fb2509e7666a828df74367b26c5a1c2851f1a5eebe60350834bef309baa2e6ed490e
6
+ metadata.gz: 4604d456402f86697ba18e0ffa261ce4747cb3eb9e9284c8b35ef8e1e9ce6856745a6b6f43fbbd3b510ea6c138fbc31ca475a9b0e2ac3ab5f92d60796244c84e
7
+ data.tar.gz: 422a78d125a1ad063e50823cead73194acf7aeb82ebab57b01d3680ef1eb7f5d6c2d9263909b7bd58c512d937a42f30cb32bb99e9dfcfcf419a9283ae5ab3ca3
@@ -1,3 +1,8 @@
1
+ ## 1.1.4
2
+
3
+ - Added check for transaction ID wraparound failure
4
+ - Added check for autovacuum danger
5
+
1
6
  ## 1.1.3
2
7
 
3
8
  - Fixed system stats
@@ -27,6 +27,8 @@ module PgHero
27
27
  @replication_lag = PgHero.replication_lag
28
28
  @good_replication_lag = @replication_lag < 5
29
29
  end
30
+ @transaction_id_danger = PgHero.transaction_id_danger
31
+ @autovacuum_danger = PgHero.autovacuum_danger
30
32
  end
31
33
 
32
34
  def index_usage
@@ -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>
@@ -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
@@ -1,3 +1,3 @@
1
1
  module PgHero
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
@@ -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"
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in searchkick.gemspec
4
- gemspec path: "../"
4
+ gemspec path: "../../"
5
5
 
6
6
  gem "activerecord", "~> 3.1.0"
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in searchkick.gemspec
4
- gemspec path: "../"
4
+ gemspec path: "../../"
5
5
 
6
6
  gem "activerecord", "~> 3.2.0"
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in searchkick.gemspec
4
- gemspec path: "../"
4
+ gemspec path: "../../"
5
5
 
6
6
  gem "activerecord", "~> 4.0.0"
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.3
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-10-22 00:00:00.000000000 Z
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: