From bdb370bad97ab5dc5f2c235ba1c9f4af5d827297 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Tue, 16 Sep 2025 21:56:27 -0500 Subject: [PATCH v1 1/1] max_active_replication_origins fix --- doc/src/sgml/config.sgml | 5 +++++ doc/src/sgml/high-availability.sgml | 5 +++++ src/backend/access/rmgrdesc/xlogdesc.c | 2 ++ src/backend/access/transam/xlog.c | 8 ++++++++ src/bin/pg_controldata/pg_controldata.c | 2 ++ src/bin/pg_resetwal/pg_resetwal.c | 2 ++ src/include/access/xlog_internal.h | 3 ++- src/include/catalog/pg_control.h | 3 ++- 8 files changed, 28 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index e9b420f3ddb..c85858e9c8a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -5322,6 +5322,11 @@ ANY num_sync ( max_wal_senders = max_wal_senders; ControlFile->max_prepared_xacts = max_prepared_xacts; ControlFile->max_locks_per_xact = max_locks_per_xact; + ControlFile->max_active_replication_origins = max_active_replication_origins; ControlFile->wal_level = wal_level; ControlFile->wal_log_hints = wal_log_hints; ControlFile->track_commit_timestamp = track_commit_timestamp; @@ -5439,6 +5440,9 @@ CheckRequiredParameterValues(void) RecoveryRequiresIntParameter("max_locks_per_transaction", max_locks_per_xact, ControlFile->max_locks_per_xact); + RecoveryRequiresIntParameter("max_active_replication_origins", + max_active_replication_origins, + ControlFile->max_active_replication_origins); } } @@ -8141,6 +8145,7 @@ XLogReportParameters(void) max_wal_senders != ControlFile->max_wal_senders || max_prepared_xacts != ControlFile->max_prepared_xacts || max_locks_per_xact != ControlFile->max_locks_per_xact || + max_active_replication_origins != ControlFile->max_active_replication_origins || track_commit_timestamp != ControlFile->track_commit_timestamp) { /* @@ -8160,6 +8165,7 @@ XLogReportParameters(void) xlrec.max_wal_senders = max_wal_senders; xlrec.max_prepared_xacts = max_prepared_xacts; xlrec.max_locks_per_xact = max_locks_per_xact; + xlrec.max_active_replication_origins = max_active_replication_origins; xlrec.wal_level = wal_level; xlrec.wal_log_hints = wal_log_hints; xlrec.track_commit_timestamp = track_commit_timestamp; @@ -8178,6 +8184,7 @@ XLogReportParameters(void) ControlFile->max_wal_senders = max_wal_senders; ControlFile->max_prepared_xacts = max_prepared_xacts; ControlFile->max_locks_per_xact = max_locks_per_xact; + ControlFile->max_active_replication_origins = max_active_replication_origins; ControlFile->wal_level = wal_level; ControlFile->wal_log_hints = wal_log_hints; ControlFile->track_commit_timestamp = track_commit_timestamp; @@ -8560,6 +8567,7 @@ xlog_redo(XLogReaderState *record) ControlFile->max_wal_senders = xlrec.max_wal_senders; ControlFile->max_prepared_xacts = xlrec.max_prepared_xacts; ControlFile->max_locks_per_xact = xlrec.max_locks_per_xact; + ControlFile->max_active_replication_origins = xlrec.max_active_replication_origins; ControlFile->wal_level = xlrec.wal_level; ControlFile->wal_log_hints = xlrec.wal_log_hints; diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index 10de058ce91..287e7e5492c 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -308,6 +308,8 @@ main(int argc, char *argv[]) ControlFile->max_prepared_xacts); printf(_("max_locks_per_xact setting: %d\n"), ControlFile->max_locks_per_xact); + printf(_("max_active_replication_origins setting:%d\n"), + ControlFile->max_active_replication_origins); printf(_("track_commit_timestamp setting: %s\n"), ControlFile->track_commit_timestamp ? _("on") : _("off")); printf(_("Maximum data alignment: %u\n"), diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index 7a4e4eb9570..6afa37c8af3 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -708,6 +708,7 @@ GuessControlValues(void) ControlFile.max_worker_processes = 8; ControlFile.max_prepared_xacts = 0; ControlFile.max_locks_per_xact = 64; + ControlFile.max_active_replication_origins = 10; ControlFile.maxAlign = MAXIMUM_ALIGNOF; ControlFile.floatFormat = FLOATFORMAT_VALUE; @@ -913,6 +914,7 @@ RewriteControlFile(void) ControlFile.max_worker_processes = 8; ControlFile.max_prepared_xacts = 0; ControlFile.max_locks_per_xact = 64; + ControlFile.max_active_replication_origins = 10; /* The control file gets flushed here. */ update_controlfile(".", &ControlFile, true); diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index cc06fc29ab2..0a48b78724d 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -31,7 +31,7 @@ /* * Each page of XLOG file has a header like this: */ -#define XLOG_PAGE_MAGIC 0xD118 /* can be used as WAL version indicator */ +#define XLOG_PAGE_MAGIC 0xD119 /* can be used as WAL version indicator */ typedef struct XLogPageHeaderData { @@ -277,6 +277,7 @@ typedef struct xl_parameter_change int max_wal_senders; int max_prepared_xacts; int max_locks_per_xact; + int max_active_replication_origins; int wal_level; bool wal_log_hints; bool track_commit_timestamp; diff --git a/src/include/catalog/pg_control.h b/src/include/catalog/pg_control.h index 63e834a6ce4..55952f52e6a 100644 --- a/src/include/catalog/pg_control.h +++ b/src/include/catalog/pg_control.h @@ -22,7 +22,7 @@ /* Version identifier for this pg_control format */ -#define PG_CONTROL_VERSION 1800 +#define PG_CONTROL_VERSION 1801 /* Nonce key length, see below */ #define MOCK_AUTH_NONCE_LEN 32 @@ -182,6 +182,7 @@ typedef struct ControlFileData int max_wal_senders; int max_prepared_xacts; int max_locks_per_xact; + int max_active_replication_origins; bool track_commit_timestamp; /* -- 2.39.5 (Apple Git-154)