Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dd77660

Browse files
author
Commitfest Bot
committed
[CF 52/5496] v14 - Log a warning in pg_createsubscriber for max_slot_wal_keep_size
This commit was automatically generated by a robot at cfbot.cputube.org. It is based on patches submitted to the PostgreSQL mailing lists and registered in the PostgreSQL Commitfest application. This branch will be overwritten each time a new patch version is posted to the email thread, and also periodically to check for bitrot caused by changes on the master branch. Commitfest entry: https://commitfest.postgresql.org/52/5496 Patch(es): https://www.postgresql.org/message-id/CAHv8RjKO1jabfcNVK5j_gd0Mrr07GQckPyhgRO59OvFwaYzo2Q@mail.gmail.com Author(s):
2 parents fc069a3 + d973363 commit dd77660

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

doc/src/sgml/ref/pg_createsubscriber.sgml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,13 @@ PostgreSQL documentation
377377
server. If the target server has a standby, replication will break and a
378378
fresh standby should be created.
379379
</para>
380+
381+
<para>
382+
Replication failures can occur if required WAL files are missing. To prevent
383+
this, the source server must set
384+
<xref linkend="guc-max-slot-wal-keep-size"/> to <literal>-1</literal> to
385+
ensure that required WAL files are not prematurely removed.
386+
</para>
380387
</refsect2>
381388

382389
<refsect2>

src/bin/pg_basebackup/pg_createsubscriber.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
849849
int max_walsenders;
850850
int cur_walsenders;
851851
int max_prepared_transactions;
852+
char *max_slot_wal_keep_size;
852853

853854
pg_log_info("checking settings on publisher");
854855

@@ -872,6 +873,7 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
872873
* - wal_level = logical
873874
* - max_replication_slots >= current + number of dbs to be converted
874875
* - max_wal_senders >= current + number of dbs to be converted
876+
* - max_slot_wal_keep_size = -1 (to prevent deletion of required WAL files)
875877
* -----------------------------------------------------------------------
876878
*/
877879
res = PQexec(conn,
@@ -880,7 +882,8 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
880882
" (SELECT count(*) FROM pg_catalog.pg_replication_slots),"
881883
" pg_catalog.current_setting('max_wal_senders'),"
882884
" (SELECT count(*) FROM pg_catalog.pg_stat_activity WHERE backend_type = 'walsender'),"
883-
" pg_catalog.current_setting('max_prepared_transactions')");
885+
" pg_catalog.current_setting('max_prepared_transactions'),"
886+
" pg_catalog.current_setting('max_slot_wal_keep_size')");
884887

885888
if (PQresultStatus(res) != PGRES_TUPLES_OK)
886889
{
@@ -895,6 +898,7 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
895898
max_walsenders = atoi(PQgetvalue(res, 0, 3));
896899
cur_walsenders = atoi(PQgetvalue(res, 0, 4));
897900
max_prepared_transactions = atoi(PQgetvalue(res, 0, 5));
901+
max_slot_wal_keep_size = pg_strdup(PQgetvalue(res, 0, 6));
898902

899903
PQclear(res);
900904

@@ -905,6 +909,8 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
905909
pg_log_debug("publisher: current wal senders: %d", cur_walsenders);
906910
pg_log_debug("publisher: max_prepared_transactions: %d",
907911
max_prepared_transactions);
912+
pg_log_debug("publisher: max_slot_wal_keep_size: %s",
913+
max_slot_wal_keep_size);
908914

909915
disconnect_database(conn, false);
910916

@@ -939,6 +945,18 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
939945
"Prepared transactions will be replicated at COMMIT PREPARED.");
940946
}
941947

948+
/*
949+
* Validate 'max_slot_wal_keep_size'. If this parameter is set to a
950+
* non-default value, it may cause replication failures due to required
951+
* WAL files being prematurely removed.
952+
*/
953+
if (dry_run && (strcmp(max_slot_wal_keep_size, "-1") != 0))
954+
{
955+
pg_log_warning("publisher requires WAL size must not be restricted");
956+
pg_log_warning_hint("Set the configuration parameter \"%s\" to -1 to ensure that required WAL files are not prematurely removed.",
957+
"max_slot_wal_keep_size");
958+
}
959+
942960
pg_free(wal_level);
943961

944962
if (failed)

0 commit comments

Comments
 (0)