My Infinite Loop
I had a small spot of panic earlier this week when a customer reported that their account page on WonderProxy was timing out. The panic intensified when I was readily able to replicate the issue: the script was timing out, and completely failing to display any account information.
I've worked on many poorly performing pages in the past, often to great success: that's not the source of the panic. My real concern was that there was no reason for the page to take that long to generate. We switched over to generating the account information automatically every hour (after our billing updates) to ensure that those pages would build fast. That was unfortunately a large chunk of code I didn't want to try to debug quickly.
Fortunately the problem was much more benign: a small infinite loop!
We've got a small block of code that determines when a user's billing period starts and ends. It accepts a start date (that could be some number of months back), calculates an end date, and keeps adding a month until *now* occurs between the start and end dates.
When the account in question was configured (tragically, by me) the start date was set in the future. So my loop obligingly kept looking forever.
A quick database tweak later and the user's account was fixed, and I had a few sanity checks to add.