From: Craig A. James <cjames@modgraph-usa.com>
Cc: Pgsql-Performance <pgsql-performance@postgresql.org>
Subject: Perl DBD and an alarming problem
Date: Wed, 16 Nov 2005 12:59:21 -0800
Message-ID: <437B9DA9.2030806@modgraph-usa.com> (raw)
In-Reply-To: <1132136225.5711.4.camel@Panoramix>
References: <BF9F6C0E.13B4A%llonergan@greenplum.com>
<1132136225.5711.4.camel@Panoramix>
I am mystified by the behavior of "alarm" in conjunction with Postgres/perl/DBD. Here is roughly what I'm doing:
eval {
local $SIG{ALRM} = sub {die("Timeout");};
$time = gettimeofday;
alarm 20;
$sth = $dbh->prepare("a query that may take a long time...");
$sth->execute();
alarm 0;
};
if ($@ && $@ =~ /Timeout/) {
my $elapsed = gettimeofday - $time;
print "Timed out after $elapsed seconds";
}
Now the mystery: It works, but it hardly matters what time I use for the alarm call, the actual alarm event always happens at 26 seconds. I can set "alarm 1" or "alarm 20", and it almost always hits right at 26 seconds.
Now if I increase alarm to anything in the range of about 25-60 seconds, the actual alarm arrives somewhere around the 90 second mark. It seems as though there are "windows of opportunity" for the alarm, and it is ignored until those "windows" arrive.
Anyone have a clue what's going on and/or how I can fix it?
A secondary question: It appears that $sth->cancel() is not implemented in the Pg DBD module. Is that true?
Thanks,
Craig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: cjames@modgraph-usa.com
Subject: Re: Perl DBD and an alarming problem
In-Reply-To: <437B9DA9.2030806@modgraph-usa.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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