com.ibatis.common.util.Throttle not decrementing Session counter causes
application to hang
-------------------------------------------------------------------------------------------
Key: IBATIS-66
URL: http://issues.apache.org/jira/browse/IBATIS-66
Project: iBatis for Java
Type: Bug
Components: SQL Maps
Versions: 2.0.9
Environment: WSAD/WebSphere 5.1, Windows XP Pro
Reporter: Mark Nabours
Attachments: SqlMapClientSessionTest.java
Hello,
I have a rather serious problem to which we need a quick resolution.
In brief, the increment method on the Throttle class is being called for
sessions after executing SqlMapClient.setUserConnection() but the
corresponding decrement method is never being called. After we reach the
session limit configured in sql-map-config.xml the application hangs hard!
Here are some of the specifics, we are using iBATIS to map data from a
database to our own set of data objects. However, we are not using iBATIS
to acquire the database connections; we are externally providing them to
the iBATIS SqlMapClient through the setUserConnection method, and we clear
the transaction out by calling setUserConnection and passing null for the
connection. We have our own connection acquisition code that we use and
therefore we do not even have a transactionManager element configured
within sql-map-config.xml -- we would prefer not to have to configure it
since it requires a data source to be configured and our connection
acquisition code if highly flexible to use different types of connection
ion various environments. It's my understanding that it is perfectly
acceptable to use iBATIS by providing external connections as long as you
handle all of your transactional requirements (which we do).
I have attached the following test case that illustrates the problem. We
have configured the maximum session count to 75. Don't read too much into
our test case code as it acquires a single connection and immediately
closes it so that we don't leave the connection open when the test case
freezes. We loop 80 times and we hang after 75 iterations.
/*
* Created on Feb 3, 2005.
*/
package com.alliancesys.common.ibatis.testing;
import java.io.Reader;
import java.sql.Connection;
import java.sql.SQLException;
import com.alliancesys.common.jdbc.DatabaseConnectionService;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import junit.framework.TestCase;
/**
* <code>[EMAIL PROTECTED] SqlMapClientSessionTest}</code>
*
*/
public class SqlMapClientSessionTest extends TestCase {
private int threadCounter = 0;
public SqlMapClientSessionTest(String arg0) {
super(arg0);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(SqlMapClientSessionTest.class);
}
private synchronized void writeCount(){
threadCounter++;
System.out.println("Thread " + threadCounter + " completed.");
}
public void testThrottleSessionLock() throws Exception {
final Connection connection =
DatabaseConnectionService.getNewConnection();
connection.close();
Reader reader =
Resources.getResourceAsReader(
getClass().getClassLoader(),
"sql-map-config.xml");
final SqlMapClient sqlMapClient =
SqlMapClientBuilder.buildSqlMapClient(reader);
for (int i = 0; i < 80; i++) {
Runnable runnable = new Runnable() {
public void run() {
try {
SqlMapClient client = sqlMapClient;
Connection cn = connection;
client.setUserConnection(cn);
client.setUserConnection(null);
writeCount();
} catch (SQLException e) {
e.printStackTrace();
}
}
};
Thread t = new Thread(runnable);
t.start();
}
}
}
If you run it, you will notice that if you have max sessions configured to
75 it hangs after completion of the 75 thread.
Our sql-map-config.xml file is as follows:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "
http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<properties
resource="ibatis.properties" />
<settings
cacheModelsEnabled="true"
enhancementEnabled="true"
maxSessions="75"
maxTransactions="20"
maxRequests="140" />
<sqlMap resource="Contact.xml" />
</sqlMapConfig>
We are hoping that it is a configuration problem, but we suspect that the
decrement method on Throttle needs to be called internally.
Let me thank you in advance for you help. iBATIS is an great product, but
this is currently preventing us from moving through QA into production.
Thanks,
Mark Nabours
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira