db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Deepa Remesh (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-210) Network Server will leak prepared statements if not explicitly closed by the user until the connection is closed
Date Mon, 20 Feb 2006 00:22:01 GMT
    [ http://issues.apache.org/jira/browse/DERBY-210?page=comments#action_12366995 ] 

Deepa Remesh commented on DERBY-210:
------------------------------------

Thanks Kathey.

In short, this is what I have been trying to do in patch4 - Limit the finalize in client statement
classes to client side cleanup and let the server handle the cleanup of its objects based
on current logic of statement re-use. So I changed finalize to not send any network commands.


But this will not work well for Kathey's scenario, where an application keeps all its statement
references and dereferences all of them in the end. With my change in finalize, the result
sets will get cleaned up only when client driver re-uses a section number for a new statement
which will make network server close it's statement and free up result sets OR when the connection
is closed.

On first look, Kathey's scenario seemed highly improbable but I guess an application can do
that if it stores references to statements in some hashtable. I will try to create a repro
for Kathey's scenario and add this case to derbyStress.java and see the behaviour with my
patches.

I'm reworking finalize method to continue sending CLSQRY as Kathey suggested and will upload
new version of patch 4.

> Network Server will leak prepared statements if not explicitly closed by the user until
the connection is closed
> ----------------------------------------------------------------------------------------------------------------
>
>          Key: DERBY-210
>          URL: http://issues.apache.org/jira/browse/DERBY-210
>      Project: Derby
>         Type: Bug
>   Components: Network Client
>     Reporter: Kathey Marsden
>     Assignee: Deepa Remesh
>  Attachments: DOTS_ATCJ2_Derby-noPatch.png, DOTS_ATCJ2_Derby-withPatch.png, derby-210-patch1.diff,
derby-210-patch2.diff, derby-210-patch2.status, derby-210-patch3.diff, derby-210-patch4-v2.diff,
derby-210-patch4-v2.status, derby-210-v2-draft.diff, derby-210-v2-draft.status, derbyStress.java
>
> Network server will not garbage collect prepared statements that are not explicitly closed
by the user.  So  a loop like this will leak.
> ...
> PreparedStatement ps;
>  for (int i = 0 ; i  < numPs; i++)
> 	{
> 	 ps = conn.prepareStatement(selTabSql);
> 	 rs =ps.executeQuery();
> 	 while (rs.next())
> 	{
> 	    rs.getString(1);
> 	}
> 	rs.close();
> 	// I'm a sloppy java programmer
> 	//ps.close();
> 	}
> 			
> To reproduce run the attached program 
> java derbyStress
> Both client and server will grow until the connection is closed.
>  
> It is likely that the fix for this will have to be in the client.  The client does not
send protocol to close the prepared statement, but rather reuses the PKGNAMCSN on the PRPSQLSTT
request once the prepared statement has been closed. This is how the server knows to close
the old statement and create a new one.

-- 
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


Mime
View raw message