test(coverage): access-method upgrade paths (db_upg 14->57%, qam/bt/hash_upgrade 0->68-97%) - #75
Merged
Merged
Conversation
…-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.
Coccinelle convention checksNo new violations. ✅ Resolved since baseline (2) -- update dist/cocci/baseline.txt to lock these in. |
ABI diff vs
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Real bug found (documented, engine NOT touched here)
__db_set_lastpgnostores__db_lastpgno()'s page count (bytes/pagesize) intometa->last_pgno, which should be the last page number (count-1) — off by +1 on any page-aligned file, anddb_verifyrejects it underHAVE_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).