lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Serba (JIRA)" <>
Subject [jira] [Commented] (SOLR-2045) DIH doesn't release jdbc connections in conjunction with DB2
Date Sat, 11 Jun 2011 16:57:01 GMT


Alexey Serba commented on SOLR-2045:

I encountered the same problem with Derby database. The reason is that you need to issue commit
or rollback before releasing jdbc connection (that's ridiculous requirement but it is what
it is). So this patch fixing this problem.

But there's even more easy workaround that doesn't require patching Solr sources. You can
set data source autoCommit property to true.

bq. Setting the connection to readOnly or changing the transaction isolation level doesn't
help neither.
readOnly property should help as well, but there's a bug in parameters parsing logic. Documentation
claims that readOnly parameter causes setting autoCommit property to true, but that's not
true as the next conditional statement resets this property back to false.

          if (Boolean.parseBoolean(initProps.getProperty("readOnly"))) {
            // Add other sane defaults
          if (!Boolean.parseBoolean(initProps.getProperty("autoCommit"))) {

> DIH doesn't release jdbc connections in conjunction with DB2 
> -------------------------------------------------------------
>                 Key: SOLR-2045
>                 URL:
>             Project: Solr
>          Issue Type: Bug
>          Components: contrib - DataImportHandler
>    Affects Versions: 1.4.1
>         Environment: DB2 SQLLIB 9.5, 9.7 jdbc Driver
>            Reporter: Fenlor Sebastia
> Using the JDBCDatasource in conjunction with the DB2 JDBC Drivers results in the following
error when the DIH tries to close the the connection due to active transactions. As a consequence
each delta im port or full import opens a new connection without closing it. So the maximum
amount of connections will be reached soon. Setting the connection to readOnly or changing
the transaction isolation level doesn't help neither.
> The JDBC Driver I used: "" relieing in db2jcc4.jar shipped with
DB2 Express 9.7 for example
> Here is the stack trace...
> 14.08.2010 01:49:51 org.apache.solr.handler.dataimport.JdbcDataSource closeConnection
> FATAL: Ignoring Error when closing connection
> [jcc][10251][10308][4.8.87] java.sql.Connection.close()
requested while a transaction is in progress on the connection.The transaction remains active,
and the connection cannot be closed. ERRORCODE=-4471, SQLSTATE=null
> 	at
> 	at
> 	at
> 	at
> 	at
> 	at
> 	at
> 	at
> 	at org.apache.solr.handler.dataimport.JdbcDataSource.closeConnection(
> 	at org.apache.solr.handler.dataimport.JdbcDataSource.close(
> 	at org.apache.solr.handler.dataimport.DataConfig$Entity.clearCache(
> 	at org.apache.solr.handler.dataimport.DataConfig.clearCaches(
> 	at org.apache.solr.handler.dataimport.DataImporter.doFullImport(
> 	at org.apache.solr.handler.dataimport.DataImporter.runCmd(
> 	at org.apache.solr.handler.dataimport.DataImporter$
> Well the issue can be solved by invoking a commit or rollback directly before the connection.close()
statement. Here is the code snipped of changes I made in
>   private void closeConnection()  {
>     try {
>       if (conn != null) {
>     	if (conn.isReadOnly())
> 		{
>"connection is readonly, therefore rollback");
> 			conn.rollback();
> 		} else
> 		{
>"connection is not readonly, therefore commit");
> 			conn.commit();
> 		}
>         conn.close();
>       }
>     } catch (Exception e) {
>       LOG.error("Ignoring Error when closing connection", e);
>     }
>   }

This message is automatically generated by JIRA.
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message