Re: Query was cancelled - reason?

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Guido Fiala <guido(dot)fiala(at)dka-gmbh(dot)de>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Query was cancelled - reason?
Date: 2004-07-01 11:20:58
Message-ID: 40E3F39A.8010405@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Guido Fiala wrote:
> Hello,
>
> i'am currently run into a strange problem with fast subsequent updates in the same table.
>
> The application is quite complex, so its difficult to to sent a code snippet, i included the network traffic instead:
>
> This is whats happening:

[... COMMIT gets cancelled ...]

> So why comes the commit-error?

Three possibilities I can think of:

- Something is sending SIGINT to the backend process.
- You are calling JDBC's Statement.cancel() method (see below) which
ends up sending a SIGINT (indirectly via a backend process).
- You have statement_timeout set too low; queries appear to be cancelled
if they time out.

There is (AFAIK) still a race condition in the JDBC driver's
implementation of Statement.cancel() which means that it can
occasionally cancel a query "in the future" if called just before a
query begins execution, i.e. sometimes this sort of code will result in
a cancelled query:

stmt.cancel();
stmt.executeUpdate("..."); // Could be a different statement
// on the same connection too

In your case it sounds like it might be:

stmt.executeUpdate("...");
stmt.cancel(); // Perhaps done by a connection management layer
conn.commit(); // Actually executes a query behind the scenes

I looked at fixing cancel() some time ago but my changes didn't make it
into the driver in the end.

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message John Pagakis 2004-07-01 21:47:02 Issue with now() within a transaction in pg74.213.jdbc.jar
Previous Message Markus Schaber 2004-07-01 10:03:29 Re: Performance Issues in 7.4.3