Practical mod_perl / HTML Book /



previous page: 20.1.5.4. Cannot find the DBI handler
  
page up: HTML Version of the book
  
next page: 20.1.5.6. Apache:DBI does not work

20.1.5.5. The morning bug


The SQL server keeps a connection to the client open for a limited period of time. In the early days of Apache::DBI, everyone was bitten by the so-called morning bug—every morning the first user to use the site received a "No Data Returned" message, but after that everything worked fine.

The error was caused by Apache::DBI returning an invalid connection handle (the server had closed it because of a timeout), and the script was dying on that error. The ping( ) method was introduced to solve this problem, but it didn't work properly until Apache::DBI Version 0.82 was released. In that version and after, ping( ) was called inside an eval block, which resolved the problem.

It's still possible that some DBD:: drivers don't have the ping( ) method implemented. The Apache::DBI manpage explains how to write it.

Another solution is to increase the timeout parameter when starting the database server. We usually start the MySQL server with the script safe_mysqld, so we modified it to use this option:

nohup $ledir/mysqld [snipped other options] -O wait_timeout=172800

The timeout value that we use is 172,800 seconds, or 48 hours. This change solves the problem, but the ping( ) method works properly in DBD::mysql as well.

 

Continue to:

  • prev: 20.1.5.4. Cannot find the DBI handler
  • Table of Contents
  • next: 20.1.5.6. Apache:DBI does not work







TOP
previous page: 20.1.5.4. Cannot find the DBI handler
  
page up: HTML Version of the book
  
next page: 20.1.5.6. Apache:DBI does not work


Menu

  • HTML Book
  • PDF Book
  • Download Code
  • Table of Contents
  • Errata
  • mod_perl2 User's Guide
  • Sitemap

Search


Add to Google




Creative Commons License


Written by
Eric Cholet (Logilune) and
Stas Bekman (StasoSphere & Free Books).


[ Privacy Policy | Terms of Use | About Us | Search ]

© 2007 StasoSphere.com