Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit217919d

Browse files
author
Amit Kapila
committed
Raise a WARNING for max_slot_wal_keep_size in pg_createsubscriber.
During the pg_createsubscriber execution, it is possible that the requiredWAL is removed from the primary/publisher node due to'max_slot_wal_keep_size'.This patch raises a WARNING during the '--dry-run' mode if the'max_slot_wal_keep_size' is set to a non-default value on theprimary/publisher node.Author: Shubham Khanna <khannashubham1197@gmail.com>Reviewed-by: Peter Smith <smithpb2250@gmail.com>Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>Reviewed-by: Vignesh C <vignesh21@gmail.com>Discussion:https://postgr.es/m/CAHv8Rj+deqsQXOMa7Tck8CBQUbsua=+4AuMVQ2=MPM0f-ZHbjA@mail.gmail.com
1 parent53d3daa commit217919d

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
intmax_walsenders;
850850
intcur_walsenders;
851851
intmax_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("required WAL could be removed from the publisher");
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)

[8]ページ先頭

©2009-2025 Movatter.jp