Subject | Fun with shutdown (was Closing FBWrappingDataSource) |
---|---|
Author | Elias Holman |
Post date | 2004-08-25T15:29:14Z |
I have been playing around with the shutdown() method as I run my
internal test suite, and have noticed a couple of possible bugs.
1) shutdown() on FBConnectionPoolDataSource does seem to close the
connections, but eventually, firebird seems to stop wanting to grant new
connections. I have attached a test case to demonstrate this. If you
rapidly open and shutdown a series of connection pools, eventually you
get:
org.firebirdsql.jdbc.FBSQLException: Resource Exception. connection
rejected by remote interface
Reason: connection rejected by remote interface
at
org.firebirdsql.pool.FBConnectionPoolDataSource.allocateConnection(FBConnectionPoolDataSource.java:300)
at
org.firebirdsql.pool.PooledConnectionQueue.addConnection(PooledConnectionQueue.java:415)
at
org.firebirdsql.pool.PooledConnectionQueue.start(PooledConnectionQueue.java:156)
at
org.firebirdsql.pool.AbstractConnectionPool.getQueue(AbstractConnectionPool.java:182)
at
org.firebirdsql.pool.FBConnectionPoolDataSource.getPooledConnection(FBConnectionPoolDataSource.java:366)
at
org.firebirdsql.pool.SimpleDataSource.getConnection(SimpleDataSource.java:56)
Sometimes you the message is 'unable to connect to localhost'. Perhaps
I am creating connections faster than the system can deallocate them?
2) If you try to do a shutdown() with 1 open connection, you get:
java.lang.IllegalStateException: Cannot execute desired operation
because pooled connection has invalid state.
at
org.firebirdsql.pool.PingablePooledConnection.checkValidity(PingablePooledConnection.java:163)
at
org.firebirdsql.pool.PingablePooledConnection.close(PingablePooledConnection.java:229)
at
org.firebirdsql.pool.PingablePooledConnection.deallocate(PingablePooledConnection.java:262)
at
org.firebirdsql.pool.PooledConnectionQueue.shutdown(PooledConnectionQueue.java:184)
at
org.firebirdsql.pool.AbstractConnectionPool.shutdown(AbstractConnectionPool.java:147)
This message is probably correct, but not particularly useful to the
user. I might suggest 'Cannot shutdown with open connection' or perhaps
even just closing any open connections silently on a shutdown() call.
Even less explanatory, if you have more than one connection open, you
get:
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782)
at java.util.HashMap$KeyIterator.next(HashMap.java:818)
at
org.firebirdsql.pool.PooledConnectionQueue.shutdown(PooledConnectionQueue.java:176)
at
org.firebirdsql.pool.AbstractConnectionPool.shutdown(AbstractConnectionPool.java:147)
Not sure if any of this will make it into the 1.5 final, but I wanted to
bring it up. These problems would probably not affect a real
application as rapidly opening and closing pools is not a common
occurrence, but you never know. Attached are two test cases that are
runnable in JUnit, or adaptable to any other purpose demonstrating these
errors.
--
Eli
[Non-text portions of this message have been removed]
internal test suite, and have noticed a couple of possible bugs.
1) shutdown() on FBConnectionPoolDataSource does seem to close the
connections, but eventually, firebird seems to stop wanting to grant new
connections. I have attached a test case to demonstrate this. If you
rapidly open and shutdown a series of connection pools, eventually you
get:
org.firebirdsql.jdbc.FBSQLException: Resource Exception. connection
rejected by remote interface
Reason: connection rejected by remote interface
at
org.firebirdsql.pool.FBConnectionPoolDataSource.allocateConnection(FBConnectionPoolDataSource.java:300)
at
org.firebirdsql.pool.PooledConnectionQueue.addConnection(PooledConnectionQueue.java:415)
at
org.firebirdsql.pool.PooledConnectionQueue.start(PooledConnectionQueue.java:156)
at
org.firebirdsql.pool.AbstractConnectionPool.getQueue(AbstractConnectionPool.java:182)
at
org.firebirdsql.pool.FBConnectionPoolDataSource.getPooledConnection(FBConnectionPoolDataSource.java:366)
at
org.firebirdsql.pool.SimpleDataSource.getConnection(SimpleDataSource.java:56)
Sometimes you the message is 'unable to connect to localhost'. Perhaps
I am creating connections faster than the system can deallocate them?
2) If you try to do a shutdown() with 1 open connection, you get:
java.lang.IllegalStateException: Cannot execute desired operation
because pooled connection has invalid state.
at
org.firebirdsql.pool.PingablePooledConnection.checkValidity(PingablePooledConnection.java:163)
at
org.firebirdsql.pool.PingablePooledConnection.close(PingablePooledConnection.java:229)
at
org.firebirdsql.pool.PingablePooledConnection.deallocate(PingablePooledConnection.java:262)
at
org.firebirdsql.pool.PooledConnectionQueue.shutdown(PooledConnectionQueue.java:184)
at
org.firebirdsql.pool.AbstractConnectionPool.shutdown(AbstractConnectionPool.java:147)
This message is probably correct, but not particularly useful to the
user. I might suggest 'Cannot shutdown with open connection' or perhaps
even just closing any open connections silently on a shutdown() call.
Even less explanatory, if you have more than one connection open, you
get:
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782)
at java.util.HashMap$KeyIterator.next(HashMap.java:818)
at
org.firebirdsql.pool.PooledConnectionQueue.shutdown(PooledConnectionQueue.java:176)
at
org.firebirdsql.pool.AbstractConnectionPool.shutdown(AbstractConnectionPool.java:147)
Not sure if any of this will make it into the 1.5 final, but I wanted to
bring it up. These problems would probably not affect a real
application as rapidly opening and closing pools is not a common
occurrence, but you never know. Attached are two test cases that are
runnable in JUnit, or adaptable to any other purpose demonstrating these
errors.
--
Eli
[Non-text portions of this message have been removed]