Dealing with yum hangs on Fedora 6 et al

Shamelessly copied from Bryan O'Sullivan's blog)

One of the exciting things about upgrading to Fedora Core 6 is that the yum package manager now frequently hangs on me. This does not fill me with joy. The most common way in which it falls over is by hanging hard after printing this message:

Parsing package install arguments

What it means to “hang hard” here is that you can’t interrupt it using control-C, or by killing it with a normal, neighbourly signal like SIGINT or SIGTERM. A little bit of digging in another terminal window indicates why:

# pidof yum 30987

This number is yum’s process ID. Let’s see what it’s stuck doing:

# strace -p 30987
Process 30987 attached - interrupt to quit futex(0xb7bf21a0, FUTEX_WAIT, 2, NULL <unfinished …>

Ooh, look; it’s stuck in a futex system call. This usually means that the culprit is trying to lock a data structure in a memory-mapped file shared with another process. If the other process isn’t around, well, things can get exciting. By the way, it is possible to kill yum at this point; you just have to be brutal.

# killall -9 yum

Once the deed is done, a little sniffing around often reveals a few “__db.*” files in /var/lib/rpm. Let’s get rid of these:

# rm -f /var/lib/rpm/__db.*

At this point, retrying the hung yum command should succeed. At least, it does so for me in nine out of ten cases. Occasionally, I need to run “yum clean all” after cleaning up the above mess before yum can make progress.