You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Edward Tan <ta...@gmail.com> on 2005/12/25 18:21:34 UTC

Connection Pool is exhausted in James 2.2.0

Hi,

I have problem that James suddenly gives error about connection is exhausted:


org.apache.commons.dbcp.SQLNestedException: Cannot get a connection,
pool exhausted
org.apache.commons.dbcp.SQLNestedException: Cannot get a connection,
pool exhausted
	at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:103)
	at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
	at org.apache.james.util.dbcp.JdbcDataSource.getConnection(JdbcDataSource.java:218)
	at com.borneosoft.kernel.mail.mailets.WebMailet.service(WebMailet.java:430)
	at org.apache.james.transport.LinearProcessor.service(LinearProcessor.java:407)
	at org.apache.james.transport.JamesSpoolManager.process(JamesSpoolManager.java:451)
	at org.apache.james.transport.JamesSpoolManager.run(JamesSpoolManager.java:360)
	at java.lang.Thread.run(Thread.java:595)
Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
	at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:756)
	at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)
	... 7 more
org.apache.commons.dbcp.SQLNestedException: Cannot get a connection,
pool exhausted
org.apache.commons.dbcp.SQLNestedException: Cannot get a connection,
pool exhausted
	at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:103)
	at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
	at org.apache.james.util.dbcp.JdbcDataSource.getConnection(JdbcDataSource.java:218)
	at com.borneosoft.kernel.mail.mailets.WebMailet.service(WebMailet.java:430)
	at org.apache.james.transport.LinearProcessor.service(LinearProcessor.java:407)
	at org.apache.james.transport.JamesSpoolManager.process(JamesSpoolManager.java:451)
	at org.apache.james.transport.JamesSpoolManager.run(JamesSpoolManager.java:360)
	at java.lang.Thread.run(Thread.java:595)
Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
	at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:756)
	at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)
	... 7 more


Can anyone help me?

Thanks
Suwan

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Connection Pool is exhausted in James 2.2.0

Posted by Edward Tan <ta...@gmail.com>.
Hi,

Sure interested, is it going to be included in Commons DBCP?

The link was about the config. Any developer's guide for the new feature
(tracking abandoned connection)?

Thanks.

Regards,
Edward

On 12/28/05, Laurent Rouvet <la...@rouvet.com> wrote:
>
> Edward Tan wrote:
>
> >Hi,
> >
> >I have problem that James suddenly gives error about connection is
> exhausted:
> >
> >
> >org.apache.commons.dbcp.SQLNestedException: Cannot get a connection,
> >pool exhausted
> >
> >
>
> You might also have that error if there is a "connection" leak.
>
> However, DBCP provide a lot of options that help to avoid that kind of
> error.
> It can track connection abandon.
> Also you can add some test before serve a connection from the pool.
> See
> http://jakarta.apache.org/commons/dbcp/configuration.html
>
> I modifed JdbcDataSource, I can send it ... if someone like...
> I also plan to send a patch to the dev-list...
>
> Laurent
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
>

Re: Connection Pool is exhausted in James 2.2.0

Posted by Stefano Bagnara <ap...@bago.org>.
Laurent Rouvet wrote:
> I modifed JdbcDataSource, I can send it ... if someone like...
> I also plan to send a patch to the dev-list...
> 
> Laurent

Can you file a new JIRA issue and attach your patch?

Stefano

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Connection Pool is exhausted in James 2.2.0

Posted by Laurent Rouvet <la...@rouvet.com>.
Edward Tan wrote:

>Hi,
>
>I have problem that James suddenly gives error about connection is exhausted:
>
>
>org.apache.commons.dbcp.SQLNestedException: Cannot get a connection,
>pool exhausted
>  
>

You might also have that error if there is a "connection" leak.

However, DBCP provide a lot of options that help to avoid that kind of 
error.
It can track connection abandon.
Also you can add some test before serve a connection from the pool.
See
http://jakarta.apache.org/commons/dbcp/configuration.html

I modifed JdbcDataSource, I can send it ... if someone like...
I also plan to send a patch to the dev-list...

Laurent

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Connection Pool is exhausted in James 2.2.0

Posted by Stefano Bagnara <ap...@bago.org>.
> But I cannot find:
> smtp connection and pop3 connection thread in config.xml. How can I
> control the number of the connection thread of smtp and pop3?


   <!-- The Connection Manager block -->
   <!-- -->
   <!-- The idle-timeout is the number of milliseconds that it will take
for idle -->
   <!-- client connections managed by this connection manager to be
marked at timed out. -->
   <!-- If no value is specified, the value defaults to 5 minutes,
300000 milliseconds -->
   <!-- A value of 0 means that client sockets will not timeout. -->
   <!-- -->
   <!-- The max-connections parameter specifies the default maximum
number of client -->
   <!-- connections that this connection manager will allow per managed
server socket. -->
   <!-- This value can be overridden by each individual service. -->
   <!-- If no value is specified, the value defaults to 30. -->
   <!-- A value of 0 creates a maximum of 1 connection due to the use of
the HardResourceLimiting -->
   <!-- thread pool by the ServerConnection class. -->
   <!-- Resource limitations imposed by other components (i.e. max # of
threads) may -->
   <!-- serve to limit the number of open connections. -->
   <!-- -->
   <connections>
      <idle-timeout>300000</idle-timeout>
      <max-connections>30</max-connections>
   </connections>

Stefano

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Connection Pool is exhausted in James 2.2.0

Posted by Edward Tan <ta...@gmail.com>.
Hi Thanks.

I have found:

     <spoolmanager>
            <!-- Number of spool threads -->
            <threads> 10 </threads>
.....
            <!-- The number of threads that should be trying to
deliver outgoing messages -->
            <deliveryThreads> 1 </deliveryThreads>
......

But I cannot find:
smtp connection and pop3 connection thread in config.xml. How can I
control the number of the connection thread of smtp and pop3?



        <!-- The SMTP server is enabled by default -->
        <!-- Disabling blocks will stop them from listening, -->
        <!-- but does not free as many resources as removing them would -->
     <smtpserver enabled="true">
            <!-- port 25 is the well-known/IANA registered port for SMTP -->
            <port>25</port>

            <!-- Uncomment this if you want to bind to a specific
inetaddress -->
            <!--
            <bind> </bind>
            -->
            <!-- Uncomment this if you want to use TLS (SSL) on this port -->
            <!--
            <useTLS>true</useTLS>
            -->

            <handler>
     <!-- This is the name used by the server to identify itself in the SMTP -->
     <!-- protocol.  If autodetect is TRUE, the server will discover its -->
     <!-- own host name and use that in the protocol.  If discovery fails, -->
     <!-- the value of 'localhost' is used.  If autodetect is FALSE, James -->
     <!-- will use the specified value. -->
     <helloName autodetect="true">myMailServer</helloName>
     <connectiontimeout>360000</connectiontimeout>

     <!--  Uncomment this if you want to require SMTP authentication. -->
     <!--
     <authRequired>true</authRequired>
     -->

<!-- CHECKME! -->
     <!--  Uncomment this if you want to authorize specific addresses/networks.
                 If you use SMTP AUTH, addresses that match those
specified here will
                 be permitted to relay without SMTP AUTH.  If you do
not use SMTP
                 AUTH, and you specify addreses here, then only
addresses that match
                 those specified will be permitted to relay.

                 Addresses may be specified as a an IP address or
domain name, with an
                 optional netmask, e.g.,

                 127.*, 127.0.0.0/8, 127.0.0.0/255.0.0.0, and
localhost/8 are all the same

                 See also the RemoteAddrNotInNetwork matcher in the
transport processor.
                 You would generally use one OR the other approach.
     -->
     <authorizedAddresses>127.0.0.0/8</authorizedAddresses>

     <!--  Uncomment this if you want to verify sender addresses,
ensuring that -->
     <!--  the sender address matches the user who has authenticated. -->
     <!--  This prevents a user of your mail server from acting as
someone else -->
     <!--
     <verifyIdentity>true</verifyIdentity>
     -->

     <!--  This sets the maximum allowed message size (in kilobytes)
for this -->
     <!--  SMTP service. If unspecified, the value defaults to 0,
which means no limit. -->
     <maxmessagesize>0</maxmessagesize>
            </handler>
     </smtpserver>

		<!-- The POP3 server is enabled by default -->
		<!-- Disabling blocks will stop them from listening, -->
		<!-- but does not free as many resources as removing them would -->
	 <pop3server enabled="true">
			<!-- port 995 is the well-known/IANA registered port for POP3S  ie
over SSL/TLS -->
			<!-- port 110 is the well-known/IANA registered port for Standard POP3 -->
			<port>110</port>

			<!-- Uncomment this if you want to bind to a specific inetaddress -->
			<!--
			<bind> </bind>
			-->
			<!--  Uncomment this if you want to use TLS (SSL) on this port -->
			<!--
			<useTLS>true</useTLS>
			-->

			<handler>
	 <!-- This is the name used by the server to identify itself in the POP3 -->
	 <!-- protocol.  If autodetect is TRUE, the server will discover its -->
	 <!-- own host name and use that in the protocol.  If discovery fails, -->
	 <!-- the value of 'localhost' is used.  If autodetect is FALSE, James -->
	 <!-- will use the specified value. -->
	 <helloName autodetect="true">myMailServer</helloName>
	 <connectiontimeout>120000</connectiontimeout>
			</handler>
	 </pop3server>



On 12/26/05, Stefano Bagnara <ap...@bago.org> wrote:
> > Thanks.
> >
> > How do I ensure that this won't be a problem, even with max_idle? The
> > mailet is an important thing and cannot afford to fail. Of course the
> > simple hack would be to keep checking until connection is created
> > successfully. But on busy server, this hack looks ugly.
> >
> > Thanks again for the suggestion, I will apply it.
>
> If your total number of threads (spool threads + delivery threads + smtp
> connection threads + pop3 connection threads) is smaller than the total
> maximum connection you should be sure this never happens.
>
> Stefano
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Connection Pool is exhausted in James 2.2.0

Posted by Stefano Bagnara <ap...@bago.org>.
> Thanks.
> 
> How do I ensure that this won't be a problem, even with max_idle? The
> mailet is an important thing and cannot afford to fail. Of course the
> simple hack would be to keep checking until connection is created
> successfully. But on busy server, this hack looks ugly.
> 
> Thanks again for the suggestion, I will apply it.

If your total number of threads (spool threads + delivery threads + smtp
connection threads + pop3 connection threads) is smaller than the total
maximum connection you should be sure this never happens.

Stefano

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Connection Pool is exhausted in James 2.2.0

Posted by Edward Tan <ta...@gmail.com>.
Hi,

Thanks.

How do I ensure that this won't be a problem, even with max_idle? The
mailet is an important thing and cannot afford to fail. Of course the
simple hack would be to keep checking until connection is created
successfully. But on busy server, this hack looks ugly.

Thanks again for the suggestion, I will apply it.

Cheers,
Edward Suwan

On 12/26/05, Stefano Bagnara <ap...@bago.org> wrote:
> Edward Tan wrote:
> > Hi,
> >
> > I have problem that James suddenly gives error about connection is exhausted:
> >
> >
> > org.apache.commons.dbcp.SQLNestedException: Cannot get a connection,
> > pool exhausted
> > [...]
> > Can anyone help me?
> >
> > Thanks
> > Suwan
>
> I changed my datasource configuration to this one.
>
> <!-- The database-connections block -->
> <database-connections>
>    <data-source name="maildb"
> class="org.apache.james.util.dbcp.JdbcDataSource">
>       <driver>com.mysql.jdbc.Driver</driver>
>       <dburl>jdbc:mysql://127.0.0.1/james?autoReconnect=true</dburl>
>       <user>username</user>
>       <password>password</password>
>       <max_idle>40</max_idle>
>       <max>40</max>
>    </data-source>
> </database-connections>
>
> I think the importante change is the max and the max_idle. IIRC the dbcp
>  pool integrated in James use more connections without the max_idle.
>
> Stefano
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Connection Pool is exhausted in James 2.2.0

Posted by Stefano Bagnara <ap...@bago.org>.
Edward Tan wrote:
> Hi,
> 
> I have problem that James suddenly gives error about connection is exhausted:
> 
> 
> org.apache.commons.dbcp.SQLNestedException: Cannot get a connection,
> pool exhausted
> [...]
> Can anyone help me?
> 
> Thanks
> Suwan

I changed my datasource configuration to this one.

<!-- The database-connections block -->
<database-connections>
   <data-source name="maildb"
class="org.apache.james.util.dbcp.JdbcDataSource">
      <driver>com.mysql.jdbc.Driver</driver>
      <dburl>jdbc:mysql://127.0.0.1/james?autoReconnect=true</dburl>
      <user>username</user>
      <password>password</password>
      <max_idle>40</max_idle>
      <max>40</max>
   </data-source>
</database-connections>

I think the importante change is the max and the max_idle. IIRC the dbcp
 pool integrated in James use more connections without the max_idle.

Stefano

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org