active_postgres 0.9.2 → 0.9.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e51d5f1214cedf497a9b060e5c667c43711f9ff5e36024bfd8dc926b50fe272f
4
- data.tar.gz: 618fa70d39a43e1c74ba2ed449b75138670bca92cb6bf418606f772de34c6a7d
3
+ metadata.gz: 12db7ee31476f31cae2fa436ade1c6fe3a94367b5013765603442df5fdc90feb
4
+ data.tar.gz: e31aa6b40e45b90b2c985e5347078e4886385e2a26c359c87ce5c951adf04eb9
5
5
  SHA512:
6
- metadata.gz: 254b6fb4342d4e510076d05ebfbeaa0e7990b463df13ad6ddb7d6eb5a70562c23cc4f502ce6c435c6372fc3dd5f695285ee3fdfed522cc188f1b1cc21c6cc90d
7
- data.tar.gz: d9147a4679529344ccb0ffd3d5c2ffacc3072464b9cf4e1c6e11150a66c142ef0d0b45f9b9cd9d34eceba6f4d0e50baa7c2f227a5b2b1719502972e2b4b39ee4
6
+ metadata.gz: 7ea49e121a8f72d4a8b271e5a270a7a25ce8ac5141d301ef623234b6951fb2874495bbf7d00e484df148e5be254cdbe12f1f54e677b81ed608326dd85a1d478e
7
+ data.tar.gz: 468c8eb9c90f8c51dbc666c81f89a3a0bae4477577309f82a49126fedec617bdbc228585bfe00cae7448e3de76f5fb587a1bf56748802c4243107c2720211902
data/README.md CHANGED
@@ -187,12 +187,10 @@ rake postgres:backup:restore_at["2026-01-29 01:15:00",promote]
187
187
  ```
188
188
 
189
189
  If you want the old primary to rejoin without a full re-clone after failover,
190
- enable pg_rewind support in repmgr:
190
+ use `repmgr node rejoin --force-rewind` once the node is ready to reattach:
191
191
 
192
- ```yaml
193
- components:
194
- repmgr:
195
- use_rewind: true
192
+ ```bash
193
+ repmgr node rejoin -f /etc/repmgr.conf --force-rewind
196
194
  ```
197
195
 
198
196
  ### Stable app endpoint with PgBouncer
@@ -141,6 +141,7 @@ module ActivePostgres
141
141
  end
142
142
 
143
143
  def setup_backup_schedules(host, pgbackrest_config)
144
+ remove_backup_schedule(host)
144
145
  schedules = backup_schedules(pgbackrest_config)
145
146
  schedules.each do |entry|
146
147
  setup_backup_schedule(host, entry[:schedule], entry[:type], entry[:file])
@@ -99,6 +99,8 @@ module ActivePostgres
99
99
 
100
100
  create_userlist(host)
101
101
 
102
+ ensure_firewall_port_open(host, pgbouncer_config[:listen_port] || 6432)
103
+
102
104
  ssh_executor.execute_on_host(host) do
103
105
  execute :sudo, 'systemctl', 'enable', 'pgbouncer'
104
106
  execute :sudo, 'systemctl', 'restart', 'pgbouncer'
@@ -194,6 +196,17 @@ module ActivePostgres
194
196
  end
195
197
  end
196
198
 
199
+ def ensure_firewall_port_open(host, port)
200
+ ssh_executor.execute_on_host(host) do
201
+ has_reject = test(:sudo, 'iptables', '-C', 'INPUT', '-j', 'REJECT', '2>/dev/null')
202
+ if has_reject
203
+ execute :sudo, 'iptables', '-I', 'INPUT', '-p', 'tcp', '--dport', port.to_s, '-j', 'ACCEPT'
204
+ execute :sudo, 'sh', '-c', "'iptables-save > /etc/iptables/rules.v4 2>/dev/null || true'"
205
+ puts " ✓ Opened port #{port} in iptables"
206
+ end
207
+ end
208
+ end
209
+
197
210
  def install_follow_primary(host, pgbouncer_config)
198
211
  interval = pgbouncer_config[:follow_primary_interval] || 5
199
212
  interval = interval.to_i
@@ -79,7 +79,7 @@ module ActivePostgres
79
79
  default: &default
80
80
  adapter: postgresql
81
81
  encoding: unicode
82
- pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
82
+ pool: <%= ENV.fetch("DB_POOL") { ENV.fetch("RAILS_MAX_THREADS") { 5 } } %>
83
83
 
84
84
  development:
85
85
  <<: *default
@@ -82,7 +82,7 @@ module ActivePostgres
82
82
  {
83
83
  'adapter' => 'postgresql',
84
84
  'encoding' => 'unicode',
85
- 'pool' => env_value('RAILS_MAX_THREADS', fallback: 5),
85
+ 'pool' => pool_env_value,
86
86
  'username' => env_value('POSTGRES_APP_USER', fallback: app_name),
87
87
  'password' => env_value('POSTGRES_APP_PASSWORD'),
88
88
  'variables' => {
@@ -138,6 +138,10 @@ module ActivePostgres
138
138
  end
139
139
  end
140
140
 
141
+ def pool_env_value
142
+ "<%= ENV.fetch('DB_POOL') { ENV.fetch('RAILS_MAX_THREADS') { 5 } } %>"
143
+ end
144
+
141
145
  def normalize_app_name(custom_name)
142
146
  chosen = custom_name || ENV['BORING_APP_NAME'] || default_app_name
143
147
  chosen.to_s.tr('- ', '_')
@@ -1,3 +1,3 @@
1
1
  module ActivePostgres
2
- VERSION = '0.9.2'.freeze
2
+ VERSION = '0.9.3'.freeze
3
3
  end
@@ -37,9 +37,6 @@ service_restart_command='sudo systemctl restart postgresql@<%= config.version %>
37
37
  service_reload_command='sudo systemctl reload postgresql@<%= config.version %>-main'
38
38
 
39
39
  ssh_options='-i /var/lib/postgresql/.ssh/active_postgres_dns -o StrictHostKeyChecking=no'
40
- <% if repmgr_config.key?(:use_rewind) %>
41
- use_rewind=<%= repmgr_config[:use_rewind] ? 'yes' : 'no' %>
42
- <% end %>
43
40
 
44
41
  log_level=INFO
45
42
  log_facility=STDERR
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - BoringCache