- I favorited a YouTube video — Microsoft .NET vs Java – trailer [HD] http://youtu.be/fzza-ZbEY70?a #
- I favorited a YouTube video — Gov 2.0 Expo 2010: Mary Davie, "Smarter and Better Acqu… http://youtu.be/fsCseVMJwNM?a #
- I just discovered database schema management tool built into CakePHP. Awesome stuff! http://bit.ly/c2fFvE #
Month: July 2010
The saga of a lost connection
I came across an interesting problem at work a couple of days ago. Â One of our CakePHP-based applications has a scheduled task (cronjob) that runs every minute and imports mail from a number of IMAP mailboxes into the database. Â All of a sudden the script broke. Â In a very particular way. Â Not a single line of code was change in the script itself, and there were no significant changes in the rest of the application that the script is using. Â But one day, for some reason, it started to import emails from only half of the mailboxes, completely ignoring the rest.
A lengthy midnight drunk debugging session helped to realize the problem. Â Apparently, in the list of mailboxes to check there were a few old mailboxes, which were not used anymore for any email. Â The script was checking them but they were always empty. Â Server administrator removed those mailboxes during a scheduled maintenance window. Â Now, the script couldn’t connect to the mailbox anymore. Â No problem, there was error handling for this case. Â But was error handling didn’t take into account is the combination of time it takes timeout on the non-existing mailbox check and the database connection timeout.
It so happened, that these few old mailboxes were right in the middle of the list of all mailboxes. Â The script was importing mail from the first few mailboxes just fine. Â But then while it was taking a long time to timeout on a few non-existing mailboxes, the database connection got closed due to the inactivity timeout. Â This wasn’t handled properly. Â The script was only checking for the existing database connection at the beginning, when it was opening the connection – not later on. Â As the result, nothing could have been imported from the rest of the mailboxes.
As always, once you know the problem, you also know how to fix it or work around it. Â But troubleshooting a problem like this is tricky. Â Seeing the queries working for one mailbox and not working for another is disorienting at least. Â Having no recent changes to the application doesn’t help either. Â And the problem being not in the code itself, but in the resources is also not very obvious.
So, here you go. Â If you ever have a weird problem like that – check that your resources (database connection, network connection, file handler) are still available to you.
Day in brief
- I favorited a YouTube video — Panorama from Times Building, New York http://youtu.be/DOxZa7s4Dv4?a #
- I favorited a YouTube video — Brittany Murphy , Oakenfold P – Faster Kill Pussycat http://youtu.be/uk3Z__7ItJY?a #
- I miss Brittany Murphy. She was hot. And her smile was awesome. Sad. #
- I favorited a YouTube video — House Bloopers http://youtu.be/4T0lT8gJFO0?a #
- I want a new phone. And it should be Android. But with version 2.2 Froyo. Any devices for sale in Europe? Cyprus? Limassol? How much? #
- Got a new dedicated server from Leaseweb for one year. Awesome #hosting Immediate setup and cheap (not horribly expensive at least). #
Day in brief
- If it's not on YouTube, it's not a video! #
- My first ever edit to BestPractical RT3 wiki.Improved AutoSetOwnerForQueue scrip – http://bit.ly/cSqSTg #
- I favorited a YouTube video — The 100 Greatest Movie Insults of All Time http://youtu.be/PSEYXWmEse8?a #