test(coverage): C driver for cold btree/db recover handlers (irep/root/rcuradj/ovref) - #91
Closed
gburd wants to merge 2 commits into
Closed
test(coverage): C driver for cold btree/db recover handlers (irep/root/rcuradj/ovref)#91gburd wants to merge 2 commits into
gburd wants to merge 2 commits into
Conversation
The Tcl recd0NN suite never produces the exact log records replayed by
four per-operation recovery handlers (recd003 does NOT unlock them --
they need scenarios no bounded recd test hits):
bt_rec.c __bam_root_recover -- subdb-create logs a __bam_root record
(root page set on file meta page)
bt_rec.c __bam_irep_recover -- compaction merges pages, replacing a
parent separator via __bam_pupdate ->
__bam_pinsert(BPI_REPLACE) -> __bam_irep
bt_rec.c __bam_rcuradj_recover-- rrecno (DB_RENUMBER) cursor adjust
logged under a CHILD txn, then aborted
(handler acts only on DB_TXN_ABORT)
db_rec.c __db_ovref_recover -- DB->truncate() of a btree with overflow
items logs __db_ovref(-1) per ovfl page
recd_handlers.c builds each scenario and replays it under DB_RECOVER /
DB_RECOVER_FATAL (and txn abort for the undo paths), verifying DB
integrity after recovery. Hard SIGALRM guard, self-cleaning home dir,
same shape as recd_compact.c. Runs in ~9s.
Lift (driver alone, all four go 0 calls -> covered):
__bam_root_recover ~53% branch
__bam_irep_recover ~60% branch
__bam_rcuradj_recover ~74% branch
__db_ovref_recover ~68% branch
Documented-but-uncovered: __db_cksum_recover. Its __db_cksum marker
record is only written on a checksum error during a logged page-in;
recovery's redo re-reads the still-corrupt page and panics (pgin failed)
before reaching the marker, so the handler never runs. Tcl recd016 has
the same limitation.
Run test/db/run_recd_handlers.sh alongside recd_compact in the COV_BACKUP driver block (default on), and document the four newly-covered recover handlers (and the one documented-uncovered __db_cksum_recover) in the coverage README.
Coccinelle convention checksNo new violations. ✅ Resolved since baseline (2) -- update dist/cocci/baseline.txt to lock these in. |
ABI diff vs
|
Collaborator
Author
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.
What
Adds
test/db/recd_handlers.c, a standalone C driver (modeled onrecd_compact.cfrom PR #82) that produces log records for fourper-operation recovery handlers the Tcl
recd0NNsuite never reaches, thenreplays them under recovery. PR #89's COV_RECD note already flagged these as
still-cold: recd003 "does NOT unlock the cold
__bam_root/__bam_irep/__bam_rcuradjor__db_ovrefhandlers (they need scenarios no bounded recdtest hits)."
__bam_root_recoverbt_rec.c__bam_root(root page set on file meta page). commit → REDO, abort → UNDO__bam_irep_recoverbt_rec.c__bam_pupdate → __bam_pinsert(BPI_REPLACE) → __bam_irep. (BPI_UPDATE/__bam_pupdateis only ever driven by compaction; plain delete usesBTD_RELINK.) commit + fatal recover → REDO__bam_rcuradj_recoverbt_rec.cDB_RENUMBER) cursor adjust logged under a child txn (CURADJ_LOGneedstxn->parent != NULL), with a 2nd cursor parked sonc > 0, then abort the child txn (handler acts only onDB_TXN_ABORT)__db_ovref_recoverdb_rec.cDB->truncate()of a btree with overflow items →__db_ovref(-1)per overflow page (db_reclaim.c __db_truncate_callback). commit → REDO, abort → UNDOEach scenario verifies DB integrity after recovery. Hard
SIGALRMguard,self-cleaning home dir, ~9s total. Wired into the
COV_BACKUPdriver block(default on) next to
recd_compact, and documented in the coverage README.Coverage result (measured,
CC="gcc --coverage", driver alone)Baseline (no run): all five target handlers at 0 calls (no
.gcda).After
recd_handlers:Driver-alone file totals:
bt_rec.c14.7% br /db_rec.c30.0% br. Thesehandlers were fully cold before; the driver takes 4 of the 5 flagged handlers
from 0 calls → covered (both REDO and UNDO paths where applicable).
Not covered (documented):
__db_cksum_recoverIts
__db_cksummarker record is only logged when a checksum error isdetected on a page-in with logging enabled (
db_conv.c:161). On the recoverypass, the redo of the records that built that page re-reads the
still-corrupt page and panics (
pgin failed for page N) before recoveryreaches the marker record — so the handler never executes. Confirmed by
running Tcl
recd016(btree) under coverage: it also leaves__db_cksum_recoverat 0 in-process (it drives the standalonedb_recoverutil, whose in-process handler coverage is likewise 0). This is a genuine
reachability gap, not a driver bug; left documented in the driver header and
README rather than forcing a synthetic hit.
No engine bugs found
All four covered handlers replay cleanly (redo + undo) and every scenario
verifies data/DB integrity after recovery. No recovery misbehavior observed.
Validation
Built
--enable-debug --enable-testin the nix dev shell, compiled the driveragainst
.libs/libdb-5.3.so, ran undertimeout—recd_handlers: PASS,run_recd_handlers.sh: PASS, 8.75s wall. No coverage artifacts committed;build_windows/,.github/, AWS, etc. untouched.