Bug 113710

Summary: unable to rpm -qa after run /usr/lib/rpm/rpmdb_verify Packages OK
Product: [Retired] Red Hat Linux Reporter: helen wang <huwang>
Component: rpmAssignee: Jeff Johnson <jbj>
Status: CLOSED WORKSFORME QA Contact: Mike McLean <mikem>
Severity: medium Docs Contact:
Priority: medium    
Version: 9CC: huwang
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-01-17 00:34:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description helen wang 2004-01-16 18:45:45 UTC
I am having rpm problem in RH9 after running up2date, either user or 
root can not query rpm packages
error message: 
#rpm -qa
rpmdb: /var/lib/rpm/Packages: unsupported hash version: 8
error: cannot open Packages index using db3 - Invalid argument (22)
error: cannot open Packages database in /var/lib/rpm
no packages

after follow the instructions descripted in 
http://www.rpm.org/hintskinks/repairdb/

I have done as root:
#cd /var/lib/rpm
rm -f /var/lib/rpm/__db*
rpm -vv --rebuilddb

I got message:
# rpm -vv --rebuilddb
D: rebuilding database /var/lib/rpm into /var/lib/rpmrebuilddb.15334
D: creating directory /var/lib/rpmrebuilddb.15334
D: opening old database with dbapi 3
D: opening  db environment /var/lib/rpm/Packages create:cdb:mpool
D: opening  db index       /var/lib/rpm/Packages rdonly mode=0x0
rpmdb: /var/lib/rpm/Packages: unsupported hash version: 8
D: closed   db index       /var/lib/rpm/Packages
D: closed   db environment /var/lib/rpm/Packages
error: cannot open Packages index
D: removing directory /var/lib/rpmrebuilddb.15334

so I did
#cd /var/lib/rpm
# rm -f __db.00*
# /usr/lib/rpm/rpmdb_verify Packages

no error message at this time
then I did 
#rpm -qa
I got:
rpmdb: /var/lib/rpm/Packages: unsupported hash version: 8
error: cannot open Packages index using db3 - Invalid argument (22)
error: cannot open Packages database in /var/lib/rpm
no packages


what shall I do to fix it now? 

Thanks a lot!!

Helen

Comment 1 Jeff Johnson 2004-01-16 19:20:49 UTC
Hmm, you've somehow managed to mix db-4.0.14 tools with
db-4.1.25 on disk format.

You can convert Packages from db-4.1.25 to db-4.0.14
by using db_dump (from db4-utils-4.1.25) piped into
db_load (from db4-utils-4.0.14). Here's how (adding explict
versions for clarify).
    cd /var/lib/rpm
    mv Packages Packages-ORIG
    db_dump-4.1.25 Packages-ORIG | db_dump-4.0.14 Packages

You'll have to figure which db_dump and db_load to use. The
file /usr/lib/rpm/rpmdb_load appears to be from db-4.0.14,
and /usr/bin/db_dump may very well be the version from 4.1.25,
verify by doing
    rpm -rf /usr/bin/db_dump
to see which version of db4-utils is installed.

Once Packages is converted, rpm --rebuilddb -vv will convert the
other indices.

Comment 2 Jeff Johnson 2004-01-16 19:21:36 UTC
*** Bug 113712 has been marked as a duplicate of this bug. ***

Comment 3 helen wang 2004-01-16 22:08:33 UTC
while using rpm-rf /usr/bin/db_dump, it gave message: rpm: arguments to --root (-r) must begin with a /
also in /usr/lib/rpm, no "db_dump" instead it has rpmdb_dump
compare these two files, the result is:

light# ls -al /usr/bin/db_dump
-r-xr-xr-x    1 root     root        10008 Feb  5  2003 /usr/bin/db_dump*
light# ls -al /usr/lib/rpm/rpmdb_dump
-rwxr-xr-x    1 rpm      rpm         11156 Feb 27  2003 /usr/lib/rpm/rpmdb_dump*

shall I use rpmdb_dump for version 4.1 and db_dump for version 4.0?



Comment 4 helen wang 2004-01-16 22:27:11 UTC
By the way, the command you give me "db_dump-4.1.25 Packages-ORIG | db_dump-4.0.14 Packages"
should it be " db_dump Packages-ORIG |rpmdb_load Packages"?? if the version  is used correctly.
Thanks


Comment 5 helen wang 2004-01-16 22:34:14 UTC

Thanks Jeff, I fixed it!!

Here si the command I am using:
/usr/lib/rpm/rpmdb_dump Packages-ORIG | /usr/bin/db_load Packages
and then 
rpm --rebuilddb -vv

now it is working fine. Thank you again!!


Comment 6 Jeff Johnson 2004-01-17 00:34:55 UTC
Yes, db_load.

There's script /usr/lib/rpm/rrpmdb_loadcvt that does what you have
done if you need reference in future.