Long-running CGI + Mozilla 1.2.1 = Inifnity

samtregar on 2003-06-16T23:06:12

I spent most of today tracking a very ellusive bug. Basically, another developer reported that when he tried to publish a story through our CMS the CGI entered into an infinite loop which lasted until he killed the server. He described the story he was trying to publish and even sent me a dump. Try as I might, I couldn't get anything but success on my machine.

Finally, in desperation, I took over his machine while he went to lunch. I inserted some debugging code and tailed all the logs. That's when I found it. Here's how it works:

  1. The request comes in to the publish CGI.
  2. The publish process takes a long time (this machine is much slower than mine).
  3. Apache times out the request and issues a "read script header timed out" error in the logs.
  4. The web browser (Mozilla 1.2.1) decides that since it got an empty result it should retry the request. Back to step 1!

The reason I couldn't trigger the problem is that my machine is too fast. I never got the timeout from Apache. Also, it seems that my version of Mozilla (1.3) doesn't retry requests after getting an empty response. At this point I was totally stunned. It never occured to me that the problem could be in the browser!

My solution was to modify the long-running CGI to produce a progress bar as it runs. This ensures that Apache never times out and also keeps the user from getting too bored. I'd planned to do this anyway but it was low on the todo list.

Bug hunting is tiring, but you just can't beat the exhilaration of killing the tough ones!

-sam


Still boring

Juerd on 2003-06-17T06:39:04

> and also keeps the user from getting too bored.

Progress bars are not exciting. :)

It's probably a better idea to supply links to comic sites instead :)