Statement Timeout and Locking

From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Statement Timeout and Locking
Date: 2005-04-28 10:28:48
Message-ID: 4270BAE0.1020402@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

Hello,

In one of our maintainance apps that shuffles some data across
independent databases, we need to enshure data consistency, and decided
to do this by acquiring a lock in the target database. Now we do not
want the application to wait indefinitely for this lock, but fail and
complain loudly whenever locking fails.

When using the SQL statement
SET statement_timeout TO 5000; LOCK TABLE exampletable IN EXCLUSIVE
MODE; SET statement_timeout TO DEFAULT;
in psql, everything works fine. If someone else has the lock, it aborts with
ERROR: canceling query due to user request
after waiting 5 seconds.

However, the attached java file shows a different behaviour, it seems to
wait forever (at least it waited three minutes, and I'll keep it running
over lunch).

I use PostgreSQL 8.0 JDBC3 with SSL (build 311) and a debian PostgreSQL
7.4.7-5 server.

Does someone have an explanation for this, or even better, a fix or
workaround?

Markus

Attachment Content-Type Size
LockTest.java text/x-java 719 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2005-04-28 11:55:14 Re: [HACKERS] Increased company involvement
Previous Message Thomas Hallgren 2005-04-28 07:35:16 Re: Increased company involvement

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2005-04-28 12:11:42 Announcement pgj2ee project on pgfoundry
Previous Message Thomas O'Dowd 2005-04-28 09:25:20 Re: Array support