Skip to content

test(coverage): XA (0→57%) + on-disk upgrade (0→14%); document db_repsite gap - #70

Merged
gburd merged 3 commits into
masterfrom
agent/xa-upgrade
Jul 29, 2026
Merged

test(coverage): XA (0→57%) + on-disk upgrade (0→14%); document db_repsite gap#70
gburd merged 3 commits into
masterfrom
agent/xa-upgrade

Conversation

@gburd

@gburd gburd commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes coverage gaps in two cold subsystems and documents a third:

subsystem file before after (line) after (func)
XA src/xa/xa.c 0% 56.6% 93.3%
XA src/xa/xa_map.c 0% 77.5% 80.0%
upgrade src/db/db_upg.c 0% 13.9% 40.0%
upgrade src/db/db_upg_opd.c 0% 0% (no fixture)

All numbers measured with CC=gcc --coverage, captured from .libs via lcov 2.4
(and cross-checked with gcov), and reproduced end-to-end through
run_coverage.sh. No engine code was changed.

1. XA (surest win)

The existing test/xa harness (chk.xa + src1..src5) needs an Oracle Tuxedo
transaction manager (atmi.h, tmboot, buildserver, …), which is unavailable —
so xa/xa.c + xa_map.c were at 0%.

test/xa/xa_direct.c is a Tuxedo-free transaction manager that drives the
exported db_xa_switch entry points directly
(xa_open/start/end/prepare/commit/rollback/recover/forget), does data-plane work
through DB_XA_CREATE handles, exercises the internal two-phase-commit path
(DB_TXN->prepare → commit/abort), and resolves an in-doubt prepared txn via
the XA recovery scan (__txn_get_prepared, DB_FIRST/DB_NEXT) — plus the
protocol/argument error paths (XAER_NOTA/INVAL/PROTO/ASYNC).

Runs entirely in one process, fully resolves every txn before exit, and has a hard
SIGALRM self-timeout, so it cannot leave a prepared txn holding locks and cannot
hang
. run_xa_direct.sh builds + runs it under a timeout, self-cleaning its home.

2. On-disk upgrade

db_upg.c was 0% (no group runs db_upgrade; the full Tcl upgrade group needs a
per-version fixture tree, test/tcl/upgrade/databases/, absent from this fork).

test/db/run_upgrade.sh runs db_upgrade + db_verify over the one committed
old-format fixture (test/csharp/bdb4.7.db, btree meta version-9), exercising the
utility open + version-check + no-op-when-current path. 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 the README).

3. db_repsite (deliberately deferred, documented)

db_repsite (the repmgr 100-series enabler) is absent from this fork — only the
Windows .vcxproj stub 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.md captures the full reverse-engineered stdin
command protocol, the DB_ENV->repmgr_site/repmgr_start API surface, and a
step-by-step reconstruction plan so the follow-up is mechanical.

Wiring

run_coverage.sh gains a COV_XA_UPG block (default on) that runs both drivers
after the Tcl subset (mirroring the COV_REP block); README documents it.

Real bug found

None. The one anomaly observed — forcing the fixture's meta version 9→8 to reach the
case 8 conversion produced a last_pgno mismatch on verify — is a synthetic-fixture
artifact
(a v9-layout file mislabeled v8), not an engine bug; that experiment is not
committed.

Validation

Every added test was run under timeout and confirmed PASS (repeatedly, no hang).
Full run_coverage.sh verified end-to-end in the nix dev shell.

gburd added 3 commits July 28, 2026 20:08
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%.
@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);

@gburd
gburd merged commit 4ddd858 into master Jul 29, 2026
45 of 47 checks passed
@gburd
gburd deleted the agent/xa-upgrade branch July 29, 2026 00:12
@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