Bug 124069 - rpm database get corrupted and rpm -qa segfaults after 2 days
rpm database get corrupted and rpm -qa segfaults after 2 days
Status: CLOSED WORKSFORME
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
2
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jeff Johnson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-05-23 15:40 EDT by Eric Ross
Modified: 2007-11-30 17:10 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-05-29 23:51:28 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Eric Ross 2004-05-23 15:40:08 EDT
Description of problem:
After 2 days, using rpm fails. I installed apt from fedora.us. It
worked fine, but after a while I started to get:


X:/var/lib/rpm# rpm -q rpm
....
apt-0.5.15cnc6-0.fdr.11.2
error: rpmdbNextIterator: skipping h#95050028 blob size(11): BAD, 8 +
16 * il(1703125084) + dl(551531384)
error: rpmdbNextIterator: skipping h#      17 blob size(11): BAD, 8 +
16 * il(1963020689) + dl(-1489727999)
error: rpmdbNextIterator: skipping h#1802246941 blob size(11): BAD, 8
+ 16 * il(91) + dl(100663297)
error: rpmdbNextIterator: skipping h#27036381 blob size(11): BAD, 8 +
16 * il(1440309175) + dl(-389703461)
error: rpmdbNextIterator: skipping h#16777216 blob size(11): BAD, 8 +
16 * il(-7441621) + dl(1313669385)
Segmentation fault


X:/var/lib/rpm# rm __db.00*; rpm --rebuilddb -vv
...
D:  read h#     745 Header V3 DSA signature: NOKEY, key ID 8df56d05
D:   +++ h#     381 Header V3 DSA signature: NOKEY, key ID 8df56d05
D: adding "apt" to Name index.
D: adding 115 entries to Basenames index.
D: adding "System Environment/Base" to Group index.
D: adding 43 entries to Requirename index.
D: adding 3 entries to Providename index.
D: adding 36 entries to Dirnames index.
D: adding 43 entries to Requireversion index.
D: adding 3 entries to Provideversion index.
D: adding 1 entries to Installtid index.
D: adding 1 entries to Sigmd5 index.
D: adding "de70b6edd5e25cec8a62de3c14f7a683cb6b8170" to Sha1header index.
D: adding 115 entries to Filemd5s index.
error: rpmdbNextIterator: skipping h#95050028 blob size(11): BAD, 8 +
16 * il(1703125084) + dl(551531384)
error: rpmdbNextIterator: skipping h#      17 blob size(11): BAD, 8 +
16 * il(1963020689) + dl(-1489727999)
error: rpmdbNextIterator: skipping h#1802246941 blob size(11): BAD, 8
+ 16 * il(91) + dl(100663297)
error: rpmdbNextIterator: skipping h#27036381 blob size(11): BAD, 8 +
16 * il(1440309175) + dl(-389703461)
error: rpmdbNextIterator: skipping h#16777216 blob size(11): BAD, 8 +
16 * il(-7441621) + dl(1313669385)
Segmentation fault

X:/var/lib/rpm# rm __db.00*; mv Pubkeys Pubkeys.old; rpm --rebuilddb -vv
[same as before]

When I try to dump the Packages file:
X:/var/lib/rpm# /usr/lib/rpm/rpmdb_dump Packages
VERSION=3
format=bytevalue
type=hash
db_dump: DB->stat: DB_PAGE_NOTFOUND: Requested page not found


Version-Release number of selected component (if applicable):
rpm-4.3.1-0.3


Additional info:

Every time I get the error, rpm start to eat memory. I see the memory
indicator in gkrellm and when rpm is about to segfaul, free memory
it's almost empty and the kernel start to swapping to disk.
Comment 1 Eric Ross 2004-05-23 15:50:40 EDT
Ups.. 'rpm -q rpm' is really 'rpm -qa'
Comment 2 Jeff Johnson 2004-05-24 10:50:15 EDT
What does the following say?
     rm -f /var/lib/rpm/__db*
    /usr/lib/rpm/rpmdb_verify /var/lib/rpm/Packages
Comment 3 Eric Ross 2004-05-24 11:12:42 EDT
X:/var/lib/rpm# rm -f /var/lib/rpm/__db*; /usr/lib/rpm/rpmdb_verify 
/var/lib/rpm/Packages
db_verify: Page 4019: item 0 has bad type
db_verify: DB->verify: /var/lib/rpm/Packages: DB_VERIFY_BAD: Database
verification failed
Comment 4 Jeff Johnson 2004-05-25 09:31:03 EDT
OK. You need to do the following:

    cd /var/lib/rpm
    mv Packages Packages-ORIG
    /usr/lib/rpm/rpmdb_dump Packages-ORIG | /usr/lib/rpm/rpmdb_load
Packages
    rpm --rebuilddb -vv

Does that fix?
Comment 5 Eric Ross 2004-05-25 12:57:59 EDT
X:/var/lib/rpm# mv Packages Packages-ORIG
X:/var/lib/rpm# /usr/lib/rpm/rpmdb_dump Packages-ORIG |
/usr/lib/rpm/rpmdb_load Packages
db_dump: DB->stat: DB_PAGE_NOTFOUND: Requested page not found
db_load: line 4: unexpected format

[In my first post I wrote about dumping the packages file]
Comment 6 Jeff Johnson 2004-05-26 20:25:32 EDT
Do
    rm -f /var/lib/rpm/__db*
to avoid DB_PAGE_NOTFOUND.
Comment 7 Eric Ross 2004-05-26 21:00:59 EDT
Ok.. here we go, in one line:

X:/var/lib/rpm# rm -f __db*; \
mv Packages Packages-ORIG;\
/usr/lib/rpm/rpmdb_dump Packages-ORIG | /usr/lib/rpm/rpmdb_load Packages
db_dump: DB->stat: DB_PAGE_NOTFOUND: Requested page not found
db_load: line 4: unexpected format
Comment 8 Jeff Johnson 2004-05-29 09:29:47 EDT
Please give me a ptr (i.e. URL, bugzilla attachments won't work)
to a tarball of your rpmdb:
    cd /var/lib
    tar czvf /tmp/rpmdb-124069.tar.gz
and I'll take a look. No promises, an rpmdb that
rpmdb_dump cannot read may not be savable.
Comment 9 Eric Ross 2004-05-29 15:18:25 EDT
I put it here:
http://vipnova.cl/~eross/rpmdb-124069.tar.bz2

I hope it's still savable.
Comment 10 Jeff Johnson 2004-05-29 20:14:50 EDT
Hmmm, your rpmdb like nothing I've ever seen.

Adding -r to rpmdb_dump into rpmdb_load generates a Packages
file that passes rpmdb_verify. Unfortunately, not enough.

Adding -rp to rpmdb_dump, and examining the printed output,
shows SElinux file contexts that (afaict) should not be
there. How that info got there is a mystery to me, but I
don't believe I can edit the rpmdb_dump output suffciently
to recreate an rpmdb.

So let's try plan B:

Look at /var/log/rpmpkgs*. That should be the list of
pkgs that you had installed.

Download a copy of those (or equivalent) pkg (that's the hard part).

Rename the existing /var/lib/rpm, make a new /var/lib/rpm.

Reinstall each of those packages with the flags
    rpm -Uvh --justdb --noscripts --notriggers
to recreate your database.

When finished, rpm -Va should identify any/all mistakes.

Add a comment here if you need help.
Comment 11 Eric Ross 2004-05-29 23:11:36 EDT
Thank you. I follow your instructions, and my rpm db is alive again. I
found no big troubles with -Va.
I didnt found references to using --justdb and friends when I searched
before posting here. I think it's a good method (if you have an
updated rpmpkgs).

Thank you again.

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