Hi, here is an update off my patch based on the discussion with Marko Tiikkaja and Andres Freund.
Marko and I had the idea of introducing reserved connections based on roles as it would create a way to garantuee specific roles to connect when other roles use up all connections for whatever reason. But Andreas said, that it would make connecting take much too long. So to just fix the issue at hand, we decided that adding max_wal_senders to the pool of reserved connections is better. With that, we are sure that streaming replication can connect to the master. So instead of creating a new configuration option I added max_wal_senders to the reserved connections and changed the check for new connections. The test.pl is a small script to test, if the patch does what it should. regards, Stefan Radomski
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 23ebc11..2ba98e2 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -2170,8 +2170,10 @@ include 'filename' processes). The default is zero, meaning replication is disabled. WAL sender processes count towards the total number of connections, so the parameter cannot be set higher than - <xref linkend="guc-max-connections">. This parameter can only - be set at server start. <varname>wal_level</> must be set + <xref linkend="guc-max-connections">. Like + <xref linkend="guc-superuser-reserved-connections"> this option reserves + connections from <xref linkend="guc-max-connections">. This parameter + can only be set at server start. <varname>wal_level</> must be set to <literal>archive</> or <literal>hot_standby</> to allow connections from standby servers. </para> diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 2c7f0f1..3194894 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -436,7 +436,7 @@ InitializeMaxBackends(void) /* the extra unit accounts for the autovacuum launcher */ MaxBackends = MaxConnections + autovacuum_max_workers + 1 + - + max_worker_processes; + + max_worker_processes + max_wal_senders; /* internal error because the values were all checked previously */ if (MaxBackends > MAX_BACKENDS) @@ -705,7 +705,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, * don't allow them to consume the reserved slots, which are intended for * interactive use. */ - if ((!am_superuser || am_walsender) && + if ((!am_superuser && !am_walsender) && ReservedBackends > 0 && !HaveNFreeProcs(ReservedBackends)) ereport(FATAL,
test.pl
Description: Perl program
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers