You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Naozumi Taromaru (Created) (JIRA)" <ji...@apache.org> on 2011/12/05 14:11:41 UTC

[jira] [Created] (DBCP-372) Statement Leak occurs when batch update is used.

Statement Leak occurs when batch update is used.
------------------------------------------------

                 Key: DBCP-372
                 URL: https://issues.apache.org/jira/browse/DBCP-372
             Project: Commons Dbcp
          Issue Type: Bug
    Affects Versions: 1.4, 1.3
         Environment: Oracle 11g
            Reporter: Naozumi Taromaru
            Priority: Critical


org.apache.commons.dbcp.PoolablePreparedStatement#passivate()
execute clearBatch().
(DBCP-264)

But this clearBatch() throw SQLException.
(DelegatingStatement#checkOpen() throw SQLException, because _closed is true.)

The result,
the PoolablePreparedStatement doesn't return to pool, and
the PoolablePreparedStatement doesn't execute PreparedStatement#close().

When a lot of data is processed, 
in the case of Oracle
 * ORA-00604
 * ORA-01000

occurs.


Proposal:
"clearBatch();" in passivate() method
changes as follows.

batchAdded = false;
getInnermostDelegate().clearBatch();


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DBCP-372) Statement Leak occurs when batch update is used.

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DBCP-372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13492454#comment-13492454 ] 

Thomas Neidhart commented on DBCP-372:
--------------------------------------

Indeed, the current passivate method in PoolablePreparedStatement does the following:

{noformat}
    public void passivate() throws SQLException {
        _closed = true;
        if(_conn != null) {
            _conn.removeTrace(this);
        }

        // The JDBC spec requires that a statement closes any open
        // ResultSet's when it is closed.
        // FIXME The PreparedStatement we're wrapping should handle this for us.
        // See bug 17301 for what could happen when ResultSets are closed twice.
        List<AbandonedTrace> resultSets = getTrace();
        if( resultSets != null) {
            ResultSet[] set = resultSets.toArray(new ResultSet[resultSets.size()]);
            for (int i = 0; i < set.length; i++) {
                set[i].close();
            }
            clearTrace();
        }
        if (batchAdded) {
            clearBatch();
        }
        
        super.passivate();
    }
{noformat}

Thus, indicating that the connection is closed first, and then afterwards trying to clear any batches. Now the clearBatch method throws an exception if the connection is already marked as closed.

Imho, the suggested fix would be fine, but we could also change the passivate method to call clearBatch before setting _closed to true.
                
> Statement Leak occurs when batch update is used.
> ------------------------------------------------
>
>                 Key: DBCP-372
>                 URL: https://issues.apache.org/jira/browse/DBCP-372
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 1.3, 1.4
>         Environment: Oracle 11g
>            Reporter: Naozumi Taromaru
>            Priority: Critical
>             Fix For: 1.4.1
>
>
> org.apache.commons.dbcp.PoolablePreparedStatement#passivate()
> execute clearBatch().
> (DBCP-264)
> But this clearBatch() throw SQLException.
> (DelegatingStatement#checkOpen() throw SQLException, because _closed is true.)
> The result,
> the PoolablePreparedStatement doesn't return to pool, and
> the PoolablePreparedStatement doesn't execute PreparedStatement#close().
> When a lot of data is processed, 
> in the case of Oracle
>  * ORA-00604
>  * ORA-01000
> occurs.
> Proposal:
> "clearBatch();" in passivate() method
> changes as follows.
> batchAdded = false;
> getInnermostDelegate().clearBatch();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (DBCP-372) Statement Leak occurs when batch update is used.

Posted by "Phil Steitz (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DBCP-372?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Steitz updated DBCP-372:
-----------------------------

    Fix Version/s: 1.4.1
    
> Statement Leak occurs when batch update is used.
> ------------------------------------------------
>
>                 Key: DBCP-372
>                 URL: https://issues.apache.org/jira/browse/DBCP-372
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 1.3, 1.4
>         Environment: Oracle 11g
>            Reporter: Naozumi Taromaru
>            Priority: Critical
>             Fix For: 1.4.1
>
>
> org.apache.commons.dbcp.PoolablePreparedStatement#passivate()
> execute clearBatch().
> (DBCP-264)
> But this clearBatch() throw SQLException.
> (DelegatingStatement#checkOpen() throw SQLException, because _closed is true.)
> The result,
> the PoolablePreparedStatement doesn't return to pool, and
> the PoolablePreparedStatement doesn't execute PreparedStatement#close().
> When a lot of data is processed, 
> in the case of Oracle
>  * ORA-00604
>  * ORA-01000
> occurs.
> Proposal:
> "clearBatch();" in passivate() method
> changes as follows.
> batchAdded = false;
> getInnermostDelegate().clearBatch();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira