db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepa Remesh <drem...@gmail.com>
Subject Re: [jira] Commented: (DERBY-210) Network Server will leak prepared statements if not explicitly closed by the user until the connection is closed
Date Mon, 13 Feb 2006 19:49:01 GMT
On 2/13/06, Daniel John Debrunner (JIRA) <derby-dev@db.apache.org> wrote:
>     [ http://issues.apache.org/jira/browse/DERBY-210?page=comments#action_12366232 ]
>
> Daniel John Debrunner commented on DERBY-210:
> ---------------------------------------------
>
> The use of close() for close and reset is confusing (I know it's existing code).
>
> Your addition is now the only  code in close() that actually generates new objects. This
code
> will be called even when the statement is being closed in order that it no longer be
used.
> This might have a performance impact, I don't know how often in a well behaved application
> this internal close method would be called. Once per statement execution or creation?
>
> I'm unclear on what this patch ('derby-210-patch3.diff') is addrressing. The comments
for
> item 10) above don't actually help me much. Was the old code successfully re-using the
old
> DRDAResultSet() but now for some reason we force it to use a new one every time?
>

The old code was successfully re-using DRDAResultSet. This patch will
be required after my changes to the finalization code in client
driver. With these changes, a CLSQRY is not sent for each result set
to network server during finalization. The cleanup of result sets is
expected to happen when the DRDAStatement is reset. But this was not
happening and I was getting a failure in derbynet/prepStmt.java when I
was running tests with the full set of changes. One solution to this
was to create a new DRDAResultSet, same as what would be done for a
new statement. I added this and a comment to say "close() method is
also called before re-using a statement in the method
Database.newDRDAStatement. It has to ensure that the statement state
is restored. ". I hope this explains the reason for this patch.

As I mentioned before, I was thinking if it was okay to add a "new"
into the close method. I did not see any performance impact since
close() gets called when re-using statements or when the session is
closed. During a session, DRDAStatement.close() method gets called
only when the statement is re-used. When session is closed,
DRDAStatement.close() gets called for each statement in the statement
table and the statement also gets removed from the hash table. From
what I understood, I think there is no performance impact because of
this change. Please correct me if I am wrong here.

Still, it looks confusing to be doing "new" inside the close() method.
One easy option I can think of is to separate close and reset as 2
methods. I was also trying to see if I can reset any variables inside
the DRDAResultSet to restore its state. I have been trying to see if
this is possible but not successful. I will look into this some more.
Any suggestions are welcome.

Thanks,
Deepa

Mime
View raw message