pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedERROR: canceling query due to user request
22+ messages / 6 participants
[nested] [flat]
* ERROR: canceling query due to user request
@ 2004-09-07 11:33 Tore Halset <halset@pvv.ntnu.no>
0 siblings, 3 replies; 22+ messages in thread
From: Tore Halset @ 2004-09-07 11:33 UTC (permalink / raw)
To: pgsql-general@postgresql.org
Hello.
I am trying to port an old java application from MS SQL Server to
PostgreSQL running on Mac OS X. I have access to the java source code
and can make modifications. I have tried with PostgreSQL version 7.4.2
and 8.0.0beta2, but get the same error. I am using pgdev.305.jdbc3.jar
for 8.0.0beta2. The PostgreSQL installation are standard, except for
log_statement = 'all' to debug this problem.
The problem is that the server returns "ERROR: canceling query due to
user request" on some of the queries. I do not find any (other) signs
of small timeouts or that the query could be cancelled in the java
client. I have tried the queries from the psql promt, and they are all
pretty fast. Where should I start looking? Are there any more debug
flags than log_statement that should be turned on?
Regards,
- Tore.
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2004-09-07 13:11 Paul Thomas <paul@tmsl.demon.co.uk>
parent: Tore Halset <halset@pvv.ntnu.no>
2 siblings, 1 reply; 22+ messages in thread
From: Paul Thomas @ 2004-09-07 13:11 UTC (permalink / raw)
To: Tore Halset <halset@pvv.ntnu.no>; +Cc: pgsql-general@postgresql.org
On 07/09/2004 12:33 Tore Halset wrote:
> Hello.
>
> I am trying to port an old java application from MS SQL Server to
> PostgreSQL running on Mac OS X. I have access to the java source code and
> can make modifications. I have tried with PostgreSQL version 7.4.2 and
> 8.0.0beta2, but get the same error. I am using pgdev.305.jdbc3.jar for
> 8.0.0beta2. The PostgreSQL installation are standard, except for
> log_statement = 'all' to debug this problem.
>
> The problem is that the server returns "ERROR: canceling query due to
> user request" on some of the queries. I do not find any (other) signs of
> small timeouts or that the query could be cancelled in the java client. I
> have tried the queries from the psql promt, and they are all pretty fast.
> Where should I start looking? Are there any more debug flags than
> log_statement that should be turned on?
It sounds to my like your Java app is issueing the cancel.
--
Paul Thomas
+------------------------------+-------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for Business |
| Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+-------------------------------------------+
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2004-09-07 14:46 Mr Pink <mr_pink_is_the_only_pro@yahoo.com>
parent: Tore Halset <halset@pvv.ntnu.no>
2 siblings, 0 replies; 22+ messages in thread
From: Mr Pink @ 2004-09-07 14:46 UTC (permalink / raw)
To: Tore Halset <halset@pvv.ntnu.no>; pgsql-general@postgresql.org
Hi,
We were getting that problem on an old, low spec server that we know has memory problems. The
error message occured only on larger jobs, such as restoring a large table.
IIRC, I got the same problem last year after messing around with postgres config parameters,
probably also a memory issue since it went away when I reset my parameters to more reasonable
settings.
The server log may have some information.
I hope this gives you some clue as to where to start looking for your problem.
regards
Mr Pink
--- Tore Halset <halset@pvv.ntnu.no> wrote:
> Hello.
>
> I am trying to port an old java application from MS SQL Server to
> PostgreSQL running on Mac OS X. I have access to the java source code
> and can make modifications. I have tried with PostgreSQL version 7.4.2
> and 8.0.0beta2, but get the same error. I am using pgdev.305.jdbc3.jar
> for 8.0.0beta2. The PostgreSQL installation are standard, except for
> log_statement = 'all' to debug this problem.
>
> The problem is that the server returns "ERROR: canceling query due to
> user request" on some of the queries. I do not find any (other) signs
> of small timeouts or that the query could be cancelled in the java
> client. I have tried the queries from the psql promt, and they are all
> pretty fast. Where should I start looking? Are there any more debug
> flags than log_statement that should be turned on?
>
> Regards,
> - Tore.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
__________________________________
Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now.
http://messenger.yahoo.com
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2004-09-07 14:54 Tom Lane <tgl@sss.pgh.pa.us>
parent: Tore Halset <halset@pvv.ntnu.no>
2 siblings, 1 reply; 22+ messages in thread
From: Tom Lane @ 2004-09-07 14:54 UTC (permalink / raw)
To: Tore Halset <halset@pvv.ntnu.no>; +Cc: pgsql-general@postgresql.org
Tore Halset <halset@pvv.ntnu.no> writes:
> I am trying to port an old java application from MS SQL Server to
> PostgreSQL running on Mac OS X.
> ...
> The problem is that the server returns "ERROR: canceling query due to
> user request" on some of the queries.
The proximate cause of this has to be that something is sending SIGINT
to the backend process that's running the query. You'll have to look
around for reasons for that to happen, if you're sure that your client
code isn't doing it. A couple of possibilities come to mind:
1. You accidentally typed ^C on the terminal window the postmaster was
launched from.
2. The postmaster was launched under non-infinite resource limits
(ulimit settings) and whatever enforces that on OS X does it by sending
SIGINT rather than the more standard signals for such things. Do the
SIGINTs come at predictable times, such as when the backend has
accumulated X amount of runtime?
This isn't the first time I've heard of unexpected SIGINTs being
delivered on OS X. (I vaguely recall seeing the MySQL guys complaining
of just that.) I have not seen it happen in my own testing, though,
so I'm not sure what's going on. Let us know if you find the cause.
regards, tom lane
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2004-09-07 16:08 Tore Halset <halset@pvv.ntnu.no>
parent: Paul Thomas <paul@tmsl.demon.co.uk>
0 siblings, 0 replies; 22+ messages in thread
From: Tore Halset @ 2004-09-07 16:08 UTC (permalink / raw)
To: pgsql-general@postgresql.org
On Sep 7, 2004, at 15:11, Paul Thomas wrote:
> It sounds to my like your Java app is issueing the cancel.
Something fishy is going on here as the application is very stable
under MS SQL Server. I have tried to set log_statement to 'all'. All
queries are displayed, but everything looks ok except for the error
message. Are there any other debug flags that I should try? I want to
see all trafic between the java app and postgresql.
Regards,
- Tore.
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2004-09-07 16:23 Tore Halset <halset@pvv.ntnu.no>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 22+ messages in thread
From: Tore Halset @ 2004-09-07 16:23 UTC (permalink / raw)
To: pgsql-general@postgresql.org
On Sep 7, 2004, at 16:54, Tom Lane wrote:
> Tore Halset <halset@pvv.ntnu.no> writes:
>> I am trying to port an old java application from MS SQL Server to
>> PostgreSQL running on Mac OS X.
>> ...
>> The problem is that the server returns "ERROR: canceling query due to
>> user request" on some of the queries.
>
> The proximate cause of this has to be that something is sending SIGINT
> to the backend process that's running the query. You'll have to look
> around for reasons for that to happen, if you're sure that your client
> code isn't doing it. A couple of possibilities come to mind:
>
> 1. You accidentally typed ^C on the terminal window the postmaster was
> launched from.
No. The same PostgreSQL server are serving other java clients without
problems. It is all running on my PowerBook.
> 2. The postmaster was launched under non-infinite resource limits
> (ulimit settings) and whatever enforces that on OS X does it by sending
> SIGINT rather than the more standard signals for such things. Do the
> SIGINTs come at predictable times, such as when the backend has
> accumulated X amount of runtime?
I have not changed any ulimit settings in the OS and have not changed
anything besides the log_statement in postgresql.conf.
I need to debug all of the trafic between the server and the client to
track down this problem.
Regards,
- Tore.
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2004-09-07 18:03 Tom Lane <tgl@sss.pgh.pa.us>
parent: Tore Halset <halset@pvv.ntnu.no>
0 siblings, 1 reply; 22+ messages in thread
From: Tom Lane @ 2004-09-07 18:03 UTC (permalink / raw)
To: Tore Halset <halset@pvv.ntnu.no>; +Cc: pgsql-general@postgresql.org
Tore Halset <halset@pvv.ntnu.no> writes:
> I need to debug all of the trafic between the server and the client to
> track down this problem.
I suspect that it's got nothing at all to do with the traffic between
the server and the client, and that the SIGINT is coming from some
outside agency. However, if you want to be sure about it, set the
postmaster's log_min_messages to DEBUG2, and then the next time the
problem happens, look in the postmaster log to see if you see anything
about
processing cancel request: sending SIGINT to process %d
regards, tom lane
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2004-09-08 07:07 Tore Halset <halset@pvv.ntnu.no>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 22+ messages in thread
From: Tore Halset @ 2004-09-08 07:07 UTC (permalink / raw)
To: pgsql-general@postgresql.org
On Sep 7, 2004, at 20:03, Tom Lane wrote:
> I suspect that it's got nothing at all to do with the traffic between
> the server and the client, and that the SIGINT is coming from some
> outside agency. However, if you want to be sure about it, set the
> postmaster's log_min_messages to DEBUG2, and then the next time the
> problem happens, look in the postmaster log to see if you see anything
> about
> processing cancel request: sending SIGINT to process %d
Yes, you are correct. I added the debug flag and reproduced the
problem. This was written to the log:
<2004-09-08 08:55:43 CEST 413eacee.3402>DEBUG: processing cancel
request: sending SIGINT to process 13311
<2004-09-08 08:55:43 CEST >DEBUG: server process (PID 13314) exited
with exit code 0
<2004-09-08 08:55:43 CEST 413eace4.33ff>ERROR: canceling query due to
user request
<2004-09-08 08:55:43 CEST >DEBUG: forked new backend, pid=13315
socket=60
<2004-09-08 08:55:43 CEST 413eacef.3403>DEBUG: processing cancel
request: sending SIGINT to process 13311
Are the OS sending the SIGINT to PostgreSQL or are postmaster sending
it to one of its child?
Regards,
- Tore.
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2004-09-08 09:25 Tore Halset <halset@pvv.ntnu.no>
parent: Tore Halset <halset@pvv.ntnu.no>
1 sibling, 1 reply; 22+ messages in thread
From: Tore Halset @ 2004-09-08 09:25 UTC (permalink / raw)
To: pgsql-general@postgresql.org
On Sep 8, 2004, at 9:07, Tore Halset wrote:
> On Sep 7, 2004, at 20:03, Tom Lane wrote:
>
>> I suspect that it's got nothing at all to do with the traffic between
>> the server and the client, and that the SIGINT is coming from some
>> outside agency. However, if you want to be sure about it, set the
>> postmaster's log_min_messages to DEBUG2, and then the next time the
>> problem happens, look in the postmaster log to see if you see anything
>> about
>> processing cancel request: sending SIGINT to process %d
>
> Yes, you are correct. I added the debug flag and reproduced the
> problem. This was written to the log:
>
> <2004-09-08 08:55:43 CEST 413eacee.3402>DEBUG: processing cancel
> request: sending SIGINT to process 13311
> <2004-09-08 08:55:43 CEST >DEBUG: server process (PID 13314) exited
> with exit code 0
> <2004-09-08 08:55:43 CEST 413eace4.33ff>ERROR: canceling query due to
> user request
> <2004-09-08 08:55:43 CEST >DEBUG: forked new backend, pid=13315
> socket=60
> <2004-09-08 08:55:43 CEST 413eacef.3403>DEBUG: processing cancel
> request: sending SIGINT to process 13311
>
> Are the OS sending the SIGINT to PostgreSQL or are postmaster sending
> it to one of its child?
I installed beta2 on a local linux box instead and now everything is
working :/ Something must trigger Mac OS X to send those evil SIGINTs.
Regards,
- Tore.
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2004-09-08 13:02 Tore Halset <halset@pvv.ntnu.no>
parent: Tore Halset <halset@pvv.ntnu.no>
0 siblings, 0 replies; 22+ messages in thread
From: Tore Halset @ 2004-09-08 13:02 UTC (permalink / raw)
To: pgsql-general@postgresql.org
On Sep 8, 2004, at 11:25, Tore Halset wrote:
> I installed beta2 on a local linux box instead and now everything is
> working :/ Something must trigger Mac OS X to send those evil SIGINTs.
Will it happens on the linux box as well, but not that often. Grr.
- Tore.
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2004-09-08 14:00 Tom Lane <tgl@sss.pgh.pa.us>
parent: Tore Halset <halset@pvv.ntnu.no>
1 sibling, 1 reply; 22+ messages in thread
From: Tom Lane @ 2004-09-08 14:00 UTC (permalink / raw)
To: Tore Halset <halset@pvv.ntnu.no>; +Cc: pgsql-general@postgresql.org
Tore Halset <halset@pvv.ntnu.no> writes:
> On Sep 7, 2004, at 20:03, Tom Lane wrote:
>> I suspect that it's got nothing at all to do with the traffic between
>> the server and the client, and that the SIGINT is coming from some
>> outside agency.
> Yes, you are correct.
No, I'm not ;-)
> I added the debug flag and reproduced the
> problem. This was written to the log:
> <2004-09-08 08:55:43 CEST 413eacee.3402>DEBUG: processing cancel
> request: sending SIGINT to process 13311
This is a smoking gun: your client *is* issuing cancel requests, whether
you know it or not. (Either that or some other process has magically
acquired the secret cancel key that was issued to your connection.)
regards, tom lane
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2004-09-09 07:15 Tore Halset <halset@pvv.ntnu.no>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 22+ messages in thread
From: Tore Halset @ 2004-09-09 07:15 UTC (permalink / raw)
To: pgsql-general@postgresql.org; +Cc: pgsql-jdbc
On Sep 8, 2004, at 16:00, Tom Lane wrote:
> This is a smoking gun: your client *is* issuing cancel requests,
> whether
> you know it or not. (Either that or some other process has magically
> acquired the secret cancel key that was issued to your connection.)
Thanks! I think I found the problem and a solution to it. The java
framework reused Statement objects and issued a st.cancel() between
every query performed with the Statement object. I just commented out
the st.cancel() line and everything seems to work ok. I googled for
others having the same problem and found this one:
http://archives.postgresql.org/pgsql-jdbc/2003-09/msg00167.php
Perhaps it is the same problem? Is this something that can be fixed in
the jdbc driver or are PostgreSQL(+jdbc) doing the right thing here?
Regards,
- Tore.
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: [JDBC] ERROR: canceling query due to user request
@ 2004-09-09 08:53 Paul Thomas <paul@tmsl.demon.co.uk>
parent: Tore Halset <halset@pvv.ntnu.no>
0 siblings, 1 reply; 22+ messages in thread
From: Paul Thomas @ 2004-09-09 08:53 UTC (permalink / raw)
To: Tore Halset <halset@pvv.ntnu.no>; +Cc: pgsql-general@postgresql.org; pgsql-jdbc
On 09/09/2004 08:15 Tore Halset wrote:
> On Sep 8, 2004, at 16:00, Tom Lane wrote:
>
>> This is a smoking gun: your client *is* issuing cancel requests, whether
>> you know it or not. (Either that or some other process has magically
>> acquired the secret cancel key that was issued to your connection.)
>
> Thanks! I think I found the problem and a solution to it. The java
> framework reused Statement objects and issued a st.cancel() between every
> query performed with the Statement object. I just commented out the
> st.cancel() line and everything seems to work ok. I googled for others
> having the same problem and found this one:
>
> http://archives.postgresql.org/pgsql-jdbc/2003-09/msg00167.php
>
> Perhaps it is the same problem? Is this something that can be fixed in
> the jdbc driver or are PostgreSQL(+jdbc) doing the right thing here?
>
> Regards,
> - Tore.
Given that statement.cancel() should only be used to cancel a running
query, I think the problem is more in your framework's misuse of cancel()
rather than in the driver itself.
--
Paul Thomas
+------------------------------+-------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for Business |
| Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+-------------------------------------------+
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: [JDBC] ERROR: canceling query due to user request
@ 2004-09-09 09:41 Oliver Jowett <oliver@opencloud.com>
parent: Paul Thomas <paul@tmsl.demon.co.uk>
0 siblings, 1 reply; 22+ messages in thread
From: Oliver Jowett @ 2004-09-09 09:41 UTC (permalink / raw)
To: Paul Thomas <paul@tmsl.demon.co.uk>; +Cc: Tore Halset <halset@pvv.ntnu.no>; pgsql-general@postgresql.org; pgsql-jdbc
Paul Thomas wrote:
> Given that statement.cancel() should only be used to cancel a running
> query, I think the problem is more in your framework's misuse of
> cancel() rather than in the driver itself.
JDBC gives you no way to ensure you only call cancel() on a running
query (there's a race between query execution returning and the call to
cancel()). Calling cancel() on a statement that's not currently
executing should do nothing; if it ends up cancelling a future query,
it's a driver bug.
-O
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: [JDBC] ERROR: canceling query due to user request
@ 2004-09-09 10:42 Paul Thomas <paul@tmsl.demon.co.uk>
parent: Oliver Jowett <oliver@opencloud.com>
0 siblings, 1 reply; 22+ messages in thread
From: Paul Thomas @ 2004-09-09 10:42 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: Tore Halset <halset@pvv.ntnu.no>; pgsql-general@postgresql.org; pgsql-jdbc
On 09/09/2004 10:41 Oliver Jowett wrote:
> Paul Thomas wrote:
>
>> Given that statement.cancel() should only be used to cancel a running
>> query, I think the problem is more in your framework's misuse of
>> cancel() rather than in the driver itself.
>
> JDBC gives you no way to ensure you only call cancel() on a running query
> (there's a race between query execution returning and the call to
> cancel()). Calling cancel() on a statement that's not currently executing
> should do nothing; if it ends up cancelling a future query, it's a driver
> bug.
Thanks for the explaination Oliver. Maybe there is a driver bug then?
--
Paul Thomas
+------------------------------+-------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for Business |
| Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+-------------------------------------------+
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: [JDBC] ERROR: canceling query due to user request
@ 2004-09-09 16:02 Tom Lane <tgl@sss.pgh.pa.us>
parent: Paul Thomas <paul@tmsl.demon.co.uk>
0 siblings, 2 replies; 22+ messages in thread
From: Tom Lane @ 2004-09-09 16:02 UTC (permalink / raw)
To: Paul Thomas <paul@tmsl.demon.co.uk>; +Cc: Oliver Jowett <oliver@opencloud.com>; Tore Halset <halset@pvv.ntnu.no>; pgsql-general@postgresql.org; pgsql-jdbc
Paul Thomas <paul@tmsl.demon.co.uk> writes:
> On 09/09/2004 10:41 Oliver Jowett wrote:
>> JDBC gives you no way to ensure you only call cancel() on a running query
>> (there's a race between query execution returning and the call to
>> cancel()). Calling cancel() on a statement that's not currently executing
>> should do nothing; if it ends up cancelling a future query, it's a driver
>> bug.
> Thanks for the explaination Oliver. Maybe there is a driver bug then?
IIRC there was such a bug at one time, but I thought it had been fixed.
Maybe the problem is use of an old driver?
regards, tom lane
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: [JDBC] ERROR: canceling query due to user request
@ 2004-09-09 21:04 Oliver Jowett <oliver@opencloud.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 22+ messages in thread
From: Oliver Jowett @ 2004-09-09 21:04 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Paul Thomas <paul@tmsl.demon.co.uk>; Tore Halset <halset@pvv.ntnu.no>; pgsql-general@postgresql.org; pgsql-jdbc
Tom Lane wrote:
> Paul Thomas <paul@tmsl.demon.co.uk> writes:
>
>>On 09/09/2004 10:41 Oliver Jowett wrote:
>>
>>>JDBC gives you no way to ensure you only call cancel() on a running query
>>>(there's a race between query execution returning and the call to
>>>cancel()). Calling cancel() on a statement that's not currently executing
>>>should do nothing; if it ends up cancelling a future query, it's a driver
>>>bug.
>
>
>>Thanks for the explaination Oliver. Maybe there is a driver bug then?
>
>
> IIRC there was such a bug at one time, but I thought it had been fixed.
> Maybe the problem is use of an old driver?
My patch for this never got applied, AFAIK. The current driver still
seems to send the cancellation request and continue without waiting for
an EOF from the server.
-O
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: [GENERAL] ERROR: canceling query due to user request
@ 2004-09-10 06:44 Tore Halset <halset@pvv.ntnu.no>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 22+ messages in thread
From: Tore Halset @ 2004-09-10 06:44 UTC (permalink / raw)
To: pgsql-jdbc
On Sep 9, 2004, at 18:02, Tom Lane wrote:
> IIRC there was such a bug at one time, but I thought it had been fixed.
> Maybe the problem is use of an old driver?
I am using pgdev.305.jdbc3.jar.
- Tore.
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2005-09-13 20:14 Kevin Grittner <Kevin.Grittner@wicourts.gov>
0 siblings, 1 reply; 22+ messages in thread
From: Kevin Grittner @ 2005-09-13 20:14 UTC (permalink / raw)
To: tgl@sss.pgh.pa.us; +Cc: pgsql-admin@postgresql.org
Thanks, Tom. An excellent suggestion. (This 50 year old dog has
today learned a new trick.)
There is good news and bad news. The good news is that I found
the cause, and we can keep this from happening with a change on
our end. The bad news is that I think it also points to a backend bug,
although not as serious as the potential (hypothetical) one I was
asking about earlier.
For the record (and the benefit of anyone with similar problems who
may search the archives), I got the connection pool set up, and found
the pids for the connection processes like this:
# ps aux|grep postgres
postgres 18307 0.0 0.0 3052 1100 pts/0 S Sep09 0:00 su postgres
postgres 18308 0.0 0.0 3408 1828 pts/0 S+ Sep09 0:00 bash
postgres 15463 0.0 0.1 89508 3852 pts/0 S 10:09 0:05 /usr/local/pgsql/bin/postmaster -D /var/pgsql/data
postgres 15466 0.0 4.0 89652 83004 pts/0 S 10:09 0:00 postgres: writer process
postgres 15467 0.0 0.1 7052 2796 pts/0 S 10:09 0:02 postgres: stats buffer process
postgres 15468 0.0 0.0 6388 1996 pts/0 S 10:09 0:03 postgres: stats collector process
postgres 926 0.0 0.3 90484 7576 pts/0 S 14:34 0:00 postgres: dtr dtr 165.219.88.77(4436) idle
postgres 927 0.0 0.2 89956 4684 pts/0 S 14:34 0:00 postgres: dtr dtr 165.219.88.77(4437) idle
postgres 928 3.0 1.1 90404 23764 pts/0 S 14:34 0:07 postgres: dtr dtr 165.219.88.77(4438) idle
postgres 929 2.7 1.1 90468 23260 pts/0 S 14:34 0:07 postgres: dtr dtr 165.219.88.77(4439) idle
root 935 0.0 0.0 1796 648 pts/2 S+ 14:38 0:00 grep postgres
I then established an strace session for each connection like this:
strace -tt -o strace.926 -p 926
Other flags may have been useful, but strace is new to me, so I took
the route I was sure I understood. I ran until we got an error, which
involved running through 7,278 transactions. I used Ctrl+C to stop
each strace and searched the results for SIGINT. There were 1,799
of them. They always came in a set of lines like this:
13:59:19.625498 recv(7, "P\0\0\0Y\0SELECT lcmtr.\"relationName"..., 8192, 0) = 125
13:59:19.625976 _llseek(32, 0, [0], SEEK_END) = 0
13:59:19.626057 _llseek(33, 0, [8192], SEEK_END) = 0
13:59:19.626159 _llseek(32, 0, [0], SEEK_END) = 0
13:59:19.626257 send(7, "1\0\0\0\0042\0\0\0\4T\0\0\0D\0\2relationName\0\0\0"..., 97, 0) = 97
13:59:19.626352 recv(7, 0x82b1000, 8192, 0) = ? ERESTARTSYS (To be restarted)
13:59:19.628477 --- SIGINT (Interrupt) @ 0 (0) ---
13:59:19.628559 sigreturn() = ? (mask now [])
The SELECT statement was easy to find, and it became clear that a
programmer had code which was incorrectly canceling a JDBC
Statement after reaching the end of the (empty) ResultSet. One
time out of 1,799 this was causing the error we were seeing on
the subsequent commit, which strikes me as a bug.
We've already changed the offending code to avoid the invocation
of the Statement.cancel method. Not that it merits high priority, but
it might make sense for PostgreSQL to behave more consistently on
a commit when a statement within the database transaction has been
canceled. There currently is a race condition where if the commit
comes fast enough after the Statement.cancel, it receives the error
which is the subject of this thread.
-Kevin
>>> Tom Lane <tgl@sss.pgh.pa.us> 09/13/05 1:18 PM >>>
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> I'm having a really hard time coming up with theories about the cause
> or things to check.
Have you tried strace'ing the backend process to see if you can see a
signal being delivered to it?
regards, tom lane
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: ERROR: canceling query due to user request
@ 2005-09-13 22:18 Tom Lane <tgl@sss.pgh.pa.us>
parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
0 siblings, 1 reply; 22+ messages in thread
From: Tom Lane @ 2005-09-13 22:18 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: pgsql-admin@postgresql.org; pgsql-jdbc
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> The SELECT statement was easy to find, and it became clear that a
> programmer had code which was incorrectly canceling a JDBC
> Statement after reaching the end of the (empty) ResultSet. One
> time out of 1,799 this was causing the error we were seeing on
> the subsequent commit, which strikes me as a bug.
> We've already changed the offending code to avoid the invocation
> of the Statement.cancel method. Not that it merits high priority, but
> it might make sense for PostgreSQL to behave more consistently on
> a commit when a statement within the database transaction has been
> canceled. There currently is a race condition where if the commit
> comes fast enough after the Statement.cancel, it receives the error
> which is the subject of this thread.
Yeah. The Query Cancel protocol has a potential race condition in it:
the cancel request is not synchronous with respect to your existing
connection (it's actually sent over a different connection). If you try
to send another command immediately, it's possible that the new command
gets to the backend before the cancel signal does, and then the cancel
zaps your new command instead of the one you intended.
This has been discussed before (try the pgsql-jdbc list archives).
I believe we concluded that an appropriate fix was to not consider the
cancel request "done" until the client sees the separate connection
dropped by the postmaster. libpq's cancel functions wait for that to
happen, and I thought that JDBC had been fixed as well --- maybe you are
using an old driver version?
Of course, if the internal threading in your app is such that you might
issue another command before the Statement.cancel method finishes, then
it's your own bug.
regards, tom lane
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: [JDBC] ERROR: canceling query due to user request
@ 2005-09-13 23:00 Oliver Jowett <oliver@opencloud.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 22+ messages in thread
From: Oliver Jowett @ 2005-09-13 23:00 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; pgsql-admin@postgresql.org; pgsql-jdbc
Tom Lane wrote:
> This has been discussed before (try the pgsql-jdbc list archives).
> I believe we concluded that an appropriate fix was to not consider the
> cancel request "done" until the client sees the separate connection
> dropped by the postmaster. libpq's cancel functions wait for that to
> happen, and I thought that JDBC had been fixed as well --- maybe you are
> using an old driver version?
I thought this got done too, but looking at the current JDBC driver code
I don't see it..
-O
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: [JDBC] ERROR: canceling query due to user request
@ 2005-09-15 14:22 Kevin Grittner <Kevin.Grittner@wicourts.gov>
0 siblings, 0 replies; 22+ messages in thread
From: Kevin Grittner @ 2005-09-15 14:22 UTC (permalink / raw)
To: oliver@opencloud.com; tgl@sss.pgh.pa.us; +Cc: pgsql-admin@postgresql.org; pgsql-jdbc
One more thought on the topic -- in the particular case where we hit
this, the Statement did not have any requests active on its connection.
If the driver can determine this, it could return from the cancel method
without doing anything.
-Kevin
>>> Oliver Jowett <oliver@opencloud.com> 09/13/05 6:00 PM >>>
Tom Lane wrote:
> This has been discussed before (try the pgsql-jdbc list archives).
> I believe we concluded that an appropriate fix was to not consider the
> cancel request "done" until the client sees the separate connection
> dropped by the postmaster. libpq's cancel functions wait for that to
> happen, and I thought that JDBC had been fixed as well --- maybe you are
> using an old driver version?
I thought this got done too, but looking at the current JDBC driver code
I don't see it..
-O
^ permalink raw reply [nested|flat] 22+ messages in thread
end of thread, other threads:[~2005-09-15 14:22 UTC | newest]
Thread overview: 22+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-09-07 11:33 ERROR: canceling query due to user request Tore Halset <halset@pvv.ntnu.no>
2004-09-07 13:11 ` Paul Thomas <paul@tmsl.demon.co.uk>
2004-09-07 16:08 ` Tore Halset <halset@pvv.ntnu.no>
2004-09-07 14:46 ` Mr Pink <mr_pink_is_the_only_pro@yahoo.com>
2004-09-07 14:54 ` Re: ERROR: canceling query due to user request Tom Lane <tgl@sss.pgh.pa.us>
2004-09-07 16:23 ` Re: ERROR: canceling query due to user request Tore Halset <halset@pvv.ntnu.no>
2004-09-07 18:03 ` Re: ERROR: canceling query due to user request Tom Lane <tgl@sss.pgh.pa.us>
2004-09-08 07:07 ` Re: ERROR: canceling query due to user request Tore Halset <halset@pvv.ntnu.no>
2004-09-08 09:25 ` Re: ERROR: canceling query due to user request Tore Halset <halset@pvv.ntnu.no>
2004-09-08 13:02 ` Re: ERROR: canceling query due to user request Tore Halset <halset@pvv.ntnu.no>
2004-09-08 14:00 ` Re: ERROR: canceling query due to user request Tom Lane <tgl@sss.pgh.pa.us>
2004-09-09 07:15 ` Re: ERROR: canceling query due to user request Tore Halset <halset@pvv.ntnu.no>
2004-09-09 08:53 ` Re: [JDBC] ERROR: canceling query due to user request Paul Thomas <paul@tmsl.demon.co.uk>
2004-09-09 09:41 ` Re: [JDBC] ERROR: canceling query due to user request Oliver Jowett <oliver@opencloud.com>
2004-09-09 10:42 ` Re: [JDBC] ERROR: canceling query due to user request Paul Thomas <paul@tmsl.demon.co.uk>
2004-09-09 16:02 ` Re: [JDBC] ERROR: canceling query due to user request Tom Lane <tgl@sss.pgh.pa.us>
2004-09-09 21:04 ` Re: [JDBC] ERROR: canceling query due to user request Oliver Jowett <oliver@opencloud.com>
2004-09-10 06:44 ` Re: [GENERAL] ERROR: canceling query due to user request Tore Halset <halset@pvv.ntnu.no>
2005-09-13 20:14 Re: ERROR: canceling query due to user request Kevin Grittner <Kevin.Grittner@wicourts.gov>
2005-09-13 22:18 ` Re: ERROR: canceling query due to user request Tom Lane <tgl@sss.pgh.pa.us>
2005-09-13 23:00 ` Re: [JDBC] ERROR: canceling query due to user request Oliver Jowett <oliver@opencloud.com>
2005-09-15 14:22 Re: [JDBC] ERROR: canceling query due to user request Kevin Grittner <Kevin.Grittner@wicourts.gov>
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