in reply to help with afork and dbi
With that said, your problem is described in http://search.cpan.org/~timb/DBI-1.616/DBI.pm#InactiveDestroy. When you fork, each copy of your process winds up talking over the same database connection. So the database gets both talking to it at once, and when the parent says, "Disconnect now", it does. Which means that the child is now talking to a database that is no longer listening.
The usual fix is to have the connection happen after the fork. Alternately you can set InactiveDestroy to false, and be very, very careful to only ever use the database connection from one copy of the process. (Because if 2 copies are reading and writing to the same connection at the same time, the database is going to become very confused.)
|
|---|