@@ -849,6 +849,7 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
849
849
int max_walsenders ;
850
850
int cur_walsenders ;
851
851
int max_prepared_transactions ;
852
+ char * max_slot_wal_keep_size ;
852
853
853
854
pg_log_info ("checking settings on publisher" );
854
855
@@ -872,6 +873,7 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
872
873
* - wal_level = logical
873
874
* - max_replication_slots >= current + number of dbs to be converted
874
875
* - max_wal_senders >= current + number of dbs to be converted
876
+ * - max_slot_wal_keep_size = -1 (to prevent deletion of required WAL files)
875
877
* -----------------------------------------------------------------------
876
878
*/
877
879
res = PQexec (conn ,
@@ -880,7 +882,8 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
880
882
" (SELECT count(*) FROM pg_catalog.pg_replication_slots),"
881
883
" pg_catalog.current_setting('max_wal_senders'),"
882
884
" (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')" );
884
887
885
888
if (PQresultStatus (res ) != PGRES_TUPLES_OK )
886
889
{
@@ -895,6 +898,7 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
895
898
max_walsenders = atoi (PQgetvalue (res , 0 , 3 ));
896
899
cur_walsenders = atoi (PQgetvalue (res , 0 , 4 ));
897
900
max_prepared_transactions = atoi (PQgetvalue (res , 0 , 5 ));
901
+ max_slot_wal_keep_size = pg_strdup (PQgetvalue (res , 0 , 6 ));
898
902
899
903
PQclear (res );
900
904
@@ -905,6 +909,8 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
905
909
pg_log_debug ("publisher: current wal senders: %d" , cur_walsenders );
906
910
pg_log_debug ("publisher: max_prepared_transactions: %d" ,
907
911
max_prepared_transactions );
912
+ pg_log_debug ("publisher: max_slot_wal_keep_size: %s" ,
913
+ max_slot_wal_keep_size );
908
914
909
915
disconnect_database (conn , false);
910
916
@@ -939,6 +945,18 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
939
945
"Prepared transactions will be replicated at COMMIT PREPARED." );
940
946
}
941
947
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
+
942
960
pg_free (wal_level );
943
961
944
962
if (failed )
0 commit comments