Re: Perl DBD and an alarming problem

Поиск
Список
Период
Сортировка
От Craig A. James
Тема Re: Perl DBD and an alarming problem
Дата
Msg-id 437CF055.6020602@modgraph-usa.com
обсуждение исходный текст
Ответ на Re: Perl DBD and an alarming problem  (Michael Fuhr <mike@fuhr.org>)
Ответы Re: Perl DBD and an alarming problem  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-performance
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
allthe books and web references said that was how to do it. :-).  I've used alarm() with Perl (with a 3rd-party C lib
thathad 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
foundin the documentation that I can do "set statement_timeout = xxx" from PerlDBI on a per-client basis, and that
works.

Craig

В списке pgsql-performance по дате отправления:

Предыдущее
От: David Boreham
Дата:
Сообщение: Re: Hardware/OS recommendations for large databases (
Следующее
От: William Yu
Дата:
Сообщение: Re: Hardware/OS recommendations for large databases (