This page has lots of useful information if you’re using Red Hat and are a fan of Gnome. It also has the following very valuable nugget of information:
RPM is a little buggy imho (well, at least on rpm 4.1). Sometimes (randomly), rpm will lock up halfway through a query or package install.
The best solution is to open a new terminal as root and perform a killall -9 rpm or killall -9 rpmq (depending on whether you’re installing or querying). Then you need to remove the stale lock files with rm -f /var/lib/rpm/__db.00*. You should then have regained control of rpm.
Just a note on signals: it’s always worth trying sigs 15, 1, and 2 (in
that order, I think) before you hit the big old nine. Sig 9 gives the
process no chance to clean up after itself at all, and should only be
sued as a last resort.