DBIx::Timeout 1.01 review

Download
by rbytes.net on

DBIx::Timeout is a Perl module that provides a safe method of timing out DBI requests. The method described in the DBI documentati

License: Perl Artistic License
File size: 5K
Developer: Sam Tregar
0 stars award from rbytes.net

DBIx::Timeout is a Perl module that provides a safe method of timing out DBI requests.

The method described in the DBI documentation uses unsafe signals, which may cause memory corruption. DBIx::Timeout instead uses a separate timeout process.

The problem with using POSIX sigaction() is that it relies on unsafe signals to work. Unsafe signals are well known to cause instability. For example, imagine your DB client code is in the middle of updating some global state when the signal arrives. That global state could be left in an inconsitent state, just wait for the next time it is needed to cause problems. Since this will likely occur far from the cause, and only ocur rarely, it can be a very difficult problem to track down.

Instead, this module:

- Forks a child process which sleeps for $timeout seconds.
- Runs your long-running query in the parent process.
- If the parent process finishes first it kills the child and returns.
- 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().

Requirements:
Perl

DBIx::Timeout 1.01 search tags