-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

All,

I've been piloting Tomcat 8 in my development environment on and off
for the last few months, and I just started working on some new
functionality that causes a #*(%^storm of JDBC activity: I have a main
page which loads dozens of images, which are actually SVGs built on
the fly by pulling similar data from the database.

This has all been working for several years, and I added some caching
at the very start because most of this data all comes from the same
place, so the first image to be loaded ends up doing the hard work
while the others wait for the cached data to become available, then
everything goes quickly after that with very little CPU usage, etc.

Now, I'm trying to load a different image simultaneously that uses
similar data yet different. This causes the two pieces of code to
fight over the cached data in a way that essentially continuously
invalidates the cache. I'll get that worked out myself because it's a
bad situation in general, but I have observed that when I run this
under Tomcat 7, it takes a long time (on the order of maybe 5 seconds)
to fulfill the request, but it makes steady progress.

When I run under Tomcat 8.0.3, a couple of the images are loaded, and
then the whole ... thing ... just ... stops. If I watch my log4j log
file, every so often a flurry of activity occurs: several pieces of
information are actually fetched from the database, and progress is
made. But I have waited like 10 minutes and the series of requests
never finishes in that time.

(Something odd I can see: when that small amount of progress is made,
the idle connection in MySQL *remains* idle. The only conclusion I can
come to is that a new connection is being created to fetch that data
and then it's being dropped, or that something is giving up somewhere
without telling me. Neither conclusion makes much sense. I haven't
actually confirmed that any real progress is made... just that I can
see "loading XYZ from db" in my log files... those messages are logged
*before* the data is loaded so I don't know it has been at this point).

Thread dumps show that everything is waiting on:

 - org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection()
@bci=55, line=1385 (Interpreted frame)

It's not that large a number of threads. It's something like 30-40
threads waiting on connections. (I'm not entirely sure why there are
so many threads active... I'm the only one using this environment and
I made a single top-level request... I thought most browsers limited
their outgoing connections to something like 8 per hostname, but that
appears not to be the case).

I have a variety of methods in operation at that time, but they are
all waiting on a database connection.

My DataSource configuration:

   <Resource name="jdbc/diagnosis"
    description="JDBC connection to main CHADIS database"
        auth="Container"
        type="javax.sql.DataSource"
        maxActive="1"
        maxIdle="1"
        maxWait="10000"
        url="[url]"
        username="[user]"
        password="[user]"
        driverClassName="com.mysql.jdbc.Driver"
        removeAbandoned="true"
        removeAbandonedTimeout="30"
        logAbandoned="true"
    testOnBorrow="true"
    validationQuery="/* ping */ SELECT 1"
    />

Note that I have a single database connection in the pool. This is to
catch any potential deadlocks in my JDBC code, and to catch abandoned
resources as soon as possible. I get *no warnings* about abandoned
anything. I don't even get timeouts waiting for connections from the
pool (there is supposed to be a 10-second connection timeout waiting
for a connection from the pool... those timeouts do not appear to be
happening... they should trigger exceptions in my log file). The MySQL
database reports that the connection held by my web application is
completely idle, and sits there doing nothing. No query is in progress.

It looks like DBCP2 is kind of hosing, here.

I don't have a simple test case right now, unfortunately, but I do
know that it has worked every time (maybe a dozen times) under Tomcat
7.0.47 and failed every time (maybe 5 times, now) under Tomcat 8.0.3.

I'm going to try using tomcat-pool to see if it makes any difference.
I suspect it will, since they are completely different architectures.

Any suggestions?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTFoLjAAoJEBzwKT+lPKRYMOIP/3HestrhGen4GMPRTDpM5VJN
5kW8dxlPJ4U9vLioLk9FgvLVWdPOsaHQpzWP0rII2qvynhb1XIf/D3idRCOsQ9Q8
jxjDxEMhX2RRuMjqZES5ACY1CxhaElBcfzYI39Gh0hPfqdotilQ/3U+7yCR7N0F/
NbGmjYFSOBXgPFYwMGTB6Z7cXq+PyAcz0H7N7sc6vFOqBY4cjwFKTNkacxyogCcP
a163TFqdo5FbZ5zat76QHy96SkFLzT9wez7tMWJLyQlSA2XUHgyj0ch9THCvfNea
o+PVkClnR2Cz5PCJKRTZ5X+14Gs/oSquRSlsqjlA78trDnJu2joC7KfE7WwnkwdT
WCkDepAoSD5SSH4YWLz2PScp3vNl1sZ6cQVSJ0IjfQdDkSt62jzbjUoNbnSEEC0s
hi3ChqoZoB1s+bY+eM3Yd70Fwv5YGlDEsPaemmwz3psZt+xw8/8NeH+a+KABVM6S
azIblSM9Gsq0Knv2LJeTzby8SxO4Luqcyf5b0M+USeWrEXxiFpDv2VtHCeqwnaLD
9ojx5AGvlbJN/WXYCXvHS60FYdhlZIWXltrkO7FticbEkJUC5ptNMfPfHqCcf+KG
CbaMs6QiAKmlPDQ+f5tQXOvnwR8eB9jdkwjkicjXogwmvKmLh6luVuq5+TyGD/0s
f4dzoI/10l9h/RivLSnB
=qNjE
-----END PGP SIGNATURE-----

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

Reply via email to