[sos-devel] [RFC PATCH] sosreport: Check for rpm database corruption during initialization

Aruna Balakrishnaiah aruna at linux.vnet.ibm.com
Fri Oct 10 05:58:14 UTC 2014


sosreport runs an rpm query to get the package list. If rpmdb is corrupted
sosreport hangs for ever hence check for rpmdb consistency before running
the rpm query.

Signed-off-by: Aruna Balakrishnaiah <aruna at linux.vnet.ibm.com>
---
When rpmdb is corrupted rpm commands hangs forever,
yum check will result in:

yum check
error: rpmdb: BDB0113 Thread/process 43828/70366497037824 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 -  (-30973)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed

So look for 'rpmdb open failed', include this check in redhat policy as
yum command is specific to redhat.

Bryn,
	Please suggest if there is a better way to do it.

Regards,
Aruna

 sos/policies/redhat.py |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py
index 2219246..3007ce1 100644
--- a/sos/policies/redhat.py
+++ b/sos/policies/redhat.py
@@ -21,6 +21,8 @@ import sys
 from sos.plugins import RedHatPlugin
 from sos.policies import LinuxPolicy, PackageManager
 from sos import _sos as _
+from sos.utilities import is_executable, shell_out
+from distutils.log import error
 
 sys.path.insert(0, "/usr/share/rhn/")
 try:
@@ -42,6 +44,16 @@ class RedHatPolicy(LinuxPolicy):
         super(RedHatPolicy, self).__init__()
         self.report_name = ""
         self.ticket_number = ""
+        """
+        Check for rpm database corruption
+        """
+        if is_executable("yum"):
+           yum_info = shell_out("yum check").splitlines()
+           for info in yum_info:
+               if 'rpmdb open failed' in info:
+                   error("rpmdb corruption, rebuild rpmdb: rpmdb --rebuildb")
+                   sys.exit(1)
+
         self.package_manager = PackageManager(
             'rpm -qa --queryformat "%{NAME}|%{VERSION}\\n"')
         self.valid_subclasses = [RedHatPlugin]




More information about the sos-devel mailing list