pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Maciek Sakrejda <msakrejda@truviso.com>
To: PG-JDBC Mailing List <pgsql-jdbc@postgresql.org>
Subject: COPY: leaked lock on connection drop
Date: Tue, 31 May 2011 19:36:21 -0700
Message-ID: <BANLkTimRR-zyjCiQ_MzTQLETCe3zLGLixQ@mail.gmail.com> (raw)

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



Message-ID: <BANLkTimRR-zyjCiQ_MzTQLETCe3zLGLixQ@mail.gmail.com>
Permalink:  ../BANLkTimRR-zyjCiQ_MzTQLETCe3zLGLixQ@mail.gmail.com/
Also on:    postgresql.org/message-id/BANLkTimRR-zyjCiQ_MzTQLETCe3zLGLixQ@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: msakrejda@truviso.com
  Subject: Re: COPY: leaked lock on connection drop
  In-Reply-To: <BANLkTimRR-zyjCiQ_MzTQLETCe3zLGLixQ@mail.gmail.com>
  References: <BANLkTimRR-zyjCiQ_MzTQLETCe3zLGLixQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox