You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Kristian Waagan (JIRA)" <de...@db.apache.org> on 2006/03/10 17:28:51 UTC

[jira] Created: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Closing an embedded connection does not seem to close associated EmbedStatements
--------------------------------------------------------------------------------

         Key: DERBY-1095
         URL: http://issues.apache.org/jira/browse/DERBY-1095
     Project: Derby
        Type: Bug
  Components: JDBC  
    Versions: 10.2.0.0    
    Reporter: Kristian Waagan
    Priority: Minor


Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.

Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12370305 ] 

Daniel John Debrunner commented on DERBY-1095:
----------------------------------------------

Knut wrote:

> In the client driver, NetConnection maintains a WeakHashMap with all
> open statements. When the connection is marked as closed, it will call
> markClosed() on the open statements. I'm afraid I don't see why it's a
> bad idea to do the same in EmbedConnection. Could you please explain?

Two reasons:

    1) Statement resources are already closed correctly on a connection.close() so I don't know what purpose this additional code is meant to solve.

    2) Performance overhead due to storage and additional object creation and garbage collection is a concern. Maybe if it's only at the
     Statement level it's not too bad a concern, but there would have to be some additional logic to handle server-side JDBC. In the server-side case
      I don't think you want to set up the WeakHashMap, if you did the performance overhead would be a concern, because with server-side
       logic there is no way for the application to hang onto statements for multiple applications like a JDBC client program can. Also J2EE
       applications tend to be stateless and therefore incur Statement creation on each execution.

For ResultSet.isClosed() a simple way of implementing it would be:

  if (isClosed)
     return true;
 
   try {
         checkExecStatus();
          return false;
} catch (SQLException sqle)
{
     return isClosed;
}

A similar approach would work for Statement.isClosed.

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Kristian Waagan (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12370518 ] 

Kristian Waagan commented on DERBY-1095:
----------------------------------------

Thanks Dan.

The slides are nice :) Assuming they are still up-to-date, I would recommend people who haven't looked at them do so!

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java, derby-1095-ResultSet.isClosed-v1.diff, derby-1095-ResultSet.isClosed-v1.stat
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1095?page=all ]

Daniel John Debrunner reassigned DERBY-1095:
--------------------------------------------

    Assign To: Daniel John Debrunner

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Reopened: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1095?page=all ]
     
Daniel John Debrunner reopened DERBY-1095:
------------------------------------------


> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug

>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>      Fix For: 10.2.0.0
>  Attachments: Derby1095Repro.java, derby-1095-ResultSet.isClosed-v1.diff, derby-1095-ResultSet.isClosed-v1.stat
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1095?page=all ]
     
Daniel John Debrunner closed DERBY-1095:
----------------------------------------

    Resolution: Fixed

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug

>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>      Fix For: 10.2.0.0
>  Attachments: Derby1095Repro.java, derby-1095-ResultSet.isClosed-v1.diff, derby-1095-ResultSet.isClosed-v1.stat
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12369887 ] 

Daniel John Debrunner commented on DERBY-1095:
----------------------------------------------

I wouldn't actually describe this as a bug, it's more an internal issue. As far as the application is concerned the Statement and ResultSet's are closed.
I see it as really  an internal optimization. 

I do think it needs to be fixed, I don't think the Connection having a list of open statements and calling close on them is the way to go.
I've been thinking about ways to fix this related to DERBY-538  where an application holding onto an open statement or result set
might hold onto the class loader indirectly and thus keep an open file. I was thinking about addressing this in the language connection
context, where the real list of active resources is held.

Not sure why it blocks DERBY-953, if all the other statements can detect if the Statement has been automatically closed,
why can't isClosed? Seems like the proposed implementation of that method is insufficient.

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Priority: Minor
>  Attachments: Derby1095Repro.java
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Kristian Waagan (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1095?page=all ]

Kristian Waagan updated DERBY-1095:
-----------------------------------

    Attachment: Derby1095Repro.java

Simple repro for demonstrating the issue. Compile and run with JDK 1.6. Derby must also be built with JDK 1.6.
The repro will fail with a "java.sql.SQLTransientConnectionException: No current connection" as long as the issue exist.
When the issue is fixed, it should simply print two lines saying both the connection and the resultset is closed.

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Priority: Minor
>  Attachments: Derby1095Repro.java
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Knut Anders Hatlen (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12371521 ] 

Knut Anders Hatlen commented on DERBY-1095:
-------------------------------------------

EmbedResultSet.isClosed() is fixed in revision 388093.

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java, derby-1095-ResultSet.isClosed-v1.diff, derby-1095-ResultSet.isClosed-v1.stat
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Knut Anders Hatlen (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1095?page=all ]

Knut Anders Hatlen updated DERBY-1095:
--------------------------------------

    Attachment: derby-1095-ResultSet.isClosed-v1.diff
                derby-1095-ResultSet.isClosed-v1.stat

Attaching patch derby-1095-ResultSet.isClosed-v1.diff.
EmbedResultSet40.isClosed() is fixed (and moved to
EmbedResultSet). Also added regression test.

derbyall and jdbc4 passed.

Does the patch look OK?

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java, derby-1095-ResultSet.isClosed-v1.diff, derby-1095-ResultSet.isClosed-v1.stat
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12370471 ] 

Daniel John Debrunner commented on DERBY-1095:
----------------------------------------------

I don't have time now to write up how the cleanup of connection close happens but it is covered somewhat in:

http://db.apache.org/derby/binaries/ApacheDerbyInternals_1_1.pdf

slides 29-32

I'll try and produce a writeup early next week.

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java, derby-1095-ResultSet.isClosed-v1.diff, derby-1095-ResultSet.isClosed-v1.stat
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Lance J. Andersen" <La...@Sun.COM>.

Kristian Waagan (JIRA) wrote:
>     [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12370077 ] 
>
> Kristian Waagan commented on DERBY-1095:
> ----------------------------------------
>
> I see your point, but I still think Derby is buggy. The repro script executes a statement, closes the connection then asks the resultset if it is closed. The resultset says it is not, and based on this the repro then executes an operation that causes an exception to be thrown. A correct answer from ResultSet.isClosed() would not have caused an exception in the repro.
>
> According to the JDBC4 spec: "A ResultSet is closed if the method close has been called on it, or if it is automatically closed."
> I thought closing the underlying connection should close all associated resources, including the resultset(s). Am I mistaken?
>   
Yes, closing the connection should result in any Statement objects and 
associated ResultSets being closed.

lance
> I notice that ResultSet.isClosed() simply returns a variable ('isClosed'), and to me it seems that the state of this variable is not maintained correctly (have not looked at the code), thus the ResultSet.isClosed() method suffers the same problem as Statement.isClosed(). We must either ensure the internal state is kept correct, or we must add extra checks to the isClosed methods.
> Although the latter solution is very simple (at least for Statement), I personally think it would be better if the close methods were executed also when the resources are automatically "closed".
>
> Dan, since you have assigned yourself to this issue, can you tell me how your (planned) solution would affect the internal state variables in ResultSet and Statment, so that I can fix Statement.isClosed accordingly?
>
>   
>> Closing an embedded connection does not seem to close associated EmbedStatements
>> --------------------------------------------------------------------------------
>>
>>          Key: DERBY-1095
>>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>>      Project: Derby
>>         Type: Bug
>>   Components: JDBC
>>     Versions: 10.2.0.0
>>     Reporter: Kristian Waagan
>>     Assignee: Daniel John Debrunner
>>     Priority: Minor
>>  Attachments: Derby1095Repro.java
>>
>> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
>> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
>> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
>> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
>> Problem detected while fixing DERBY-953; implement Statement.isClosed().
>>     
>
>   

[jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Kristian Waagan (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12370077 ] 

Kristian Waagan commented on DERBY-1095:
----------------------------------------

I see your point, but I still think Derby is buggy. The repro script executes a statement, closes the connection then asks the resultset if it is closed. The resultset says it is not, and based on this the repro then executes an operation that causes an exception to be thrown. A correct answer from ResultSet.isClosed() would not have caused an exception in the repro.

According to the JDBC4 spec: "A ResultSet is closed if the method close has been called on it, or if it is automatically closed."
I thought closing the underlying connection should close all associated resources, including the resultset(s). Am I mistaken?

I notice that ResultSet.isClosed() simply returns a variable ('isClosed'), and to me it seems that the state of this variable is not maintained correctly (have not looked at the code), thus the ResultSet.isClosed() method suffers the same problem as Statement.isClosed(). We must either ensure the internal state is kept correct, or we must add extra checks to the isClosed methods.
Although the latter solution is very simple (at least for Statement), I personally think it would be better if the close methods were executed also when the resources are automatically "closed".

Dan, since you have assigned yourself to this issue, can you tell me how your (planned) solution would affect the internal state variables in ResultSet and Statment, so that I can fix Statement.isClosed accordingly?

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1095?page=all ]

Daniel John Debrunner updated DERBY-1095:
-----------------------------------------

    Fix Version: 10.2.0.0

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug

>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>      Fix For: 10.2.0.0
>  Attachments: Derby1095Repro.java, derby-1095-ResultSet.isClosed-v1.diff, derby-1095-ResultSet.isClosed-v1.stat
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12370115 ] 

Daniel John Debrunner commented on DERBY-1095:
----------------------------------------------

Are there bugs open for the incorrect results from Statement.isClosed() and ResultSet.isClosed? If so I can pick them up after my latest change under this bug, which is currently undergoing tests. Or I could fix them under this bug.

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Knut Anders Hatlen (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12370210 ] 

Knut Anders Hatlen commented on DERBY-1095:
-------------------------------------------

Dan Debrunner wrote:

> I do think it needs to be fixed, I don't think the Connection having
> a list of open statements and calling close on them is the way to
> go.

In the client driver, NetConnection maintains a WeakHashMap with all
open statements. When the connection is marked as closed, it will call
markClosed() on the open statements. I'm afraid I don't see why it's a
bad idea to do the same in EmbedConnection. Could you please explain?

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1095?page=all ]
     
Daniel John Debrunner closed DERBY-1095:
----------------------------------------

    Resolution: Fixed

I think all the cleanup for this task has been performed. A connection close always did incorrectly close
any JDBC objects, now the context manager is cleaned up correctly as well.

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java, derby-1095-ResultSet.isClosed-v1.diff, derby-1095-ResultSet.isClosed-v1.stat
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Kristian Waagan (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12370138 ] 

Kristian Waagan commented on DERBY-1095:
----------------------------------------

No Jiras have been opened. First patch for Statement.isClosed() is not even committed yet (DERBY-953). Code for ResultSet.isClosed() is committed under DERBY-948. 
I was planning to  change the patch for Statement.isClosed() based on information about your planned fix, but if you want to do it just unassign me from the issue and assign yourself.

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Knut Anders Hatlen (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12371431 ] 

Knut Anders Hatlen commented on DERBY-1095:
-------------------------------------------

The patch for ResultSet.isClosed() has to be updated because of a
conflict with the rearranging of the jdbc4 test suite. I will resolve
the conflict and commit the patch tomorrow.

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java, derby-1095-ResultSet.isClosed-v1.diff, derby-1095-ResultSet.isClosed-v1.stat
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-1095) Closing an embedded connection does not seem to close associated EmbedStatements

Posted by "Kristian Waagan (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12370338 ] 

Kristian Waagan commented on DERBY-1095:
----------------------------------------

I do not disagree that it is easy to implement isClosed to return the intended results (I commented this when uploading the patch for DERBY-953).

However, by looking briefly at EmbedConnection, I cannot immediatly see how assoicated resources are closed when EmbedConnection.close() is called. Can someone familiar with the code take a few minutes to briefly explain how it is done? (I'm referring to reason 1 in the previous comment by Dan)
With regard to statements and resultsets, are these being closed explicitly or are we only nulling out the references to them?

> Closing an embedded connection does not seem to close associated EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java
>
> Closing an embedded connection (calling EmbedConnection.close()) does not seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the internal EmbedStatement variable 'active' is not updated accordingly, the most severe case is that the the resources bound to EmbedStatement will not be viable for garbage collection until the EmbedStatement itself is (if user keeps references to it).
> If methods on the statement are called, Derby will correctly throw an NoCurrentConnection exception, but the close() method is still never called automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira