Journal Entries

I'll crush you like the bug you are

Finally! I've found and fixed the memory leak we've suffered since last November.

It wasn't a bad one, but it meant that every day, we'd see a handful of database connections left hanging, which indicates that somewhere in the code someone wasn't deleting a database object properly. We could see the connections, and also see what SQL command was last executed on it, and it is this information that has, in the past, made it possible to track down these leaks. Left unchecked, these orphaned connections would mount up and eventually make it impossible to get a new connection, and the web servers would then lose contact with the database, falling back to serving cached pages. Not nice.

This latest one was a puzzle, though. Usually, the last command to go through the connection was to fetch user details, something that *every* page does at some point, so no help there. Next possibility is that a particular page was causing an access violation, thus exiting the thread and leaving the connection hanging. Trouble is, that would leave an entry in the logs, but whenever I checked, no such error was logged.

Another problem was that, sometimes, the last query wasn't user details, but was more specific - but still didn't point to a bug in the code.

Then yesterday, I was doing the usual, but this time (luckily) there were two connections very close to one another. I looked in the logs, found possible offending queries and noticed they both went to the Info page. I called up the code, and immediately spotted the problem. A database connection was created, then the code checked the cache for recently cached info (we cache it for five minutes) and if that exists it would serve that instead of doing an expensive database query for every request. The bug was that the database connection wasn't released if the cached version was served. Moving the creation of the database connection below the cache test meant everything was fine.

The fact that the connection was created but never used explains why the last query run on it was variable - I was seeing the last query run before the connection was recycled and claimed by the info code. It's also clear why it wasn't happening that much - Info isn't used a huge amount, and the bug would only happen if two people requested the page within five minutes of each other.

It'll need monitoring, but I'm really pleased to have found this one, as it's the only memory leak that I'm aware of in the code, so its removal should mean the site is much more reliable.

Discuss this Journal entry [8]

Latest reply: Mar 16, 2001

It took a while but...

... we're back! Finally.

I'm *really* sorry it took so long. But it's worth it to see that people are mostly happy to be back.

Now if we can only persuade the BBC that links in forums are actually a *good* thing...

Discuss this Journal entry [4]

Latest reply: Mar 14, 2001

See you soon...

*takes a last look around before closing the doors*

Don't worry - you'll be back up and running in no time.

smiley - sadface

Discuss this Journal entry [1]

Latest reply: Jan 25, 2001

Disappearing Journals

I'm investigating the possibility that people's Journal entries are disappearing from their personal spaces. But I've no idea how or why...

Discuss this Journal entry [1]

Latest reply: Jan 8, 2001

Testing

This is to see if journal entries are still working.

Discuss this Journal entry [1]

Latest reply: Nov 20, 2000


Back to Jim Lynn's Personal Space Home

Jim Lynn

Researcher U6

Work Edited by h2g2

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more