Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Interfaces Jdbc > Re: Deadlock wh...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 1907 of 2028
Post > Topic >>

Re: Deadlock while using getNotifications() and Statement.executeQuery()

by books@[EMAIL PROTECTED] (Kris Jurka) Apr 1, 2008 at 01:22 AM

This is a multi-part message in MIME format.
--------------070908060405080402000502
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Joao Rui Leal wrote:
> On Tuesday 25 March 2008, Kris Jurka wrote:
>> Still that's not a real clean/understandable design.  Perhaps instead
>> processNotifies() should be added to the public QueryExecutor interface
>> and then AbstractJdbc2Connection can call processNotifies itself so
that
>> fetching notifications from protoConnection doesn't require any
>> interaction with the QueryExecutor.
> 
> I agree.
> 

I've applied the attached patch to CVS back to the 8.1 driver.  The 8.0 
driver does not have this problem because it doesn't allow notification 
retrieval without executing a query.

Thanks for the re****t and diagnosis.

Kris Jurka

--------------070908060405080402000502
Content-Type: text/x-patch;
 name="syncnot.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="syncnot.patch"

Index: org/postgresql/core/QueryExecutor.java
===================================================================
RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/core/QueryExecutor.java,v
retrieving revision 1.41
diff -c -r1.41 QueryExecutor.java
*** org/postgresql/core/QueryExecutor.java	8 Jan 2008 06:56:27 -0000	1.41
--- org/postgresql/core/QueryExecutor.java	1 Apr 2008 07:09:38 -0000
***************
*** 170,175 ****
--- 170,184 ----
       */
      Query createParameterizedQuery(String sql); // Parsed for parameter
placeholders ('?')
  
+     /**
+      * Prior to attempting to retrieve notifications, we need to pull
+      * any recently received notifications off of the network buffers.
+      * The notification retrieval in ProtocolConnection cannot do this
+      * as it is prone to deadlock, so the higher level caller must be
+      * responsible which requires exposing this method.
+      */
+     void processNotifies() throws SQLException;
+ 
      //
      // Fastpath interface.
      //
Index: org/postgresql/core/v2/ProtocolConnectionImpl.java
===================================================================
RCS file:
/cvsroot/jdbc/pgjdbc/org/postgresql/core/v2/ProtocolConnectionImpl.java,v
retrieving revision 1.11
diff -c -r1.11 ProtocolConnectionImpl.java
*** org/postgresql/core/v2/ProtocolConnectionImpl.java	8 Jan 2008 06:56:27
-0000	1.11
--- org/postgresql/core/v2/ProtocolConnectionImpl.java	1 Apr 2008 07:09:39
-0000
***************
*** 62,68 ****
      }
  
      public synchronized PGNotification[] getNotifications() throws
SQLException {
-         executor.processNotifies();
          PGNotification[] array =
(PGNotification[])notifications.toArray(new
PGNotification[notifications.size()]);
          notifications.clear();
          return array;
--- 62,67 ----
Index: org/postgresql/core/v3/ProtocolConnectionImpl.java
===================================================================
RCS file:
/cvsroot/jdbc/pgjdbc/org/postgresql/core/v3/ProtocolConnectionImpl.java,v
retrieving revision 1.12
diff -c -r1.12 ProtocolConnectionImpl.java
*** org/postgresql/core/v3/ProtocolConnectionImpl.java	8 Jan 2008 06:56:27
-0000	1.12
--- org/postgresql/core/v3/ProtocolConnectionImpl.java	1 Apr 2008 07:09:39
-0000
***************
*** 65,71 ****
      }
  
      public synchronized PGNotification[] getNotifications() throws
SQLException {
-         executor.processNotifies();
          PGNotification[] array =
(PGNotification[])notifications.toArray(new
PGNotification[notifications.size()]);
          notifications.clear();
          return array;
--- 65,70 ----
Index: org/postgresql/jdbc2/AbstractJdbc2Connection.java
===================================================================
RCS file:
/cvsroot/jdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java,v
retrieving revision 1.48
diff -c -r1.48 AbstractJdbc2Connection.java
*** org/postgresql/jdbc2/AbstractJdbc2Connection.java	19 Feb 2008 06:12:24
-0000	1.48
--- org/postgresql/jdbc2/AbstractJdbc2Connection.java	1 Apr 2008 07:09:39
-0000
***************
*** 1022,1027 ****
--- 1022,1028 ----
  
      public PGNotification[] getNotifications() throws SQLException
      {
+         getQueryExecutor().processNotifies();
          // Backwards-compatibility hand-holding.
          PGNotification[] notifications =
protoConnection.getNotifications();
          return (notifications.length == 0 ? null : notifications);

--------------070908060405080402000502
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

--------------070908060405080402000502--
 




 5 Posts in Topic:
Deadlock while using getNotifications() and Statement.executeQue
joao.leal@[EMAIL PROTECTE  2008-03-24 17:58:06 
Re: Deadlock while using getNotifications() and Statement.execut
joao.leal@[EMAIL PROTECTE  2008-03-25 15:16:15 
Re: Deadlock while using getNotifications() and
books@[EMAIL PROTECTED]   2008-03-25 16:11:52 
Re: Deadlock while using getNotifications() and Statement.execut
joao.leal@[EMAIL PROTECTE  2008-03-26 10:19:38 
Re: Deadlock while using getNotifications() and Statement.execut
books@[EMAIL PROTECTED]   2008-04-01 01:22:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Sep 6 15:23:18 CDT 2008.