<div dir="ltr"><div class="gmail_quote">On Thu, Jun 28, 2012 at 6:38 PM, Tatsuo Ishii <span dir="ltr">&lt;<a href="mailto:ishii@postgresql.org" target="_blank">ishii@postgresql.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div class="h5">
&gt; connections to a database whose name is not in one of &#39;postgres&#39;,<br>
&gt; &#39;template0&#39;, &#39;template1&#39;, or &#39;regression&#39;.<br>
&gt;<br>
&gt; This appears to be because of the following piece of code from child.c:<br>
&gt;<br>
&gt;     /*<br>
&gt;      * do not cache connection if:<br>
&gt;      * pool_config-&gt;connection_cahe == 0 or<br>
&gt;      * database name is template0, template1, postgres or regression<br>
&gt;      */<br>
&gt;     if (pool_config-&gt;connection_cache == 0 ||<br>
&gt;         !strcmp(sp-&gt;database, &quot;template0&quot;) ||<br>
&gt;         !strcmp(sp-&gt;database, &quot;template1&quot;) ||<br>
&gt;         !strcmp(sp-&gt;database, &quot;postgres&quot;) ||<br>
&gt;         !strcmp(sp-&gt;database, &quot;regression&quot;))<br>
&gt;     {<br>
&gt;<br>
&gt; So I see two problems with this.<br>
&gt;<br>
&gt; One, these databases will never see the benefit of connection caching.<br>
&gt; Since most pgpool users would be using the default &#39;postgres&#39; database,<br>
<br>
</div></div>&gt; I have noticed a bug that rears its head only when the client makes<br>I don&#39;t believe this and have never heard about such a user in my<br>
customers who is using &quot;postgres&quot; database to store mission critical<br>
data. Any serious database users will never use &quot;postgres&quot; for their<br>
real database. The postgres database should be soly used for<br>
PostgreSQL internal use (for example autovacuum) or database<br>
administration tool like createdb.<br></blockquote><div><br>I have to disagree! postgres is the default database a user is supposed to connect to and start working with. Serious or not a serious application is besides the point. This is a non-system database, ulike template0|1 databases, and hence should be treated as such. And I&#39;d apply the same argument to remove &#39;regression&#39; database too from that list.<br>

 </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
&gt; this seems to be a bad decision.<br>
&gt; Second, the client connections that used a database not in this list, seem<br>
&gt; not to be able to reuse the cached connections unless the connections held<br>
&gt; by pgpool come close the the max_connection parameter in postgres.<br>
&gt;<br>
&gt; Here&#39;s how to reproduce this:<br>
&gt;<br>
&gt; export PGHOST=localhost PGPORT=9999 PGDATABASE=some_other_db PGUSER=postgres<br>
&gt;<br>
&gt; while sleep 1; do psql &quot;select 1&quot;; done<br>
&gt;<br>
&gt; This causes the number of connections on postgres side to steadily<br>
&gt; increase, even though the client app disconnects before requesting a new<br>
&gt; connection.<br>
&gt;<br>
&gt; If I change the PGPORT to 5432, then the number of connections stays stable<br>
&gt; at 1. And if I change the PGDATABASE to &#39;postgres&#39; (keeping PGPORT=9999),<br>
&gt; then also the number of connections on postgres stay stable.<br>
&gt;<br>
&gt; The first problem of treating some databases might be acceptable to some,<br>
&gt; but the inability to reuse a previously released connection troubles me. To<br>
&gt; be specific, this causes the c3p0 connection pooler (which wants to keep<br>
&gt; just 5 connections) to cause a connection spike on postgres, and hence<br>
&gt; those postgres backends are not usable by any other application.<br>
<br>
</div>Probably you&#39;d better to look into our FAQ.<br>
Especially this:<br>
&quot;Is connection pool cache shared among pgpool process?&quot;<br></blockquote></div><br>Thanks, I didn&#39;t know this was by design.<br><br>For this case I think reducing child_life_time, to say 10 seconds, would help the cached connection be destroyed sooner, so that the total number of connections on the DB side stay low.<br clear="all">

<br>Best regards,<br>-- <br><div dir="ltr">Gurjeet Singh<br>EnterpriseDB Corporation<br>The Enterprise PostgreSQL Company<br></div><br>
</div>