artemave has asked for the wisdom of the Perl Monks concerning the following question:
I have then googled for a possible workaround and found this patch to Ima::DBI :[Wed May 02 18:55:09 2007] [error] [client 127.0.0.1] DBD::mysql::db F +ETCH failed: handle 2 is owned by thread 161929c not current thread 1 +ba79ec (handles can't be shared between threads and your driver may n +eed a CLONE method added) at c:/Perl/site/lib/Apache/DBI.pm line 226. +\n
Which leads to the same result. Perhaps it is because all threads share the same process id?sub _mk_db_closure { my ($class, $dsn, $user, $pass, $attr) = @_; $attr ||= {}; my $dbh; my $process_id = $$; return sub { # set the PID in a private cache key to prevent us # from sharing one with the parent after fork. This # is better than disconnecting the existing $dbh since # the parent may still need the connection open. Note # that forking code also needs to set InactiveDestroy # on all open handles in the child or the connection # will be broken during DESTROY. $attr->{private_cache_key_pid} = $$; # reopen if this is a new process or if the connection # is bad if ($process_id != $$ or not ($dbh && $dbh->FETCH('Active') && + $dbh->ping)) { $dbh = DBI->connect_cached($dsn, $user, $pass, $attr); $process_id = $$; } return $dbh; }; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Class::DBI and mod_perl 2
by perrin (Chancellor) on May 03, 2007 at 21:07 UTC | |
by meredith (Friar) on Jun 12, 2007 at 19:01 UTC | |
by perrin (Chancellor) on Jun 12, 2007 at 19:14 UTC | |
by meredith (Friar) on Jun 12, 2007 at 19:22 UTC | |
by perrin (Chancellor) on Jun 12, 2007 at 19:37 UTC | |
Re: Class::DBI and mod_perl 2
by ides (Deacon) on May 04, 2007 at 14:47 UTC | |
by artemave (Beadle) on May 04, 2007 at 17:22 UTC |