Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 12023B5FEFB for ; Wed, 1 Jun 2011 00:35:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 22018-08 for ; Wed, 1 Jun 2011 03:35:15 +0000 (UTC) X-Greylist: delayed 00:27:32.085107 by SQLgrey-1.7.6 Received: from mail-yw0-f46.google.com (mail-yw0-f46.google.com [209.85.213.46]) by mail.postgresql.org (Postfix) with ESMTP id CBA12B5FDC3 for ; Wed, 1 Jun 2011 00:35:15 -0300 (ADT) Received: by ywe9 with SMTP id 9so2088920ywe.19 for ; Tue, 31 May 2011 20:35:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.151.99.21 with SMTP id b21mr5910570ybm.57.1306895781080; Tue, 31 May 2011 19:36:21 -0700 (PDT) Received: by 10.147.83.16 with HTTP; Tue, 31 May 2011 19:36:21 -0700 (PDT) Date: Tue, 31 May 2011 19:36:21 -0700 Message-ID: Subject: COPY: leaked lock on connection drop From: Maciek Sakrejda To: PG-JDBC Mailing List Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/1 X-Sequence-Number: 21925 This is something of a degenerate error, but it's worth documenting on the list, if nothing else. Take the following scenario: 1. JDBC user starts COPY, COPY acquires query execution lock in QueryExecutorImpl 2. Connection dies, and writeToCopy gets an IOException; note that query execution lock is not released 3. User catches exception; attempts to use the connection again (e.g., to issue a ROLLBACK) 4. The driver waits indefinitely on the query execution lock I have not confirmed this, but the query execution lock management that was put in for COPY does not seem to account for exception handling in the QueryExecutorImpl. As far as I can see, this is never a problem in normal operation--only when the connection dies. A potential workaround is to use getSQLState() to check the type of error, and only attempt to use the connection if it's still live. The proper fix would be to manage locking and unlocking more carefully with respect to exception handling. --- Maciek Sakrejda | System Architect | Truviso 1065 E. Hillsdale Blvd., Suite 215 Foster City, CA 94404 (650) 242-3500 Main www.truviso.com