#1095493 reprepro: Secondary index inconsistent with primary

Package:
reprepro
Source:
reprepro
Description:
Debian package repository producer
Submitter:
Slavko
Date:
2026-06-24 09:59:02 UTC
Severity:
normal
Tags:
#1095493#5
Date:
2025-02-08 13:02:37 UTC
From:
To:
Hi,

after upgrade od reprepro in trixie i noticed this at add (new
version) package:

    Error: database uses deprecated format.
    Please run translatelegacyreferences to update to the new format first.
    There have been errors!

Thus i cd to repo and run:

    reprepro -Vb . translatelegacyreferences

It produces no output, but now on add/list packages i see (wrapped)
eg.:

    reprepro -Vb . ls virtualbox
    packages.db/trixie|main|amd64: BDB0088 DB_SECONDARY_BAD: \
        Secondary index inconsistent with primary
    Internal error of the underlying BerkeleyDB database:
    Within packages.db subtable trixie|main|amd64 at c_get(DB_NEXT): \
        BDB0088 DB_SECONDARY_BAD: Secondary index inconsistent with primary
    There have been errors!

The same output for:

    reprepro -Vb . check

I do not know if i did something wrongly, nor how to fix DB now...

regards

#1095493#10
Date:
2025-02-08 14:55:36 UTC
From:
To:
I tried to recovery packages.db as described in recovery file, but it
ends with the same error::

    reprepro -Vb . update
    aptmethod got 'copy:/home/slavko/tmp/dist_mv/dists/trixie/InRelease'
    aptmethod got 'copy:/home/slavko/tmp/dist_mv/dists/bookworm/InRelease'
    aptmethod got 'copy:/home/slavko/tmp/dist_mv/dists/bullseye/InRelease'
    aptmethod got 'copy:/home/slavko/tmp/dist_mv/dists/buster/InRelease'
    Calculating packages to get...
      processing updates for 'buster|non-free|source'
      reading './lists/localreadd_buster_non-free_Sources'
      processing updates for 'buster|non-free|amd64'
      reading './lists/localreadd_buster_non-free_amd64_Packages'
      processing updates for 'buster|main|source'
    packages.db/buster|main|source: BDB0088 DB_SECONDARY_BAD: Secondary index inconsistent with primary
    Internal error of the underlying BerkeleyDB database:
    Within packages.db subtable buster|main|source at c_get(DB_???NEXT): BDB0088 DB_SECONDARY_BAD: Secondary index inconsistent with primary
    There have been errors!

It is not tied with particular suite/codename, as when i comment one,
the error is raised in another.

regards

#1095493#15
Date:
2025-02-10 03:33:56 UTC
From:
To:
I can confirm the behavior.

regards

#1095493#20
Date:
2025-02-15 11:30:46 UTC
From:
To:
Hi,

After downgrade to 5.3.1-5, the recovery was success...

regards

#1095493#25
Date:
2025-02-15 14:34:33 UTC
From:
To:
I can no longer find 5.3.1-5

...

#1095493#30
Date:
2025-02-15 14:40:12 UTC
From:
To:
Am 15.02.25 um 15:34 schrieb Holger Schröder:

http://snapshot.debian.org/package/reprepro/5.3.1-5/

#1095493#35
Date:
2025-02-22 08:03:48 UTC
From:
To:
reprepro DB is still broken:

[12/4820]mh@spinturn:~/incoming $ sudo -H -u zg20150 env REPREPRO_BASE_DIR=/var/lib/zg20150/repositories/zg reprepro includedeb bookworm-zg-unstable kernel-image-zgsrv20080_6.13.4.0.20250222.0-1_all.deb
Internal error of the underlying BerkeleyDB database:
Within references.db subtable references at put: BDB0067 DB_KEYEXIST: Key/data pair already exists
Internal error of the underlying BerkeleyDB database:
Within references.db subtable references at put: BDB0067 DB_KEYEXIST: Key/data pair already exists
Internal error of the underlying BerkeleyDB database:
Within references.db subtable references at put: BDB0067 DB_KEYEXIST: Key/data pair already exists
There have been errors!
255 [13/4821]mh@spinturn:~/incoming $

I have deleted the references.db and rebuilt sudo -H -u zg20150 env
REPREPRO_BASE_DIR=/var/lib/zg20150/repositories/zg reprepro  -Vb .
rereference

but that didn't help. Would it help to go through the more complicated
recovery of packages.db?

I'd appreciate the package maintainer to chime in here, the issue has
been around for more than a week now.

Greetings
Marc

#1095493#38
Date:
2025-02-22 08:03:48 UTC
From:
To:
reprepro DB is still broken:

[12/4820]mh@spinturn:~/incoming $ sudo -H -u zg20150 env REPREPRO_BASE_DIR=/var/lib/zg20150/repositories/zg reprepro includedeb bookworm-zg-unstable kernel-image-zgsrv20080_6.13.4.0.20250222.0-1_all.deb
Internal error of the underlying BerkeleyDB database:
Within references.db subtable references at put: BDB0067 DB_KEYEXIST: Key/data pair already exists
Internal error of the underlying BerkeleyDB database:
Within references.db subtable references at put: BDB0067 DB_KEYEXIST: Key/data pair already exists
Internal error of the underlying BerkeleyDB database:
Within references.db subtable references at put: BDB0067 DB_KEYEXIST: Key/data pair already exists
There have been errors!
255 [13/4821]mh@spinturn:~/incoming $

I have deleted the references.db and rebuilt sudo -H -u zg20150 env
REPREPRO_BASE_DIR=/var/lib/zg20150/repositories/zg reprepro  -Vb .
rereference

but that didn't help. Would it help to go through the more complicated
recovery of packages.db?

I'd appreciate the package maintainer to chime in here, the issue has
been around for more than a week now.

Greetings
Marc

#1095493#43
Date:
2025-02-23 14:37:54 UTC
From:
To:
Am 22.02.25 um 09:03 schrieb Marc Haber:

Sure, time is limited. I am happy to take patches. If none show up within a week or two and I do no find the time myself
I am going to revert to 5.3.1-5.

#1095493#48
Date:
2025-02-24 00:01:23 UTC
From:
To:
I got the same error after updating a 'mesa-asahi' package. After running
translatelegacyreferences [1] and doing the update, my packagenames.db
contains a single item,

[(b'mesa-asahi\x00', b'mesa-asahi|25.1.0~git20250221.67b507f-1\x00')]

while those in my packages.db are two, with keys

[b'mesa-asahi\x00', b'mesa-asahi|25.1.0~git20250221.67b507f-1\x00']

(these were obtained using the berkeleydb python package). This is wrong:
packagenames.db is a secondary indices database for packages.db, so it must
contain one and only one item for each key in packages.db (with the value
equal to the key). This mismatch is the error we are observing.


Using -VVV it seems that database_translate_legacy_packages was never called.
I think this is because database_openpackages calls database_table_secondary
with the DB_CREATE flag before calling database_translate_legacy_packages. In
turn, database_table_secondary calls database_opentable *for packagenames.db*
with the DB_CREATE flag, which creates the database. So when
database_openpackages then must decide whether to call
database_translate_legacy_packages, it finds packagenames.db and thinks it
must not. It then proceeds to update packagenames.db and packages.db without
doing the migration, which leaves the database in an inconsistent state (see
above).


[1] For full disclosure, I am the author of translatelegacyreferences, which
I submitted under a different name (my real one). I checked that command
doesn't do anything unintended, other than changing the DUP flags as
documented. In particular, it doesn't touch neither packages.db nor
packagenames.db, where this bug originates.

#1095493#57
Date:
2026-03-04 22:47:43 UTC
From:
To:
Does anyone know what needs to be done to fix this issue?
#1095493#62
Date:
2026-06-24 09:48:55 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
reprepro, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1095493@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Bastian Germann <bage@debian.org> (supplier of updated reprepro package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Wed, 24 Jun 2026 11:22:42 +0200
Source: reprepro
Architecture: source
Version: 5.5.0-1
Distribution: experimental
Urgency: medium
Maintainer: Bastian Germann <bage@debian.org>
Changed-By: Bastian Germann <bage@debian.org>
Closes: 1095493 1131622 1133682
Changes:
 reprepro (5.5.0-1) experimental; urgency=medium
 .
   * Import new upstream version 5.5.0
   * Migrate legacy format before opening for write (Closes: #1095493)
 .
   [ Simon Richter ]
   * Supersede should also delete for equal version (Closes: #1131622)
   * Handle "any-amd64" and "any-any" in needbuild (Closes: #1133682)
Checksums-Sha1:
 13b8d888ef799121921ac34b62e13dc490bfa923 1792 reprepro_5.5.0-1.dsc
 9bb6a81c2fba5d1c49c2ce4fc7da43ec7bf23eb8 463556 reprepro_5.5.0.orig.tar.xz
 7d90443d887973385e800969a3cf3fdcca04dee3 15424 reprepro_5.5.0-1.debian.tar.xz
 03b014d94b8994afe57571475b6c22ee2b0e3194 7106 reprepro_5.5.0-1_source.buildinfo
Checksums-Sha256:
 b1dcaeb79c281dd5c423a34e5174acc9a3c5d3792e1fc46ad2ba2c51bdcc3d90 1792 reprepro_5.5.0-1.dsc
 efc317fba149e40bb7f96251d433ab8bbcffac1c12fe07db1327c6a25a27aac7 463556 reprepro_5.5.0.orig.tar.xz
 a5ddbc92f0d4d5f4cb13a2dd888601cf5d0261cb8071bfd897cbfa97ce0a5716 15424 reprepro_5.5.0-1.debian.tar.xz
 a0c70e2b7bf36a9be52b29949c259c79d8c3f5372c6ad29d701d8ab1e8854936 7106 reprepro_5.5.0-1_source.buildinfo
Files:
 358088be7cbd1ed27fa4976425a978bb 1792 utils optional reprepro_5.5.0-1.dsc
 8f6d29557322293e204760878006ca16 463556 utils optional reprepro_5.5.0.orig.tar.xz
 ed7b17b21c24ae34f8ade3a8e957e13f 15424 utils optional reprepro_5.5.0-1.debian.tar.xz
 f72a97601400a789ffc6ebaa6c6ad673 7106 utils optional reprepro_5.5.0-1_source.buildinfo
-----BEGIN PGP SIGNATURE-----

iQHEBAEBCgAuFiEEQGIgyLhVKAI3jM5BH1x6i0VWQxQFAmo7oy8QHGJhZ2VAZGVi
aWFuLm9yZwAKCRAfXHqLRVZDFNhTDACdwlRhb5ePOfO4RHlClyOX+LeRRZ9L1Xc/
UTBwYca2jI1aRm6Xqgz7xtnUldDJOW13k41XPw/feExCNIzIjS04zKiFZ5bAF/i+
c8gNja8Cal5SOSzvHZXjmzgeMqT++c8mmt2kDobjJoqZqP4W6Cu7gvBGoYamn60y
lrx83lnItMlnwioMy0vFzq0suk5Hpti75nqCpM+ON026r5ATBuxcEh8Tg38tKKD5
u3AcHK4LH01Kgaiw/32VjVyLCAnYZDAxOQTZhNSf15afOLABi7kHyPn69Kugmyv/
RcFCypmxVbdSSVNsmfssiuN5jSruy5yWhRozKzzFbYDlFDZnnE7mxSbjVqTjT5Zs
5x+ASscRPEw8eJN8EB3bCqkTDjJl1dwVaDDicoiIdOaUU23IvDY8m48ZOlQuYK4F
bXapBfbCwhLqiCEGTMYvdtAciIgV0bQ0f6UsbdcrEsuYYXn6vKbkKv6Ta9Ny5N75
44Nb2mQYGHrbTsqgNisgvAbGvfaa9x8=
=bEDz
-----END PGP SIGNATURE-----

#1095493#67
Date:
2026-06-24 09:57:03 UTC
From:
To: