Re: binary patch problems - Mailing list pgsql-jdbc

From Mikko Tiihonen
Subject Re: binary patch problems
Date
Msg-id 4E734D08.10205@nitorcreations.com
Whole thread Raw
In response to binary patch problems  (Dave Cramer <pg@fastcrypt.com>)
Responses Re: binary patch problems  (Dave Cramer <pg@fastcrypt.com>)
Re: binary patch problems  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
On 09/16/2011 01:10 AM, Dave Cramer wrote:
> I have applied to the current code and the tests fail with ResultSet
> already closed. I can't replicate this in eclipse, only in the command
> line ant test. My guess is that somehow result sets are being shared
> across tests. Anyone shed some light on this ? The patch I applied is
> at http://wiki.postgresql.org/wiki/JDBC-BinaryTransfer version 13
> Dave Cramer

I've been lately trying to figure out the same problem.
In separate emails I just sent the refreshed set of patches broken into separate patches out for easier review.

The trace shows that for some reason the C_5 portal is closed while still processing the results.

(3)  FE=> Execute(portal=C_5,limit=1)
(3)  FE=> Sync
(3)  <=BE DataRow(len=305)
(3)  <=BE PortalSuspended
(3)  <=BE ReadyForQuery(T)
(3)  FE=> Execute(portal=C_5,limit=1)
(3)  FE=> Sync
(3)  <=BE DataRow(len=305)
(3)  <=BE PortalSuspended
(3)  <=BE ReadyForQuery(T)
(3)  FE=> CloseStatement(S_2)
(3)  FE=> ClosePortal(C_5)
(3)  FE=> Execute(portal=C_5,limit=1)
(3)  FE=> Sync
(3)  <=BE CloseComplete
(3)  <=BE CloseComplete
(3)  <=BE ErrorMessage(ERROR: portal "C_5" does not exist
  Location: File: postgres.c, Routine: exec_execute_message, Line: 1844
  Server SQLState: 34000)
org.postgresql.util.PSQLException: ERROR: portal "C_5" does not exist
  Location: File: postgres.c, Routine: exec_execute_message, Line: 1844
  Server SQLState: 34000
       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2158)
       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1887)
       at org.postgresql.core.v3.QueryExecutorImpl.fetch(QueryExecutorImpl.java:2090)
       at org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2ResultSet.java:1870)
       at org.postgresql.test.jdbc2.DatabaseEncodingTest.testEncoding(DatabaseEncodingTest.java:149)

The C_5 portal is closed because it is in the openPortalCleanupQueue containing PhantomReferences. The trace shows that
S_2is also closed at the same 
time, which is correct because that statement is no longer in use.

If I debugged it correctly it looks like the query statement is closed by finalizer during the test which in turn
closesthe relevant portals. 
If I add stmt.close() to the end of the test there are no failures as it keeps the GC from killing of the statement
duringthe test. 

But why I only seem to get it when running with binary transfer patches I do not know. So there must be something in
thepatches that I cannot spot. 

-Mikko

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: binary patch problems
Next
From: Mikko Tiihonen
Date:
Subject: Binary transfer support [0/7] - intro