Skip to content

test(coverage): access-method upgrade paths (db_upg 14->57%, qam/bt/hash_upgrade 0->68-97%) - #75

Merged
gburd merged 1 commit into
masterfrom
coverage/upgrade-rebased
Jul 29, 2026
Merged

test(coverage): access-method upgrade paths (db_upg 14->57%, qam/bt/hash_upgrade 0->68-97%)#75
gburd merged 1 commit into
masterfrom
coverage/upgrade-rebased

Conversation

@gburd

@gburd gburd commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Covers the on-disk-format upgrade code via synthetic old-format fixtures (rewriting a current DB's metadata page into old on-disk layouts — HASHHDR v5, HMETA30 v6, BTMETA2X v6, BTMETA30 v7, QMETA30 v1, QMETA31 v2), driving the real per-version transforms without needing an old library.

file before after
db/db_upg.c 13.9% 57.2%
qam/qam_upgrade.c 0% 97.1%
btree/bt_upgrade.c 0% 82.4%
hash/hash_upgrade.c 0% 68.5%
db/db_upg_opd.c 0% 0% (needs a genuine pre-3.1 off-page-dup fixture — documented gap)

Real bug found (documented, engine NOT touched here)

__db_set_lastpgno stores __db_lastpgno()'s page count (bytes/pagesize) into meta->last_pgno, which should be the last page number (count-1) — off by +1 on any page-aligned file, and db_verify rejects it under HAVE_FTRUNCATE. Byte-identical to upstream BDB 4.7/4.8 → likely a long-standing latent defect. The hash path masks it (its v8→v9 pass goes through mpool, which recomputes last_pgno on close). Reported (not patched) since the fixtures are synthetic — needs confirmation on a genuine old fixture. Being investigated separately.

No binary fixtures or build artifacts committed; driver passes under timeout, idempotent; wired into run_coverage.sh (COV_XA_UPG).

…-format fixtures

Extend test/db/run_upgrade.sh to exercise the on-disk-format upgrade code
(src/db/db_upg.c, src/btree/bt_upgrade.c, src/hash/hash_upgrade.c,
src/qam/qam_upgrade.c), which was almost entirely dead (0-14%) because this
fork ships only one current-format fixture and lacks upstream's per-version
Tcl upgrade fixture tree (test/tcl/upgrade/databases/).

The driver now:
- runs db_upgrade (DB->upgrade) + db_verify over the committed btree v9
  fixture and freshly-created current-format dbs of every access method
  (btree/hash/queue/recno + btree-with-dups + the -s DUPSORT flag and
  salvage), covering the full magic/version dispatch and the
  version-current no-op branch for each AM;
- manufactures old-format fixtures WITHOUT an old library, by rewriting a
  current db's metadata page into the byte layout of an older release
  (HASHHDR v5, HMETA30 v6, BTMETA2X v6, BTMETA30 v7, QMETA30 v1, QMETA31 v2
  from dbinc/db_upgrade.h) with the version field set back, driving the real
  per-version transform functions.

Coverage (line), before -> after:
  db/db_upg.c        13.9% -> 57.2%   (functions 40% -> 100%)
  qam/qam_upgrade.c   0.0% -> 97.1%   (functions 0% -> 100%)
  btree/bt_upgrade.c  0.0% -> 82.4%   (functions 0% -> 100%)
  hash/hash_upgrade.c 0.0% -> 68.5%   (functions 0% -> 66.7%)
  db/db_upg_opd.c     0.0% -> 0.0%    (still cold; see below)

Fixtures are generated at test time from current-format dbs, so no binary
fixtures are committed.

Two documented gaps (in test/coverage/README.md, engine NOT changed):
- db_upg_opd.c (__db_31_offdup, 3.0->3.1 off-page-dup conversion) needs a
  genuine 3.0-era off-page-duplicate page chain (linked __P_DUPLICATE pages);
  a rewritten current db can't produce it (current dups are already a Recno
  tree), so it stays 0%.
- __db_set_lastpgno off-by-one: the btree v6/v7 path stores __db_lastpgno()'s
  page COUNT into meta->last_pgno (a page NUMBER = count-1), so db_verify
  rejects last_pgno on a page-aligned file ("last_pgno is not correct: N !=
  N-1", under HAVE_FTRUNCATE). The hash path avoids it (its v8->v9 pass runs
  through mpool, which recomputes last_pgno on close). The code is identical
  to upstream BDB 4.7/4.8. The driver upgrades btree v6/v7 (covering the
  transform) but skips db_verify on them, asserting the version bump instead.
  Reported to confirm against a genuine old fixture; not fixed.
@gburd
gburd merged commit 1edc063 into master Jul 29, 2026
45 of 47 checks passed
@gburd
gburd deleted the coverage/upgrade-rebased branch July 29, 2026 11:09
@github-actions

Copy link
Copy Markdown

Coccinelle convention checks

No new violations. ✅

Resolved since baseline (2) -- update dist/cocci/baseline.txt to lock these in.
rule_mutex_unbalanced|MUTEX_UNBALANCED|src/crypto/mersenne/mt19937db.c|return (ret);
rule_mutex_unbalanced|MUTEX_UNBALANCED|src/mp/mp_register.c|return (ret);

@github-actions

Copy link
Copy Markdown

ABI diff vs v5.3.31 (libabigail — authoritative)

Removed exported symbols (nm -D, _NNNN version suffix normalized)

None.


Advisory: libabigail/nm is the authoritative binary-ABI check; Coccinelle is complementary source-level early warning. See dist/cocci/README.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant