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

Commit e0f9b01

Browse files
committed
Port recent changes from EE
1 parent 1a0f83b commit e0f9b01

File tree

14 files changed

+380
-77
lines changed

14 files changed

+380
-77
lines changed

doc/src/sgml/config.sgml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,125 @@ include_dir 'conf.d'
703703
</listitem>
704704
</varlistentry>
705705

706+
<varlistentry id="guc-max-sessions" xreflabel="max_sessions">
707+
<term><varname>max_sessions</varname> (<type>integer</type>)
708+
<indexterm>
709+
<primary><varname>max_sessions</varname> configuration parameter</primary>
710+
</indexterm>
711+
</term>
712+
<listitem>
713+
<para>
714+
The maximum number of client sessions that can be handled by
715+
one backend when session pooling is switched on.
716+
This parameter does not add any memory or CPU overhead, so
717+
specifying a large <varname>max_sessions</varname> value
718+
does not affect performance.
719+
If the <varname>max_sessions</varname> limit is reached,
720+
the backend stops accepting connections. Until one of the
721+
connections is terminated, attempts to connect to this
722+
backend result in an error.
723+
</para>
724+
<para>
725+
The default value is 1000. This parameter can only be set at server start.
726+
</para>
727+
</listitem>
728+
</varlistentry>
729+
730+
<varlistentry id="guc-session-pool-size" xreflabel="session_pool_size">
731+
<term><varname>session_pool_size</varname> (<type>integer</type>)
732+
<indexterm>
733+
<primary><varname>session_pool_size</varname> configuration parameter</primary>
734+
</indexterm>
735+
</term>
736+
<listitem>
737+
<para>
738+
Enables session pooling and defines the maximum number of
739+
backends that can be used by client sessions for each database/user combination.
740+
Launched backends are never terminated even if there are no active sessions.
741+
</para>
742+
<para>
743+
The default value is zero, so session pooling is disabled.
744+
</para>
745+
</listitem>
746+
</varlistentry>
747+
748+
<varlistentry id="guc-connection-pool-workers" xreflabel="connection_pool_workers">
749+
<term><varname>connection_pool_workers</varname> (<type>integer</type>)
750+
<indexterm>
751+
<primary><varname>connection_pool_workers</varname> configuration parameter</primary>
752+
</indexterm>
753+
</term>
754+
<listitem>
755+
<para>
756+
Number of connection listeners used to read client startup packages.
757+
If session pooling is enabled, <productname>&productname;</productname>
758+
server redirects all client startup packages to a connection listener.
759+
The listener determines the database and user that the client needs
760+
to access and redirects the connection to an appropriate backend,
761+
which is selected from the pool using the round-robin algorithm.
762+
This approach allows to avoid server slowdown if a client tries
763+
to connect via a slow or unreliable network.
764+
</para>
765+
<para>
766+
The default value is 2.
767+
</para>
768+
</listitem>
769+
</varlistentry>
770+
771+
<varlistentry id="guc-dedicated-databases" xreflabel="dedicated_databases">
772+
<term><varname>dedicated_databases</varname> (<type>string</type>)
773+
<indexterm>
774+
<primary><varname>dedicated_databases</varname> configuration parameter</primary>
775+
</indexterm>
776+
</term>
777+
<listitem>
778+
<para>
779+
Specifies the list of databases for which session pooling is disabled.
780+
For such databases, a separate backend is forked for each connection.
781+
By default, session pooling is disabled for <literal>template0</literal>,
782+
<literal>template1</literal>, and <literal>postgres</literal> databases.
783+
</para>
784+
</listitem>
785+
</varlistentry>
786+
787+
<varlistentry id="guc-restart-pooler-on-reload" xreflabel="restart_pooler_on_reload">
788+
<term><varname>restart_pooler_on_reload</varname> (<type>string</type>)
789+
<indexterm>
790+
<primary><varname>restart_pooler_on_reload</varname> configuration parameter</primary>
791+
</indexterm>
792+
</term>
793+
<listitem>
794+
<para>
795+
Restart session pool workers once <function>pg_reload_conf()</function> is called.
796+
The default value is <literal>false</literal>.
797+
</para>
798+
</listitem>
799+
</varlistentry>
800+
801+
<varlistentry id="guc-session-schedule" xreflabel="session_schedule">
802+
<term><varname>session_schedule</varname> (<type>enum</type>)
803+
<indexterm>
804+
<primary><varname>session_schedule</varname> configuration parameter</primary>
805+
</indexterm>
806+
</term>
807+
<listitem>
808+
<para>
809+
Specifies scheduling policy for assigning session to backend in case of
810+
connection pooling. Default policy is <literal>round-robin</literal>.
811+
</para>
812+
<para>
813+
With <literal>round-robin</literal> policy postmaster cyclicly scatter sessions between session pool backends.
814+
</para>
815+
<para>
816+
With <literal>random</literal> policy postmaster randomly choose backend in session pool.
817+
</para>
818+
<para>
819+
With <literal>load-balancing</literal> policy postmaster choose backend with lowest load average.
820+
Load average of backend is estimated by number of ready events at each reschedule iteration.
821+
</para>
822+
</listitem>
823+
</varlistentry>
824+
706825
<varlistentry id="guc-unix-socket-directories" xreflabel="unix_socket_directories">
707826
<term><varname>unix_socket_directories</varname> (<type>string</type>)
708827
<indexterm>

src/backend/libpq/pqcomm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ pq_endmsgread(void)
13211321
bool
13221322
pq_is_reading_msg(void)
13231323
{
1324-
return pqstate->is_reading;
1324+
return pqstate && pqstate->is_reading;
13251325
}
13261326

13271327
/* --------------------------------

src/backend/postmaster/connpool.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,22 @@ StartupPacketReaderMain(Datum arg)
252252

253253
worker->state = CPW_PROCESSED;
254254

255+
/* send size of data */
255256
while ((rc = send(worker->pipes[1], &buf.len, sizeof(buf.len), 0)) < 0 && errno == EINTR);
256-
if (rc != (int)sizeof(buf.len))
257+
258+
if (rc != (int) sizeof(buf.len))
257259
elog(ERROR, "could not send data to postmaster");
260+
261+
/* send the data */
258262
while ((rc = send(worker->pipes[1], buf.data, buf.len, 0)) < 0 && errno == EINTR);
263+
259264
if (rc != buf.len)
260265
elog(ERROR, "could not send data to postmaster");
266+
261267
pfree(buf.data);
262268
buf.data = NULL;
263-
cleanup:
269+
270+
cleanup:
264271
resetWorkerState(worker, port);
265272
MemoryContextReset(mcxt);
266273
}

0 commit comments

Comments
 (0)