You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Todd Chapman <to...@chaka.net> on 2014/10/07 17:11:29 UTC

Re: Debugging Tomcat JDBC pool disconnects.

Chris,

Thank you for the detailed reply and sorry for my delayed response. We
located the problem.

We had setTestOnBorrow(true) but had not set the validation query. When the
validation query is null the validation fails causing the connection to be
re-opened.

-Todd

On Wed, Sep 24, 2014 at 9:36 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Todd,
>
> On 9/23/14 11:41 AM, Todd Chapman wrote:
> > My application uses the Tomcat JDBC pool. While using netstat and
> > tcpdump to diagnose connection problems I noticed that the client
> > side occasionally closes a DB connection and opens a new one. That
> > is unexpected based on my configuration.
> >
> > poolProperties.setInitialSize(10); poolProperties.setMinIdle(10);
> > poolProperties.setMaxActive(100); poolProperties.setMaxIdle(100);
> > poolProperties.setMaxWait(10000);
>
> Okay.
>
> > poolProperties.setTimeBetweenEvictionRunsMillis(30000);
> > poolProperties.setMinEvictableIdleTimeMillis(30000);
> > poolProperties.setTestWhileIdle(false);
>
> These 3 settings together don't make any sense: if you have disabled
> idle-checking, then setting the schedule for idle-checking isn't
> getting you anything.
>
> > poolProperties.setTestOnBorrow(true);
> > poolProperties.setValidationQuery("SELECT 1 AS data");
> > poolProperties.setValidationInterval(3);
>
> The validation interval is specified in milliseconds. Are you sure you
> want a value so low?
>
> > poolProperties.setLogValidationErrors(true);
> > poolProperties.setTestOnReturn(false); poolProperties. maxAge(0);
>
> Note that maxAge=0 is the default.
>
> > I would expect the pool size to never shrink based on this
> > configuration. Well maybe if borrow test fails but no validation
> > errors are being logged.
> >
> > How can I figure out where close() is being called on the physical
> > DB connection? I tried writing a JdbcInterceptor but it's
> > disconnected() method gets called on the PooledConnection, not the
> > physical connection.
> >
> > Does Tomcat JDBC Pool implement javax.sql.ConnectionEventListener
> > interface?
>
> Could this be the typical firewall-timeout where a network component
> is dropping the connection in the middle, rather than one or the other
> end of the connection dropping it?
>
> What about the database itself? Are there any connection timeouts over
> there?
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> Comment: GPGTools - http://gpgtools.org
>
> iQIcBAEBCAAGBQJUIsjfAAoJEBzwKT+lPKRYBsYP/irwy6tz9Xrf4sM9zGCWc/AS
> aLVyRua/ZhPy+wLyi/LRXjCXHdEekANIqdrKV9jXOPyyIvnB4kwKo3nubPtzNgA3
> GeHeJktLjoz0OMrUI1TPUEU8wab2VNqXBmxF+5yOTExDKSUSfUee4xj/0EVgJ2Jw
> +0YvldtF5RCcTtNNSR38+lUreTTkmaMDGCvhfFY6xXwtU3f7jLUhj9RbFMEwjgDs
> W9VOHF9YKoleiPrzXVxHzPvvJB7k1aSoGreDOorauDnXHK6s5/9BhX7HxLUFZ1U7
> /xdJR8Ul8XjaxNV7zfW1BErUCvjD2V27ASNPNHSnMGrJbElBW8tR23LeH+9Au0fI
> w2/G7MsOp4GpU6t/8I0uyLoiEz85USyRJdVn/PuDTrV3X4aKXt3nnT3wUSQelkyq
> zW+MASMflDPoxEjXPkvb9WO6a8ZaFFQQlHauqIkT1GUEpM0ii1cY7IJPJYSAyvg/
> eMYUFTn17Ml1GCQeLvUWbcbbvisfUJC0SZ7l+5zlUD5FsU/B71gmqgIjVLN+qW6C
> CfV7rBUgKBzgb8LfU2GE4e7PxFUj+161pv/Vyaf8UoYvhhzdXCtg76qndRgbwugK
> gW2j5FApz934BiHNJKzVKfHI5nJPOpL44N2fQAG+KyT1Ojc8pr0E+8FB67g1eTYE
> IvLlYB4adCxQcIy9wqxN
> =9crk
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Debugging Tomcat JDBC pool disconnects.

Posted by Todd Chapman <to...@chaka.net>.
Aniket,

That change had not been committed yet.

-Todd

On Tuesday, October 7, 2014, Aniket Bhoi <an...@gmail.com> wrote:

> On Tue, Oct 7, 2014 at 8:41 PM, Todd Chapman <todd@chaka.net
> <javascript:;>> wrote:
>
> > Chris,
> >
> > Thank you for the detailed reply and sorry for my delayed response. We
> > located the problem.
> >
> > We had setTestOnBorrow(true) but had not set the validation query. When
> the
> > validation query is null the validation fails causing the connection to
> be
> > re-opened.
> >
> > But I do see you have set poolProperties.setValidationQuery("SELECT 1 AS
> data"); earlier
> did that not help?.Is there something that you did differently
>
> Regards
> Aniket
>
> > -Todd
> >
> > On Wed, Sep 24, 2014 at 9:36 AM, Christopher Schultz <
> > chris@christopherschultz.net <javascript:;>> wrote:
> >
> > > -----BEGIN PGP SIGNED MESSAGE-----
> > > Hash: SHA256
> > >
> > > Todd,
> > >
> > > On 9/23/14 11:41 AM, Todd Chapman wrote:
> > > > My application uses the Tomcat JDBC pool. While using netstat and
> > > > tcpdump to diagnose connection problems I noticed that the client
> > > > side occasionally closes a DB connection and opens a new one. That
> > > > is unexpected based on my configuration.
> > > >
> > > > poolProperties.setInitialSize(10); poolProperties.setMinIdle(10);
> > > > poolProperties.setMaxActive(100); poolProperties.setMaxIdle(100);
> > > > poolProperties.setMaxWait(10000);
> > >
> > > Okay.
> > >
> > > > poolProperties.setTimeBetweenEvictionRunsMillis(30000);
> > > > poolProperties.setMinEvictableIdleTimeMillis(30000);
> > > > poolProperties.setTestWhileIdle(false);
> > >
> > > These 3 settings together don't make any sense: if you have disabled
> > > idle-checking, then setting the schedule for idle-checking isn't
> > > getting you anything.
> > >
> > > > poolProperties.setTestOnBorrow(true);
> > > > poolProperties.setValidationQuery("SELECT 1 AS data");
> > > > poolProperties.setValidationInterval(3);
> > >
> > > The validation interval is specified in milliseconds. Are you sure you
> > > want a value so low?
> > >
> > > > poolProperties.setLogValidationErrors(true);
> > > > poolProperties.setTestOnReturn(false); poolProperties. maxAge(0);
> > >
> > > Note that maxAge=0 is the default.
> > >
> > > > I would expect the pool size to never shrink based on this
> > > > configuration. Well maybe if borrow test fails but no validation
> > > > errors are being logged.
> > > >
> > > > How can I figure out where close() is being called on the physical
> > > > DB connection? I tried writing a JdbcInterceptor but it's
> > > > disconnected() method gets called on the PooledConnection, not the
> > > > physical connection.
> > > >
> > > > Does Tomcat JDBC Pool implement javax.sql.ConnectionEventListener
> > > > interface?
> > >
> > > Could this be the typical firewall-timeout where a network component
> > > is dropping the connection in the middle, rather than one or the other
> > > end of the connection dropping it?
> > >
> > > What about the database itself? Are there any connection timeouts over
> > > there?
> > >
> > > - -chris
> > > -----BEGIN PGP SIGNATURE-----
> > > Version: GnuPG v1
> > > Comment: GPGTools - http://gpgtools.org
> > >
> > > iQIcBAEBCAAGBQJUIsjfAAoJEBzwKT+lPKRYBsYP/irwy6tz9Xrf4sM9zGCWc/AS
> > > aLVyRua/ZhPy+wLyi/LRXjCXHdEekANIqdrKV9jXOPyyIvnB4kwKo3nubPtzNgA3
> > > GeHeJktLjoz0OMrUI1TPUEU8wab2VNqXBmxF+5yOTExDKSUSfUee4xj/0EVgJ2Jw
> > > +0YvldtF5RCcTtNNSR38+lUreTTkmaMDGCvhfFY6xXwtU3f7jLUhj9RbFMEwjgDs
> > > W9VOHF9YKoleiPrzXVxHzPvvJB7k1aSoGreDOorauDnXHK6s5/9BhX7HxLUFZ1U7
> > > /xdJR8Ul8XjaxNV7zfW1BErUCvjD2V27ASNPNHSnMGrJbElBW8tR23LeH+9Au0fI
> > > w2/G7MsOp4GpU6t/8I0uyLoiEz85USyRJdVn/PuDTrV3X4aKXt3nnT3wUSQelkyq
> > > zW+MASMflDPoxEjXPkvb9WO6a8ZaFFQQlHauqIkT1GUEpM0ii1cY7IJPJYSAyvg/
> > > eMYUFTn17Ml1GCQeLvUWbcbbvisfUJC0SZ7l+5zlUD5FsU/B71gmqgIjVLN+qW6C
> > > CfV7rBUgKBzgb8LfU2GE4e7PxFUj+161pv/Vyaf8UoYvhhzdXCtg76qndRgbwugK
> > > gW2j5FApz934BiHNJKzVKfHI5nJPOpL44N2fQAG+KyT1Ojc8pr0E+8FB67g1eTYE
> > > IvLlYB4adCxQcIy9wqxN
> > > =9crk
> > > -----END PGP SIGNATURE-----
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> <javascript:;>
> > > For additional commands, e-mail: users-help@tomcat.apache.org
> <javascript:;>
> > >
> > >
> >
>

Re: Debugging Tomcat JDBC pool disconnects.

Posted by Aniket Bhoi <an...@gmail.com>.
On Tue, Oct 7, 2014 at 8:41 PM, Todd Chapman <to...@chaka.net> wrote:

> Chris,
>
> Thank you for the detailed reply and sorry for my delayed response. We
> located the problem.
>
> We had setTestOnBorrow(true) but had not set the validation query. When the
> validation query is null the validation fails causing the connection to be
> re-opened.
>
> But I do see you have set poolProperties.setValidationQuery("SELECT 1 AS
data"); earlier
did that not help?.Is there something that you did differently

Regards
Aniket

> -Todd
>
> On Wed, Sep 24, 2014 at 9:36 AM, Christopher Schultz <
> chris@christopherschultz.net> wrote:
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA256
> >
> > Todd,
> >
> > On 9/23/14 11:41 AM, Todd Chapman wrote:
> > > My application uses the Tomcat JDBC pool. While using netstat and
> > > tcpdump to diagnose connection problems I noticed that the client
> > > side occasionally closes a DB connection and opens a new one. That
> > > is unexpected based on my configuration.
> > >
> > > poolProperties.setInitialSize(10); poolProperties.setMinIdle(10);
> > > poolProperties.setMaxActive(100); poolProperties.setMaxIdle(100);
> > > poolProperties.setMaxWait(10000);
> >
> > Okay.
> >
> > > poolProperties.setTimeBetweenEvictionRunsMillis(30000);
> > > poolProperties.setMinEvictableIdleTimeMillis(30000);
> > > poolProperties.setTestWhileIdle(false);
> >
> > These 3 settings together don't make any sense: if you have disabled
> > idle-checking, then setting the schedule for idle-checking isn't
> > getting you anything.
> >
> > > poolProperties.setTestOnBorrow(true);
> > > poolProperties.setValidationQuery("SELECT 1 AS data");
> > > poolProperties.setValidationInterval(3);
> >
> > The validation interval is specified in milliseconds. Are you sure you
> > want a value so low?
> >
> > > poolProperties.setLogValidationErrors(true);
> > > poolProperties.setTestOnReturn(false); poolProperties. maxAge(0);
> >
> > Note that maxAge=0 is the default.
> >
> > > I would expect the pool size to never shrink based on this
> > > configuration. Well maybe if borrow test fails but no validation
> > > errors are being logged.
> > >
> > > How can I figure out where close() is being called on the physical
> > > DB connection? I tried writing a JdbcInterceptor but it's
> > > disconnected() method gets called on the PooledConnection, not the
> > > physical connection.
> > >
> > > Does Tomcat JDBC Pool implement javax.sql.ConnectionEventListener
> > > interface?
> >
> > Could this be the typical firewall-timeout where a network component
> > is dropping the connection in the middle, rather than one or the other
> > end of the connection dropping it?
> >
> > What about the database itself? Are there any connection timeouts over
> > there?
> >
> > - -chris
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1
> > Comment: GPGTools - http://gpgtools.org
> >
> > iQIcBAEBCAAGBQJUIsjfAAoJEBzwKT+lPKRYBsYP/irwy6tz9Xrf4sM9zGCWc/AS
> > aLVyRua/ZhPy+wLyi/LRXjCXHdEekANIqdrKV9jXOPyyIvnB4kwKo3nubPtzNgA3
> > GeHeJktLjoz0OMrUI1TPUEU8wab2VNqXBmxF+5yOTExDKSUSfUee4xj/0EVgJ2Jw
> > +0YvldtF5RCcTtNNSR38+lUreTTkmaMDGCvhfFY6xXwtU3f7jLUhj9RbFMEwjgDs
> > W9VOHF9YKoleiPrzXVxHzPvvJB7k1aSoGreDOorauDnXHK6s5/9BhX7HxLUFZ1U7
> > /xdJR8Ul8XjaxNV7zfW1BErUCvjD2V27ASNPNHSnMGrJbElBW8tR23LeH+9Au0fI
> > w2/G7MsOp4GpU6t/8I0uyLoiEz85USyRJdVn/PuDTrV3X4aKXt3nnT3wUSQelkyq
> > zW+MASMflDPoxEjXPkvb9WO6a8ZaFFQQlHauqIkT1GUEpM0ii1cY7IJPJYSAyvg/
> > eMYUFTn17Ml1GCQeLvUWbcbbvisfUJC0SZ7l+5zlUD5FsU/B71gmqgIjVLN+qW6C
> > CfV7rBUgKBzgb8LfU2GE4e7PxFUj+161pv/Vyaf8UoYvhhzdXCtg76qndRgbwugK
> > gW2j5FApz934BiHNJKzVKfHI5nJPOpL44N2fQAG+KyT1Ojc8pr0E+8FB67g1eTYE
> > IvLlYB4adCxQcIy9wqxN
> > =9crk
> > -----END PGP SIGNATURE-----
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>