I encountered this today when trying to query a package on a Red Hat server:
rpmdb: Lock table is out of available locker entries
error: db4 error(22) from db->close: Invalid argument
error: cannot open Name index using db3 – Cannot allocate memory (12)
This happens when an operation involving the rpm db gets interrupted and the locks not cleared. The solution is rather simple:
1. Make a backup of /var/lib/rpm (because you never know)
2. rm /var/lib/rpm/__db.00*
3. rpm --rebuilddb
You should have a working rpm databse now.