Sudden semi-deterministic disconnection between queries

From: Peter Schuller <peter(dot)schuller(at)infidyne(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Sudden semi-deterministic disconnection between queries
Date: 2004-03-10 07:34:51
Message-ID: 200403100834.51880.peter.schuller@infidyne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I have a difficult-to-debug problem. I will try to keep this as brief as
possible without leaving things out. In a certain situation my application
fails with:

org.postgresql.util.PSQLException: Connection is closed. Operation is not
permitted.

After some debugging I realized that this would happen on the first query,
regardless of what it is, *after* a specific previous query. In other words:

query1
query2
...
queryN <- seems to cause the failure
queryN+1 <- failure

queryN *seemingly* completes successfully without any error messsage, but then
I get the above error when executing queryN+1.

By commenting out N+1 in my code I would get the error on the next query
instead. By not running N at all, there are no errors.

queryN is simple:

INSERT
INTO email (from_header, to_header, subject_header, body)
VALUES (?, ?, ?, ?)

Note that the error *always* appears on the query executed immediately after
the above query - *however* it does not happen on all queries. At first I saw
this happening every now and then but I now have a reproducable situation
where I do something which triggers 10 E-Mails to be inserted into the
database. Exactly after which message it fails seems to vary - so far I've
seen it fail on the third and sevenths iteration.

The first thing I did was to upgrade the JDBC driver to the latest stable
version for 7.4 on jdbc.postgresql.org. Then I upgraded PostgreSQL from 7.3.4
to the latest 7.4 release (with a dump/reload of the database).

Unfortunately the code depends on a lot of other things and all database
access is going through a middle layer I wrote, so I can't produce a simple
few-line example which demonstrates the problem.

* All queries are running in a transaction with SERIALIZABLE isolation level.
* All queries are definitely executed on the same connection - I have verified
this in case there was some bug in my middle layer that would cause
it to suddently switch to another (perhaps stale) connection.

Does anyone have any suggestions at all of what might cause this, or how I
might debug further? Can I make postgresql do extremely verbose logging
somehow? For example, if the postmaster is intentionally closing the
connection it would be interesting to know why.

Someone on IRC suggested the server might be segfaulting, but I don't know of
a good way to check for this.

Thanks!

--
/ Peter Schuller, InfiDyne Technologies HB

PGP userID: 0xE9758B7D or 'Peter Schuller <peter(dot)schuller(at)infidyne(dot)com>'
Key retrieval: Send an E-Mail to getpgpkey(at)scode(dot)org
E-Mail: peter(dot)schuller(at)infidyne(dot)com Web: http://www.scode.org

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2004-03-10 07:40:14 Re: C locale
Previous Message Bobbie van der Westhuizen 2004-03-10 07:24:55 updates (postgreSQL) very slow