Advertisement

08.04.2008 at 04:30PM PDT, ID: 23620769 | Points: 250
[x]
Attachment Details

Reliable Timeout for DBI and mysql

Asked by Andr6w in Perl Programming Language, MySQL Server, Berkeley DB

Tags: ,

Hello Esteemed Code Friends

It's been a while since I try to set up a reliable timeout for our site's search engine. I've noticed that there's some issue with simple alarm calls not working because of "unsafe signals". So I heard that the solution is this DBIx::Timeout module.
http://search.cpan.org/~samtregar/DBIx-Timeout-1.01/lib/DBIx/Timeout.pm

But 2 problems:
1) It doesn't seem to trigger the alarm either
2) There's some caveat that worries me, described below. I'm running this on a mod_perl script, so this is problematic.

"If the child process wakes up it kills the parent's DB thread and  exits with a code so the parent knows it was timed out. NOTE: After this call your database connection may be killed even if no timeout occurred. This is due to a race condition - the child may wake up just as parent process finishes. Patches addressing this bug are welcome. Until this is fixed you should be ready to reconnect after call_with_timeout()."

Any better ideas?

Thanks

Andr6w



Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
#########################
# Start of timeout #####
use DBIx::Timeout;
 
  # run code() for a maximum of 1 second, doing work with $dbh
  local our $ok = DBIx::Timeout->call_with_timeout(
    dbh     => $dbh,
    code    => sub { 
    
       $sth->execute( );
    
    },
    timeout => 1
  );
 
  # handle the result
  if (!$ok) {
    die "You ran out of time!";
  }
 
#########################
# End of timeout ########
[+][-]08.04.2008 at 09:16PM PDT, ID: 22158105

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.05.2008 at 03:53PM PDT, ID: 22165823

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.05.2008 at 09:20PM PDT, ID: 22167106

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628