From eb202446f85b4969eefcbaecafe4ee634cc52d7f Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Wed, 3 Apr 2024 17:27:58 +0000 Subject: [PATCH] postgresql: Decouple wal_g from streaming replication. Streaming replication may be used even if `wal-g` is not -- as long as the user can move a copy of the base backup to the replica (e.g. using `pg_basebackup`). Remove the warning about this combination, and move the `primary_conninfo` setting outside of the `s3_backups_bucket` check. --- puppet/zulip/manifests/profile/postgresql.pp | 7 ------- .../templates/postgresql/12/postgresql.conf.template.erb | 5 +++-- .../templates/postgresql/13/postgresql.conf.template.erb | 5 +++-- .../templates/postgresql/14/postgresql.conf.template.erb | 5 +++-- puppet/zulip/templates/postgresql/zulip.conf.template.erb | 5 +++-- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/puppet/zulip/manifests/profile/postgresql.pp b/puppet/zulip/manifests/profile/postgresql.pp index c675f19604..614d7d8996 100644 --- a/puppet/zulip/manifests/profile/postgresql.pp +++ b/puppet/zulip/manifests/profile/postgresql.pp @@ -55,13 +55,6 @@ class zulip::profile::postgresql { } if $replication_primary != undef and $replication_user != undef { - if $s3_backups_bucket == '' { - $message = @(EOT/L) - Replication is enabled, but s3_backups_bucket is not set in zulip-secrets.conf! \ - Streaming replication requires wal-g backups be configured. - |-EOT - warning($message) - } # The presence of a standby.signal file triggers replication file { "${zulip::postgresql_base::postgresql_datadir}/standby.signal": ensure => file, diff --git a/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb index 67c861248d..7c0fea8fd0 100644 --- a/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb +++ b/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb @@ -788,17 +788,18 @@ listen_addresses = <%= @listen_addresses %> <% end -%> <% if @s3_backups_bucket != '' -%> -# Streaming backups and replication +# WAL backups to S3 (may also be used for replication) archive_mode = on archive_command = '/usr/bin/timeout 10m /usr/local/bin/env-wal-g wal-push %p' restore_command = '/usr/local/bin/env-wal-g wal-fetch "%f" "%p"' +<% end -%> <% unless @replication_primary.nil? || @replication_user.nil? -%> +# Streaming replication primary_conninfo = 'host=<%= @replication_primary %> user=<%= @replication_user -%> <% if @replication_password != '' %> password=<%= @replication_password %><% end -%> <% unless @ssl_mode.nil? %> sslmode=<%= @ssl_mode %><% end -%> ' <% end -%> -<% end -%> <% unless @ssl_cert_file.nil? -%> ssl_cert_file = '<%= @ssl_cert_file %>' # (change requires restart) diff --git a/puppet/zulip/templates/postgresql/13/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/13/postgresql.conf.template.erb index 111eabb1eb..45e63c4fea 100644 --- a/puppet/zulip/templates/postgresql/13/postgresql.conf.template.erb +++ b/puppet/zulip/templates/postgresql/13/postgresql.conf.template.erb @@ -819,17 +819,18 @@ listen_addresses = <%= @listen_addresses %> <% end -%> <% if @s3_backups_bucket != '' -%> -# Streaming backups and replication +# WAL backups to S3 (may also be used for replication) archive_mode = on archive_command = '/usr/bin/timeout 10m /usr/local/bin/env-wal-g wal-push %p' restore_command = '/usr/local/bin/env-wal-g wal-fetch "%f" "%p"' +<% end -%> <% unless @replication_primary.nil? || @replication_user.nil? -%> +# Streaming replication primary_conninfo = 'host=<%= @replication_primary %> user=<%= @replication_user -%> <% if @replication_password != '' %> password=<%= @replication_password %><% end -%> <% unless @ssl_mode.nil? %> sslmode=<%= @ssl_mode %><% end -%> ' <% end -%> -<% end -%> <% unless @ssl_cert_file.nil? -%> ssl_cert_file = '<%= @ssl_cert_file %>' # (change requires restart) diff --git a/puppet/zulip/templates/postgresql/14/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/14/postgresql.conf.template.erb index cf3d7ff6c1..3a68100924 100644 --- a/puppet/zulip/templates/postgresql/14/postgresql.conf.template.erb +++ b/puppet/zulip/templates/postgresql/14/postgresql.conf.template.erb @@ -840,17 +840,18 @@ listen_addresses = <%= @listen_addresses %> <% end -%> <% if @s3_backups_bucket != '' -%> -# Streaming backups and replication +# WAL backups to S3 (may also be used for replication) archive_mode = on archive_command = '/usr/bin/timeout 10m /usr/local/bin/env-wal-g wal-push %p' restore_command = '/usr/local/bin/env-wal-g wal-fetch "%f" "%p"' +<% end -%> <% unless @replication_primary.nil? || @replication_user.nil? -%> +# Streaming replication primary_conninfo = 'host=<%= @replication_primary %> user=<%= @replication_user -%> <% if @replication_password != '' %> password=<%= @replication_password %><% end -%> <% unless @ssl_mode.nil? %> sslmode=<%= @ssl_mode %><% end -%> ' <% end -%> -<% end -%> <% unless @ssl_cert_file.nil? -%> ssl_cert_file = '<%= @ssl_cert_file %>' # (change requires restart) diff --git a/puppet/zulip/templates/postgresql/zulip.conf.template.erb b/puppet/zulip/templates/postgresql/zulip.conf.template.erb index 943c12a269..ca5fc7b001 100644 --- a/puppet/zulip/templates/postgresql/zulip.conf.template.erb +++ b/puppet/zulip/templates/postgresql/zulip.conf.template.erb @@ -40,17 +40,18 @@ effective_io_concurrency = <%= @effective_io_concurrency %> <% end -%> <% if @s3_backups_bucket != '' -%> -# Streaming backups and replication +# WAL backups to S3 (may also be used for replication) archive_mode = on archive_command = '/usr/bin/timeout 10m /usr/local/bin/env-wal-g wal-push %p' restore_command = '/usr/local/bin/env-wal-g wal-fetch "%f" "%p"' +<% end -%> <% unless @replication_primary.nil? || @replication_user.nil? -%> +# Streaming replication primary_conninfo = 'host=<%= @replication_primary %> user=<%= @replication_user -%> <% if @replication_password != '' %> password=<%= @replication_password %><% end -%> <% unless @ssl_mode.nil? %> sslmode=<%= @ssl_mode %><% end -%> ' <% end -%> -<% end -%> <% unless @ssl_cert_file.nil? -%> ssl_cert_file = '<%= @ssl_cert_file %>' # (change requires restart)