users@glassfish.java.net

Glassfish/Toplink and sqljdbc4.jar retrying forever on broken db-connection

From: <glassfish_at_javadesktop.org>
Date: Wed, 12 Aug 2009 02:22:35 PDT

I'm using Glassfish and Toplink together with an MS-SQL-Server, thus sqljdbc4.jar is used for connecting to the database. When the database is not available (DB server is down), the CPU usage rises to 100% and Glassfish keeps on trying to connect forever. My log fills up rapidly with the following messages:


FINE: TDSChannel (ConnectionID:7) read failed:Connection reset
FINE: *** SQLException:ConnectionID:7 com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset Connection reset
FINE: com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1368)com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1355)com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1532)com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:3274)com.microsoft.sqlserver.jdbc.TDSReader.nextPacket(IOBuffer.java:3227)com.microsoft.sqlserver.jdbc.TDSReader.ensurePayload(IOBuffer.java:3203)com.microsoft.sqlserver.jdbc.TDSReader.peekTokenType(IOBuffer.java:3420)com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:50)com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:39)com.microsoft.sqlserver.jdbc.SQLServerStatement.processExecuteResults(SQLServerStatement.java:1064)com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.processResponse(SQLServerPreparedStatement.java:345)com.microsoft.sqlserver.jdbc.TDSCommand.close(IOBuffer.java:4111)com.microsoft.sqlserver.jdbc.SQLServerStatement.discardLastExecutionResults(SQLServerStatement.java:99)com.microsoft.sqlserver.jdbc.SQLServerStatement.closeInternal(SQLServerStatement.java:592)com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.closeInternal(SQLServerPreparedStatement.java:170)com.microsoft.sqlserver.jdbc.SQLServerStatement.close(SQLServerStatement.java:604)com.sun.gjc.spi.ManagedConnectionFactory.isValidByTableQuery(ManagedConnectionFactory.java:397)com.sun.gjc.spi.ManagedConnectionFactory.isValid(ManagedConnectionFactory.java:297)com.sun.gjc.spi.ManagedConnectionFactory.getInvalidConnections(ManagedConnectionFactory.java:246)com.sun.enterprise.resource.AbstractConnectorAllocator.getInvalidConnections(AbstractConnectorAllocator.java:99)com.sun.enterprise.resource.AbstractResourcePool.removeInvalidResources(AbstractResourcePool.java:1535)com.sun.enterprise.resource.AbstractResourcePool.removeInvalidAndIdleResources(AbstractResourcePool.java:1515)com.sun.enterprise.resource.AbstractResourcePool.resizePool(AbstractResourcePool.java:1448)com.sun.enterprise.resource.AbstractResourcePool$Resizer.run(AbstractResourcePool.java:1610)java.util.TimerThread.mainLoop(Timer.java:512)java.util.TimerThread.run(Timer.java:462)


Is there a way to set a retry-limit for connections to the database, or a pause timeout between the connection retries?

How can I make Glassfish throw an exception instead trying to connect forever?
[Message sent by forum member 'rosi' (rosi)]

http://forums.java.net/jive/thread.jspa?messageID=360044