Bug 115484 - rpmdb corrupted after run up2date in RHEL3
Summary: rpmdb corrupted after run up2date in RHEL3
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: rpm
Version: 3.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact: Mike McLean
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-02-12 21:55 UTC by helen wang
Modified: 2007-11-30 22:07 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-02-17 16:10:38 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description helen wang 2004-02-12 21:55:38 UTC
Description of problem:

after install RHEL3 and update all of the patches, rpm -qa not 
working as root and user.

Steps to Reproduce:
1.#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

2.
#cd /var/lib/rpm
#rm -f /var/lib/rpm/__db*
#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

3.#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

4. then try to convert the db into right format

cd /var/lib/rpm
mv Packages Packages-ORIG

***db_dump-4.1.25 Packages-ORIG | db_load-4.0.14 Packages

the real command on my machine as for the correct version is

#/usr/lib/rpm/rpmdb_dump Packages-ORIG | /usr/bin/db_load Packages

no error message at this step. then 
# rpm -vv --rebuilddb

D: rebuilding database /var/lib/rpm into /var/lib/rpmrebuilddb.2851
D: creating directory /var/lib/rpmrebuilddb.2851
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.2851

Additional info:
I have also tried the opposite way to convert it, same result. Any 
idea how to fix it? Thanks!!

Comment 1 Jeff Johnson 2004-02-12 22:48:24 UTC
What version of rpm?

Your steps are basically sound, db-4.1.25 is backward
compatible with db-4.0.14, but db-4.0.14 is not forward
compatible with db-4.1.25.

You might look at /usr/lib/rpm/rpmdb_loadcvt, that's a script
that does essentially what you have done manually.

There are also copies (or should be) of all db4 utilities
that are linked against the same version of Berkeley DB that
rpm is. For example, there's rpmdb_dump, rpmdb_load, etc.

Running file(1) against the database files in /var/lib/rpm
will display version information.

Packages is the most important. If you get that converted
to a version that rpm can read, the other indices will
be recreated with --rebuilddb -vv.

change from NEEDINFO -> ASSIGNED if you need help sorting out.

Comment 2 helen wang 2004-02-12 23:13:40 UTC
Jeff, Thanks for he quick response. 

I tried /usr/lib/rpm/rpmdb_loadcvt, as you recommended, no error at this step, 
it showed  "converting to db-4.1.25 compatible format" ....
"Done"

then I did 
"rpm --rebuilddb" it still gave me the same error message as I mentioned as above. what could it be the trouble?
Helen

Comment 3 Jeff Johnson 2004-02-12 23:21:15 UTC
What version of rpm please?

Comment 4 helen wang 2004-02-12 23:29:27 UTC
rpm version is 4.1 by running rpm --version

Comment 5 helen wang 2004-02-12 23:30:52 UTC
by running rpmdb --version, it shows rpm version 4.2.1 ??

Comment 6 Jeff Johnson 2004-02-12 23:39:07 UTC
Hmmm, 4.1 != 4.2.1, something is odd. Digging ...

Could you try rpmdb --rebuilddb -vv please?
That should have db-4.1.25 inside which is backwards compat.

Comment 7 helen wang 2004-02-12 23:46:16 UTC
Ha!! very smart! it works this time. appreciate it very much. 
just confusing in different version of RH... 

have a wonderful night.

Helen

Comment 8 helen wang 2004-02-12 23:53:27 UTC
Oops, rpmdb --rebuilddb -vv worked fine, but when I use rpm -qa, it gave error message again like 
"cannot open Package index using db3, cannot open packages database in /var/lib/rpm"


Comment 9 helen wang 2004-02-13 00:06:30 UTC
Jeff, 
I noticed that in RHEL the command for query is /usr/bin/rpmquery ( pointing to /usr/lib/rpm/rpmq) 
with options similar to rpm -qa, this command is working fine, so I am wondering that in RHEL3 something 
about rpm changed so the general rpm command under /bin is no longer being used for the same purpose?

Helen

Comment 10 Jeff Johnson 2004-02-13 00:30:05 UTC
Hmmm, /bin/rpm is from wrong version.

For all modes but install/upgrade/erase, /bin/rpm is just
a front-end, invoking (after a little digging) helpers located
in /usr/lib/rpm that look like, say, rpmv for verify mode, rpmk for
signature checking, etc, etc.

/bin/rpm seems damaged somehow, I don't think from RHEL3.

Try /usr/lib/rpm/rpmv -V rpm to see what is broken or missing.

I suspect that /bin/rpm will show up as modified.

Is that the case?


Comment 11 helen wang 2004-02-13 17:22:18 UTC
Jeff,
I agree with you, but when I check /bin/rpm and all the rpm commands under /usr/lib/rpm/, they are all 
showing the same modification time as Jan 8 at 21:47
group# ls -al /bin/rpm
-rwxr-xr-x    1 rpm      rpm         79388 Jan  8 21:47 /bin/rpm*
group#
group# ls -al /usr/lib/rpm/rpm*
-rwxr-xr-x    1 rpm      rpm           713 Jan  8 21:47 /usr/lib/rpm/rpm2cpio.sh*
-rwxr-xr-x    1 rpm      rpm         19656 Jan  8 21:47 /usr/lib/rpm/rpmb*
-rwxr-xr-x    1 rpm      rpm         12264 Jan  8 21:47 /usr/lib/rpm/rpmcache*
-rwxr-xr-x    1 rpm      rpm         10432 Jan  8 21:47 /usr/lib/rpm/rpmd*
-rwxr-xr-x    1 rpm      rpm           104 Jan  8 21:47 /usr/lib/rpm/rpm.daily*
-rwxr-xr-x    1 rpm      rpm          7052 Jan  8 21:47 /usr/lib/rpm/rpmdb_deadlock*
-rwxr-xr-x    1 rpm      rpm         11100 Jan  8 21:47 /usr/lib/rpm/rpmdb_dump*
-rwxr-xr-x    1 rpm      rpm         18040 Jan  8 21:47 /usr/lib/rpm/rpmdb_load*
-rwxr-xr-x    1 rpm      rpm          1467 Jan  8 21:47 /usr/lib/rpm/rpmdb_loadcvt*
-rwxr-xr-x    1 rpm      rpm         24852 Jan  8 21:47 /usr/lib/rpm/rpmdb_stat*
-rwxr-xr-x    1 rpm      rpm         39788 Jan  8 21:47 /usr/lib/rpm/rpmdb_svc*
-rwxr-xr-x    1 rpm      rpm          7320 Jan  8 21:47 /usr/lib/rpm/rpmdb_verify*
-rwxr-xr-x    1 rpm      rpm          5912 Jan  8 21:47 /usr/lib/rpm/rpmdeps*
lrwxr-xr-x    1 rpm      rpm             4 Jan 30 19:39 /usr/lib/rpm/rpme -> rpmi*
-rwxr-xr-x    1 rpm      rpm          8848 Jan  8 21:47 /usr/lib/rpm/rpmfile*
-rwxr-xr-x    1 rpm      rpm       1951224 Jan  8 21:47 /usr/lib/rpm/rpmi*
-rwxr-xr-x    1 rpm      rpm         11792 Jan  8 21:47 /usr/lib/rpm/rpmk*
-rwxr-xr-x    1 rpm      rpm            61 Jan  8 21:47 /usr/lib/rpm/rpm.log*
-rw-r--r--    1 rpm      rpm         20872 Jan  8 21:47 /usr/lib/rpm/rpmpopt-4.2.1
-rwxr-xr-x    1 rpm      rpm         11136 Jan  8 21:47 /usr/lib/rpm/rpmq*
-rw-r--r--    1 rpm      rpm         10596 Jan  8 21:47 /usr/lib/rpm/rpmrc
lrwxr-xr-x    1 rpm      rpm             4 Jan 30 19:49 /usr/lib/rpm/rpmt -> rpmb*
lrwxr-xr-x    1 rpm      rpm             4 Jan 30 19:39 /usr/lib/rpm/rpmu -> rpmi*
lrwxr-xr-x    1 rpm      rpm             4 Jan 30 19:39 /usr/lib/rpm/rpmv -> rpmq*
-rwxr-xr-x    1 rpm      rpm           319 Jan  8 21:47 /usr/lib/rpm/rpm.xinetd*

running the command  rpmv -V rpm did not show anything.

group# /usr/lib/rpm/rpmv -V rpm
group#

shall I reinstall rpm package at this point or simply get a good version of rpm executable and copy it under /bin?

Hele

Comment 12 Jeff Johnson 2004-02-14 05:37:58 UTC
reinstall with --force should fix.

if /bin/rpm fails to install, then try /usr/lib/rpm/rpmi with
same args.

if /usr/lib/rpm/rpmi fails to install, then you will
need to install manually using rpm2cpio. There's rpm2cpio
man page, but the commands will be something like

    mkdir -p /var/tmp/xxx
    rpm2cpio /path/to/rpm-4*.rpm | cpio -dim
    find . -type d -exec chmod 755 {} \;
    tar cf - . | (cd /; tar xvf -)


Comment 13 helen wang 2004-02-16 20:24:02 UTC
Jeff, 

the problem is fixed finally by your instructions. thank you very much for all of the help. 
with all of these solutions, I hope I won;t have any rpm problem anymore :)) have a good day.

Helen


Note You need to log in before you can comment on or make changes to this bug.