tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: deadlock in database connection pooling?
Date Fri, 11 Dec 2009 15:53:35 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mitch,

On 12/10/2009 7:43 PM, Mitch Claborn wrote:
>               poolPreparedStatements="true"
>               driverClassName="com.mysql.jdbc.Driver"
>               validationQuery="select * from operator limit 1"

FWIW, this is a non-ideal validation query:

1. It uses SELECT *, which is not particularly efficient.
2. It uses a real table, which means that real data will be selected.
3. It uses a LIMIT, which means that you know that too much data is
   going to come back.

Might I suggest:

validationQuery="/* ping */SELECT 1"

MySQL Connector/J drivers after a certain version recognize the "/* ping
*/" at the beginning of the query and will execute a low-level
connection check that does not involve a query at all! So, you get your
validation that the connection is properly connected without all that
silly work on the server.

If the version of the MySQL driver is NOT new enough, it will execute
the "SELECT 1" query which consults no tables and executed super fast.

You win both ways.

>               testWhileIdle="true"
>               testOnBorrow="false"
>               testOnReturn="false"

That's an odd configuration... why test while idle but not when the
connection is needed?

I suspect that if you set testOnBorrow="true" and testWhileIdle="false",
you will avoid your deadlock problem.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksiav8ACgkQ9CaO5/Lv0PDpMgCfU2gk24uX4Dbis4mj+89Nxo8t
vq0AoKxl0RC1AmU72MNCDbVhK4yf2SCl
=JUuv
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message