Perl DBD and an alarming problem

From: "Craig A(dot) James" <cjames(at)modgraph-usa(dot)com>
To:
Cc: Pgsql-Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Perl DBD and an alarming problem
Date: 2005-11-16 20:59:21
Message-ID: 437B9DA9.2030806@modgraph-usa.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message mudfoot 2005-11-16 21:03:37 Re: Hardware/OS recommendations for large databases (
Previous Message Ron 2005-11-16 20:57:20 Re: Hardware/OS recommendations for large databases