Nerdier

Adjective: Comparative form of nerdy: more nerdy.

Yum: DB_RUNRECOVERY: Fatal error, run database recovery

So I was trying to get something installed with puppet and I encountered this lovely error in the logs;

Sep 17 23:50:27 xxxxxx puppet-agent[32222]: Execution of '/usr/bin/yum -d 0 -e 0 -y install screen' returned 1: rpmdb: PANIC: fatal region error detected; run recovery
Sep 17 23:50:27 xxxxxx puppet-agent[32222]: error: db4 error(-30977) from dbenv->open: DB_RUNRECOVERY: Fatal error, run database recovery
Sep 17 23:50:27 xxxxxx puppet-agent[32222]: error: cannot open Packages index using db3 -  (-30977)
Sep 17 23:50:27 xxxxxx puppet-agent[32222]: error: cannot open Packages database in /var/lib/rpm
Sep 17 23:50:27 xxxxxx puppet-agent[32222]: Traceback (most recent call last):
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:   File "/usr/bin/yum", line 29, in ?
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:     yummain.user_main(sys.argv[1:], exit_code=True)
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:   File "/usr/share/yum-cli/yummain.py", line 309, in user_main
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:     errcode = main(args)
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:   File "/usr/share/yum-cli/yummain.py", line 157, in main
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:     base.getOptionsConfig(args)
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:   File "/usr/share/yum-cli/cli.py", line 187, in getOptionsConfig
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:     self.conf
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:   File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 665, in <lambda>
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:     conf = property(fget=lambda self: self._getConfig(),
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:   File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 240, in _getConfig
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:     self._conf = config.readMainConfig(startupconf)
Sep 17 23:50:27 xxxxxx puppet-agent[32222]:   File "/usr/lib/python2.4/site-packages/yum/config.py", line 805, in readMainConfig
Sep 17 23:50:28 xxxxxx puppet-agent[32222]:     yumvars['releasever'] = _getsysver(startupconf.installroot, startupconf.distroverpkg)
Sep 17 23:50:28 xxxxxx puppet-agent[32222]:   File "/usr/lib/python2.4/site-packages/yum/config.py", line 878, in _getsysver
Sep 17 23:50:28 xxxxxx puppet-agent[32222]:     idx = ts.dbMatch('provides', distroverpkg)
Sep 17 23:50:28 xxxxxx puppet-agent[32222]: TypeError: rpmdb open failed

Turns out the fix is super simple! You just need to run the following commands:

cd /var/lib/rpm/
rm -f __db*
rpm -–rebuilddb
yum clean all

Then you will be good to go.

 

Leave a Reply

Your email address will not be published. Required fields are marked *