If you are getting following error while doing any updates on the server
rpmdb: Program version 4.2 doesnâ€™t match environment version
error: db4 error(22) from dbenv->open: Invalid argument
error: cannot open Packages index using db3 – Invalid argument (22)
error: cannot open Packages database in /var/lib/rpm
Then to fix that do as per below step.
1. Check for processes holding the rpm database open (usually in MUTEX/FUTEX states):
lsof | grep /var/lib/rpm
If it finds any, kill -9 them all.
2. Delete any temporary DB files:
rm -fv /var/lib/rpm/__*
3. Rebuild your RPM database:
rpm â€“rebuilddb -v -v
If you still have problems, a reboot is probably quickest, then repeat steps 2 and 3 above.
Hopefully it will fix he problem.