pghero 2.0.4 → 2.0.5

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: e94afa4fd9aa4ce59b5a97d78b9d15ff48ebd669
4
- data.tar.gz: 1974a3612f8eae97a888af4a25e965571a2e449e
3
+ metadata.gz: 35e051862227173af7785b2c94c18e8adb212c7b
4
+ data.tar.gz: e59c139875040a33db54c06263569792cae6901c
5
5
  SHA512:
6
- metadata.gz: 6fe161c323e6916ea3fa9c19103cfb17b3403e313b6889ed7be15c2cd7a6d8ff86ab22e667a82a05f0cd2ee471f359097f9b6626e5ce94aa586cff5cf32e7042
7
- data.tar.gz: 5f6db96bd7b69f7a889af3f30b24c8f2964b8b22b937426a067c78a49af5b89461a7cc2ee2be55f01f6406a756e65d5819eca478de9d13bee2b97682ac24fafa
6
+ metadata.gz: 01bf19bcaadab5a8cc039cc15bd0934ddb9d77b45c8b0cbabbf05aca2f0445ae1f0191907ee92f7f9a67a1ed7ad22bdeb4ded66285aa6f4662d41a9e77238e19
7
+ data.tar.gz: f8662218394eafdf740aa70f7e32fce9bb32b9f7412e41b50bd8ca063bef778b51b4b3abe360df96289b81327e9b0a7a6949b8b234d847dbe2461074a1fd7711
@@ -1,3 +1,8 @@
1
+ ## 2.0.5
2
+
3
+ - Fixed error with sequences in different schemas
4
+ - Better advice
5
+
1
6
  ## 2.0.4
2
7
 
3
8
  - Fixed `AssetNotPrecompiled` error
@@ -45,6 +45,12 @@ h1 {
45
45
  font-weight: bold;
46
46
  }
47
47
 
48
+ h2 {
49
+ margin-top: 0;
50
+ font-size: 16px;
51
+ font-weight: bold;
52
+ }
53
+
48
54
  h1 small {
49
55
  font-weight: normal;
50
56
  font-size: 14px;
@@ -246,6 +246,7 @@ module PgHero
246
246
  def tune
247
247
  @title = "Tune"
248
248
  @settings = @database.settings
249
+ @autovacuum_settings = @database.autovacuum_settings if params[:autovacuum]
249
250
  end
250
251
 
251
252
  def connections
@@ -137,6 +137,10 @@
137
137
  <%= button_to "Kill All", kill_long_running_queries_path, class: "btn btn-danger", style: "float: right;" %>
138
138
  <h1>Long Running Queries</h1>
139
139
 
140
+ <p>We recommend setting a statement timeout on all non-superusers with:</p>
141
+
142
+ <pre><code>ALTER ROLE &lt;user&gt; SET statement_timeout TO '60s';</code></pre>
143
+
140
144
  <%= render partial: "live_queries_table", locals: {queries: @long_running_queries} %>
141
145
  </div>
142
146
  <% end %>
@@ -173,7 +177,10 @@
173
177
  <div class="content">
174
178
  <h2>Vacuuming Needed</h2>
175
179
  <p>The database <strong>will shutdown</strong> when there are fewer than 1,000,000 transactions left. <%= link_to "Read more", "http://www.postgresql.org/docs/9.1/static/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND", target: "_blank" %>.</p>
176
- <p>For each table, run:</p>
180
+
181
+ <p>Try <%= link_to "tuning autovacuum", "https://blog.2ndquadrant.com/autovacuum-tuning-basics/", target: "_blank" %> - specifically autovacuum_vacuum_cost_limit.</p>
182
+
183
+ <p>If that doesn’t work, for each table, run:</p>
177
184
  <pre><code>VACUUM FREEZE VERBOSE table;</code></pre>
178
185
  <table class="table">
179
186
  <thead>
@@ -20,3 +20,33 @@
20
20
 
21
21
  <p>Check out <%= link_to "PgTune", "http://pgtune.leopard.in.ua", target: "_blank" %> for recommendations. DB version is <%= @database.server_version.split(".").first(2).join(".") %>.</p>
22
22
  </div>
23
+
24
+ <% if @autovacuum_settings %>
25
+ <div class="content">
26
+ <h1>Autovacuum</h1>
27
+
28
+ <table class="table">
29
+ <thead>
30
+ <tr>
31
+ <th>Setting</th>
32
+ <th style="width: 20%;">Value</th>
33
+ </tr>
34
+ </thead>
35
+ <tbody>
36
+ <% @autovacuum_settings.each do |setting, value| %>
37
+ <tr>
38
+ <td><%= setting %></td>
39
+ <td>
40
+ <%= value %>
41
+ <% if setting == :autovacuum_vacuum_cost_limit && value == "-1" %>
42
+ <span class="text-muted"><%= @database.vacuum_settings[:vacuum_cost_limit] %></span>
43
+ <% end %>
44
+ </td>
45
+ </tr>
46
+ <% end %>
47
+ </tbody>
48
+ </table>
49
+
50
+ <p>Check out <%= link_to "Autovacuum Tuning Basics", "https://blog.2ndquadrant.com/autovacuum-tuning-basics/", target: "_blank" %> for recommendations.</p>
51
+ </div>
52
+ <% end %>
@@ -12,6 +12,7 @@ require "pghero/methods/queries"
12
12
  require "pghero/methods/query_stats"
13
13
  require "pghero/methods/replication"
14
14
  require "pghero/methods/sequences"
15
+ require "pghero/methods/settings"
15
16
  require "pghero/methods/space"
16
17
  require "pghero/methods/suggested_indexes"
17
18
  require "pghero/methods/system"
@@ -10,6 +10,7 @@ module PgHero
10
10
  include Methods::QueryStats
11
11
  include Methods::Replication
12
12
  include Methods::Sequences
13
+ include Methods::Settings
13
14
  include Methods::Space
14
15
  include Methods::SuggestedIndexes
15
16
  include Methods::System
@@ -1,24 +1,6 @@
1
1
  module PgHero
2
2
  module Methods
3
3
  module Basic
4
- def settings
5
- names =
6
- if server_version_num >= 90500
7
- %i(
8
- max_connections shared_buffers effective_cache_size work_mem
9
- maintenance_work_mem min_wal_size max_wal_size checkpoint_completion_target
10
- wal_buffers default_statistics_target
11
- )
12
- else
13
- %i(
14
- max_connections shared_buffers effective_cache_size work_mem
15
- maintenance_work_mem checkpoint_segments checkpoint_completion_target
16
- wal_buffers default_statistics_target
17
- )
18
- end
19
- Hash[names.map { |name| [name, select_one("SHOW #{name}")] }]
20
- end
21
-
22
4
  def ssl_used?
23
5
  ssl_used = nil
24
6
  with_transaction(rollback: true) do
@@ -24,7 +24,7 @@ module PgHero
24
24
  c.relkind = 'r'
25
25
  AND (#{quote(max_value)} - GREATEST(AGE(c.relfrozenxid), AGE(t.relfrozenxid))) < #{quote(threshold)}
26
26
  ORDER BY
27
- 2, 1
27
+ 3, 1, 2
28
28
  SQL
29
29
  end
30
30
 
@@ -22,20 +22,35 @@ module PgHero
22
22
 
23
23
  def replication_slots
24
24
  if server_version_num >= 90400
25
- select_all <<-SQL
26
- SELECT
27
- slot_name,
28
- database,
29
- active
30
- FROM pg_replication_slots
31
- SQL
25
+ with_feature_support([]) do
26
+ select_all <<-SQL
27
+ SELECT
28
+ slot_name,
29
+ database,
30
+ active
31
+ FROM pg_replication_slots
32
+ SQL
33
+ end
32
34
  else
33
35
  []
34
36
  end
35
37
  end
36
38
 
37
39
  def replicating?
38
- select_all("SELECT state FROM pg_stat_replication").any?
40
+ with_feature_support(false) do
41
+ select_all("SELECT state FROM pg_stat_replication").any?
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def with_feature_support(default)
48
+ begin
49
+ yield
50
+ rescue ActiveRecord::StatementInvalid => e
51
+ raise unless e.message.start_with?("PG::FeatureNotSupported:")
52
+ default
53
+ end
39
54
  end
40
55
  end
41
56
  end
@@ -29,7 +29,7 @@ module PgHero
29
29
  s.relname ASC
30
30
  SQL
31
31
 
32
- select_all(sequences.map { |s| "SELECT last_value FROM #{s[:sequence]}" }.join(" UNION ALL ")).each_with_index do |row, i|
32
+ select_all(sequences.map { |s| "SELECT last_value FROM #{quote_ident(s[:schema])}.#{quote_ident(s[:sequence])}" }.join(" UNION ALL ")).each_with_index do |row, i|
33
33
  sequences[i][:last_value] = row[:last_value]
34
34
  end
35
35
 
@@ -0,0 +1,37 @@
1
+ module PgHero
2
+ module Methods
3
+ module Settings
4
+ def settings
5
+ names =
6
+ if server_version_num >= 90500
7
+ %i(
8
+ max_connections shared_buffers effective_cache_size work_mem
9
+ maintenance_work_mem min_wal_size max_wal_size checkpoint_completion_target
10
+ wal_buffers default_statistics_target
11
+ )
12
+ else
13
+ %i(
14
+ max_connections shared_buffers effective_cache_size work_mem
15
+ maintenance_work_mem checkpoint_segments checkpoint_completion_target
16
+ wal_buffers default_statistics_target
17
+ )
18
+ end
19
+ fetch_settings(names)
20
+ end
21
+
22
+ def autovacuum_settings
23
+ fetch_settings %i(autovacuum autovacuum_max_workers autovacuum_vacuum_cost_limit autovacuum_vacuum_scale_factor autovacuum_analyze_scale_factor)
24
+ end
25
+
26
+ def vacuum_settings
27
+ fetch_settings %i(vacuum_cost_limit)
28
+ end
29
+
30
+ private
31
+
32
+ def fetch_settings(names)
33
+ Hash[names.map { |name| [name, select_one("SHOW #{name}")] }]
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module PgHero
2
- VERSION = "2.0.4"
2
+ VERSION = "2.0.5"
3
3
  end
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: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-28 00:00:00.000000000 Z
11
+ date: 2017-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -180,6 +180,7 @@ files:
180
180
  - lib/pghero/methods/query_stats.rb
181
181
  - lib/pghero/methods/replication.rb
182
182
  - lib/pghero/methods/sequences.rb
183
+ - lib/pghero/methods/settings.rb
183
184
  - lib/pghero/methods/space.rb
184
185
  - lib/pghero/methods/suggested_indexes.rb
185
186
  - lib/pghero/methods/system.rb
@@ -215,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
216
  version: '0'
216
217
  requirements: []
217
218
  rubyforge_project:
218
- rubygems_version: 2.6.11
219
+ rubygems_version: 2.6.13
219
220
  signing_key:
220
221
  specification_version: 4
221
222
  summary: A performance dashboard for Postgres