« January 2007 | Main | March 2007 »

February 28, 2007

Blogger's delight: restore a corrupted Berkeley DB in Movable Type

Here's a technical bit for all fellow bloggers who use Movable Type and haven't changed the default database backend from Berkeley DB.

The first tip is: switch to an SQL database. If you use SQLite,, you won't even need a separate database process on the server - you can install everything locally, and as CGI.

The second tip: should you ever get stuck with a dysfunctional Movable Type installation because the database is corrupted, then read on.

Berkeley DB database files seem to get corrupted quite often. This can happen when, for instance, the harddrive fills up or you exceed your quota on the server. Or when database accesses get interrupted by a server that looses power, or a server that kills processes. There are many reasons, and every one of them a motivation to switch to a better database backend.

What happened to me was that MT could not finish its background tasks any longer. A process (mt-feed.cgi) that is used to kick off such tasks was hogging all the CPU cycles on the server, and I started getting complaints from the local system administrator.

A couple of weeks ago I had noticed that MT would not list comments, trackbags or log entries any longer: "No comments could be found."

no-comments-found.png

I ignored the problem for a while, but when I got words that my MT installation was blocking the server, I decided to investigate.

I noticed that MT would clear comments from some popular entries when they were rebuild (which happens as soon as someone posts a new comment!). That sucks!

It turned out that my database was corrupted.

~:/web/data/mt/db$ db_verify comment.db 
db_verify: Page 5598: btree or recno page is of inappropriate type 0 
db_verify: Page 5593: btree or recno page is of inappropriate type 0 
db_verify: Page 9863: btree or recno page is of inappropriate type 7 
db_verify: comment.db: DB_VERIFY_BAD: Database verification failed

Various attempts to save the data using tools such as db_dump were futile. Exporting it all using MT's export function didn't work: only 90 out of 530 comments were saved, and many interesting discussions from my readers lost.

Similarly, logs were corrupted, too. I managed to export the log entries to a CSV (plain-text) file, and reset the whole log, using some trickery.

But what to do about the comments? I tried switching to an SQL database, in my case: SQLLite. (Postgres and MySQL are alternatives.) SixApart, the maker of MovableType, provides a conversion script with every MT installation: mt-db2sql.cgi. But unfortunately this script blatantly refused to convert any comments from the corrupted comment table.

I did notice, however, that I could use MT's search function on the comments - this worked just fine. The reason must have been that the search can ignore junk (spam) for comments and trackbacks. So my comments were still there!

Chances are that this is the case for other MT installations as well. Given the recent wave of comment and trackback spam, it's quite likely that corruption occurrs in junk messages. Note that junk is stored in the database, even if it doesn't make it onto your published blog. The solution was to extract the data from the comments table, not using the original mt-db2sql.cgi tool provided, but using a modified version.

Wonderful: All 530 comments rescued and all data recovered. And I've switched to SQLite in the process, so it hopefully won't happen again.

Contact me if you would like me to attempt the same for your blog. No promises though!

Posted by dr at 12:07 PM | Comments (0)

February 18, 2007

Regina Spektor makes David happy

Among the things that made me happy this Month is Regina Spektor's latest album "Begin to Hope". My friends just call her "the screaming woman", but I have to say that she screams a hell lot better than Tori Amos. And she screams so much more interestingly!

Having listened to her past albums, I'd say Begin to Hope is a little less experimental than "Songs" and a little more trying to please than "Eleven Eleven", but nonetheless strange and novel and surprising enough: Yes, her music makes me happy, but there's also enough left to discover to make me want to listen to it again. What I like: she doesn't establish one "regina" style. She's not turning something into a scheme just because it works well - every song is different, nothing follows folk patterns. A step ahead of great artists like Ani DiFranco or Björk.

Samson went back to bed
Not much hair left on his head
He ate a slice of wonder bread and went right back to bed
(Samson)


(Fidelity)

Posted by dr at 6:06 PM | Comments (0) | TrackBack

February 12, 2007

Soaring in the Scottish Alps

Easterly winds carrying damp air over the East of Scotland. The weather radio at Edinburgh airport reported "runway wet, wet, wet". It's been a bad weekend and certainly not the perfect day to get in a glider. So what does the budding glider pilot do for a Sunday evening challenge? Last night, for the first time, I've soared the Alps! The Scottish Alps.

davidxc-map.jpg

I've completed a 100k task in roughly one hour, starting at Bolzano, which is somewhere in the Italian part of the Tyrol region. Of course, it wasn't the real thing: I fired up a PC-based flight simulator dedicated to gliding. Such a thing exists, and the advantage is that you don't need "piss bottles" along with any contraptions that allow you to fill them while seated.

Let's start from the beginning. It was a competition between Andrew (r.) and me, 100 kilometers, a typical task. In the sport of gliding, flying a competition basically means that you're trying to get from A to D via B and C, often covering a few hundred kilometers on the way. And of course you're trying to do it as quickly as possible, without having to annoy a farmer by landing on his crops, a couple of miles before you get back home, because you've run out of lift.

Thanks to Condor, a flight sim software dedicated to soaring, I got to fly the latest hot ship, which will glide along efficiently and get you pretty far for each foot of height that you're going down, 42 to 1. Remember: we've got no engine. We're counting on the magic of rising air and the mystery of a strong stomach.

The tow plane drops me a couple of flight minutes before the start zone, where we officially begin the race. Before getting there, I find a strong thermal, yank the stick to the left and, with a bit of concentration, manage to stay and gain a couple of thousand feet, up to cloud base. (A thermal is a column of rising air.)

After crossing the start line, it's a breeze. The trick was to pull up and slow down when I was in rising air, speed up early enough so we could pass through sink, and only stop and circle in the strongest thermals. Glider pilots tend to have quite sophisticated equipment to tell you where and how fast to fly, GPS navigation systems connected to standard-issue PDA board computers connected to loggers, electronic variometers and battery packs. GPS is the kind of stuff used nowadays to guide the big planes to their destinations around the globe, and I'm not kidding when I say that their dedicated, certified equipment is faster, but not much more functional, and 10 times as expensive.

After some circling and navigating around beautiful ridges under the watch of my instructor Gareth, I start the final glide, zooming along at 80 knots into the valley. 40k to go, coming down from 8,000 feet. Competition finish, going low and very fast, pulling up near the club house on the airfield - not fast enough though, so the final turns back on the runway were less than elegant.

The good news of the day is that my competitor next door broke his glider on the way there by going too fast, out of boredom he says. What an excuse!

davidxc-approach.jpg
davidxc-pullup.jpg

Posted by dr at 10:49 PM | Comments (0) | TrackBack

February 4, 2007

Conquer the Autobahn: Hitch-hiking 2.0

Bad things ensued on the German Autobahn when I hit the brakes while on black ice at 70 kph in my small Mitsubishi Colt (Mirage). No, you really shouldn't brake when you're on ice. But what do you do when the guy in front slows down? He was far away. And his car was equipped with anti-blocking. Mine was not. The Mitsubishi started to spin.

The 5-second story ended on the crash barrier, luckily with no-one hurt. The 40-ton truck that followed us could pass. With me in the car were three others that I barely new, a couple of computers and lots of luggage in the trunk. That was back in February 1999.

My passengers back then didn't complain too much and were sorry for the damage. We continued our 7-hour journey across Germany from Mainz to Berlin.

Hitch-hikers have always been patient passengers - even though I picked up these hitch-hikers with one of Germany's first ride-sharing agencies. These shops matched up drivers and passengers for a fee - and as a driver, I saved on fuel money because my passengers were chipping in. Now, eight years later, ride-sharing has really taken off. Web sites such as Mitfahrgelegenheit.de list willing chauffeurs, often dozens of rides to choose from between major German cities. It's rare that you see classic hitch-hikers on the road. Shoestring travel has just become more reliable.

IMG_3389.jpg The system works: a month ago, Simone (left) was kind enough to take Anne (right) and me to Berlin. Simone sells databases for Oracle, Anne is a budding artist - soon she'll be presenting an installation of her's in Germany's new (old) capital. For just 20 Euros, I made the trip - a steal compared to overpriced train tickets (90 Euros unless you book weeks ahead of time). High gas prices have convinced drivers to share rides and cost - expensive train travel has driven passengers back on the road.

A day later, I got back into some stranger's car, which took me down to Leipzig, later to Munich and eventually back to Mainz near Frankfurt, where I caught a flight home.

One thing you have to deal with as a passenger: different driving styles. I did hold my breath when I could make out what movie the kids were watching in the rear seats of the van in front. I find tailgating at 140kph autobahnspeed is rather exciting.

Did I always meet fantastically interesting people? Of course not. But they've always been friendly and for sure as reliable as the British trains or international aircraft.

Posted by dr at 2:44 PM | Comments (2) | TrackBack