test(coverage): XA (0→57%) + on-disk upgrade (0→14%); document db_repsite gap - #70
Merged
Conversation
The existing test/xa harness (chk.xa + src1..src5) requires an Oracle Tuxedo transaction manager, which is unavailable, leaving xa/xa.c and xa_map.c at 0% coverage. Add xa_direct.c: a self-contained transaction manager that drives the exported db_xa_switch entry points directly (xa_open/start/end/prepare/ commit/rollback/recover/forget), performs data-plane work via DB_XA_CREATE handles, and resolves an in-doubt prepared txn through the XA recovery scan (__txn_get_prepared, DB_FIRST/DB_NEXT). Everything runs in one process and every txn is fully resolved before exit, plus a hard SIGALRM guard, so the test can never leave a prepared txn holding locks and can never hang. run_xa_direct.sh builds + runs it against the freshly-built libdb in .libs under a timeout, self-cleaning its home. Coverage: xa/xa.c 0% -> ~57% line (93% func), xa/xa_map.c 0% -> ~78%.
The on-disk-format upgrade path (src/db/db_upg.c) is at 0% because no group runs db_upgrade and the full Tcl "upgrade" group needs a large per-version fixture tree (test/tcl/upgrade/databases/) that is absent from this fork. Add run_upgrade.sh: run the db_upgrade utility + db_verify over the one committed old-format fixture (test/csharp/bdb4.7.db, a btree meta version-9 database), exercising the utility open + version-check + no-op-when-current path. Runs under a timeout; self-cleans its work dir. Coverage: db/db_upg.c 0% -> ~14% line (40% func). db_upg_opd.c stays 0% (the off-page-duplicate conversion needs a genuinely pre-v9 db with off-page dups, which the fork lacks -- noted in README).
…b_repsite - run_coverage.sh: add a COV_XA_UPG block (default on) that runs the two non-Tcl drivers after the Tcl subset, mirroring the COV_REP block. Both self-clean and run under a hard timeout, so they cannot hang. - README.md: document COV_XA_UPG, the two drivers, their measured lifts, and why db_upg_opd.c stays cold. - DB-REPSITE-TODO.md: full assessment of the absent db_repsite utility (the repmgr 100-series enabler) -- reverse-engineered stdin command protocol, the DB_ENV->repmgr_site/repmgr_start API surface it needs, and step-by-step reconstruction plan. Deliberately deferred (hardest of the three; XA + upgrade were the surer, shippable wins). Verified end-to-end via run_coverage.sh (host lcov 2.4): the aggregated report shows xa/xa.c 56.6%, xa/xa_map.c 77.5%, db/db_upg.c 13.9%.
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.
Summary
Closes coverage gaps in two cold subsystems and documents a third:
src/xa/xa.csrc/xa/xa_map.csrc/db/db_upg.csrc/db/db_upg_opd.cAll numbers measured with
CC=gcc --coverage, captured from.libsvia lcov 2.4(and cross-checked with
gcov), and reproduced end-to-end throughrun_coverage.sh. No engine code was changed.1. XA (surest win)
The existing
test/xaharness (chk.xa+src1..src5) needs an Oracle Tuxedotransaction manager (
atmi.h,tmboot,buildserver, …), which is unavailable —so
xa/xa.c+xa_map.cwere at 0%.test/xa/xa_direct.cis a Tuxedo-free transaction manager that drives theexported
db_xa_switchentry points directly(
xa_open/start/end/prepare/commit/rollback/recover/forget), does data-plane workthrough
DB_XA_CREATEhandles, exercises the internal two-phase-commit path(
DB_TXN->prepare→ commit/abort), and resolves an in-doubt prepared txn viathe XA recovery scan (
__txn_get_prepared,DB_FIRST/DB_NEXT) — plus theprotocol/argument error paths (
XAER_NOTA/INVAL/PROTO/ASYNC).Runs entirely in one process, fully resolves every txn before exit, and has a hard
SIGALRMself-timeout, so it cannot leave a prepared txn holding locks and cannothang.
run_xa_direct.shbuilds + runs it under a timeout, self-cleaning its home.2. On-disk upgrade
db_upg.cwas 0% (no group runsdb_upgrade; the full Tclupgradegroup needs aper-version fixture tree,
test/tcl/upgrade/databases/, absent from this fork).test/db/run_upgrade.shrunsdb_upgrade+db_verifyover the one committedold-format fixture (
test/csharp/bdb4.7.db, btree meta version-9), exercising theutility open + version-check + no-op-when-current path.
db_upg_opd.cstays 0%: theoff-page-duplicate conversion needs a genuinely pre-v9 db with off-page dups, which
the fork lacks (noted in the README).
3. db_repsite (deliberately deferred, documented)
db_repsite(the repmgr 100-series enabler) is absent from this fork — only theWindows
.vcxprojstub survives, and it is not in git history as a.cpp.Reconstructing a multi-process repmgr CLI and making the 100-series pass reliably
without hanging is materially larger/riskier than the XA + upgrade wins.
test/coverage/DB-REPSITE-TODO.mdcaptures the full reverse-engineered stdincommand protocol, the
DB_ENV->repmgr_site/repmgr_startAPI surface, and astep-by-step reconstruction plan so the follow-up is mechanical.
Wiring
run_coverage.shgains aCOV_XA_UPGblock (default on) that runs both driversafter the Tcl subset (mirroring the
COV_REPblock); README documents it.Real bug found
None. The one anomaly observed — forcing the fixture's meta version 9→8 to reach the
case 8conversion produced alast_pgnomismatch on verify — is a synthetic-fixtureartifact (a v9-layout file mislabeled v8), not an engine bug; that experiment is not
committed.
Validation
Every added test was run under
timeoutand confirmed PASS (repeatedly, no hang).Full
run_coverage.shverified end-to-end in the nix dev shell.