[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] CAP::DBH + FastCGI: persistent DB connections, please


From: Cees Hek <suppressed>
>
>That seems like lots more code for something that you already
acknowledge rarely happens.  Seems like more room for error to me...

It's just a common routine. The code that's executed after every DBH funcion is simply "if ($@)".  If the common routine is called it is passed the dbh, the statement handle, retry count, reference to the prepare statement, etc. It performs common processing to connect, prepare, undef/reprepare, undef/reconnect, etc. This way, I don't have to test if the connection is alive (when I expect it to be by default), or test if the statement is prepared (when I expect it to be by default).

It's not that a ping is so bad. But, I've found that error testing is still required. So, it's not like I can eliminate ugly error testing with a ping. Like you said, something could go wrong where the ping works but the execution fails. A richer error handling routine can undef everything, reconnect and reprepare, and retry the execution (4-5 times). Potentially hiding even the rarest of errors. Whether that's a side benefit of eliminating needless pings, or eliminating needless pings is a side benefit of effective error handling is debateable. :)

It's worked well for me. I like it because all the processing can be structured for the best case (anticipated) circumstance. Not only do I not have to ping the database connection, but I don't have to test if the statement has been prepared. If it hasn't, the failure is sent to the common db error handling routine and the prepare is executed there (via the reference to the subroutine containing the prepare). After the initial connection and prepare, it's fast. But, it's setup to catch the worst case condition (a rare failure like you mentioned) and retry it. 

Mark


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.