pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig A. James <cjames@modgraph-usa.com>
To: Michael Fuhr <mike@fuhr.org>
Cc: Pgsql-Performance <pgsql-performance@postgresql.org>
Subject: Re: Perl DBD and an alarming problem
Date: Thu, 17 Nov 2005 13:04:21 -0800
Message-ID: <437CF055.6020602@modgraph-usa.com> (raw)
In-Reply-To: <20051117002344.GA55377@winnie.fuhr.org>
References: <BF9F6C0E.13B4A%llonergan@greenplum.com>
	<1132136225.5711.4.camel@Panoramix>
	<437B9DA9.2030806@modgraph-usa.com>
	<20051117002344.GA55377@winnie.fuhr.org>


Thanks for the info on alarm and timeouts, this was a big help.  One further comment:

Michael Fuhr wrote:
>>  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...
> 
> 
> High-level languages' signal handlers don't always work well with
> low-level libraries...
>
> Is there a reason you're using alarm() in the client instead of
> setting statement_timeout on the server?

statement_timeout solved the problem, thanks VERY much for the pointer.  To answer your question, I use alarm() because all the books and web references said that was how to do it. :-).  I've used alarm() with Perl (with a 3rd-party C lib that had a potential infinite loop) very successfully.

So thanks for the pointer to statement_timeout.  But...

When I set statement_timeout in the config file, it just didn't do anything - it never timed out (PG 8.0.3).  I finally found in the documentation that I can do "set statement_timeout = xxx" from PerlDBI on a per-client basis, and that works.

Craig



view thread (7+ messages)  latest in thread

Message-ID: <437CF055.6020602@modgraph-usa.com>
Permalink:  ../437CF055.6020602@modgraph-usa.com/
Also on:    postgresql.org/message-id/437CF055.6020602@modgraph-usa.com

 · 

reply

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, mike@fuhr.org
  Subject: Re: Perl DBD and an alarming problem
  In-Reply-To: <437CF055.6020602@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