From: | "Eric Simon" <esimon(at)theiqgroup(dot)com> |
---|---|
To: | <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Problem Using PQcancel in a Synchronous Query |
Date: | 2010-08-23 21:13:41 |
Message-ID: | B5583D9A92B841D38FDC5B3C5B8F67F7@Masterchief |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
I am using Perl (DBD::Pg) with Postgres. DBD::Pg already fully supports
asynchronous queries, and the canceling of those queries, but I need to
cancel a synchronous query. So to do that, I am trying to write
$sth->cancel() support for DBD::Pg. Here's my example in Perl:
my $aborted = 0;
my $action = POSIX::SigAction->new(
sub {$sth->cancel; $aborted = 1},
POSIX::SigSet->new(SIGALRM)
);
my $oldaction = POSIX::SigAction->new;
POSIX::sigaction(SIGALRM,$action,$oldaction);
my $sth = $dbh->prepare('SELECT id FROM user_session FOR UPDATE');
alarm(10); # wait 10 seconds before time out
$sth->execute;
alarm(0); # cancel alarm (if execute worked fast)
POSIX::sigaction(SIGALRM,$oldaction); # restore original handler
warn "warning: query timed out" if $aborted;
Now that I've established some context, here's where I'm at: I've written
$sth->cancel() for DBD::Pg using PQcancel(), and it works (it returns the
status 57014: QUERY CANCELED). The problem is that the $sth->execute call
(which resides between the two alarm() calls above) doesn't continue on, but
rather stays frozen, waiting for data. Does PQcancel not communicate back
to the execute statement so that it unblocks?
--
Eric Simon
The IQ Group, Inc.
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2010-08-23 21:30:04 | Re: Interruptible sleeps (was Re: CommitFest 2009-07: Yay, Kevin! Thanks, reviewers!) |
Previous Message | Andrew Dunstan | 2010-08-23 20:57:20 | Re: WIP: extensible enums |