As WizardOfUz suggested, double-check that your children aren't sharing the parent's DB connection and then closing it out from under the parent's feet.
If that's not the issue, try setting: $dbh->{mysql_auto_reconnect} = 1;
after opening your connection. | [reply] [d/l] |
| [reply] |
I printed dbh and it gives different mysql_thread_id. Doesn't it mean that they are different connections?
If I am wrong how do i find out whether they are the same connection or not.
| [reply] |
Look at your code. When you create a DBI connection and fork() after that, your child processes will try to use the DBI connection from the parent, and usually fail miserably. Create the connection after fork()ing, not before. If you need a connection before you fork(), close it before calling fork().
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
| [reply] |
If you grab the SVN version of Rose::DB, which is thread- and fork-safe, it should automatically handle this situation for you. (These changes will go out in the next CPAN release of Rose::DB.) | [reply] |
| [reply] |
Instead of forking child process for every web request, and consequently establishing new connection to MySQL, you can use some event oriented framework like AnyEvent::HTTP, POE::Component::Client::HTTP, or just Event or EV and perform all requests in single process.
| [reply] |