04 Apr 2012, 08:00

DBI_TRACE

Share

If you happen to encounter strange DBI-connection-lost issues, like me, it’s worth to try out DBI_TRACE! DBI_TRACE=2=dbitrace.log perl yourdbiscript.pl

This will write a very, very, detailed and helpful logfile to the current directory. Helped me to identify a nasty fork()ing related bug.

For the record: I was experiencing some strange “connection to mysql server lost” issues with a single thread script (no forking either). After some time a colleague pointed me to the DBI_TRACE documentation and I found out that I was incorrectly using some library that did some work in a fork(). The problems began when this fork was finished since it closed all filehandles, including the one to the database server.