test(coverage): hot backup, DB_CONFIG parser, compaction-recovery (env_backup 0->97%, env_config 3->72%) - #82
Merged
Conversation
The Tcl backup.tcl test drives hot backup only through the db_hotbackup utility, which calls DB_ENV->backup() with a NULL backup_handle -- so env/env_backup.c (the four backup config setters/getters and the backup callback setter/getter) was never reached (0% line/branch), and the backup->open/write/close callback branches of db/db_backup.c stayed cold. Add test/backup/backup_direct.c (same standalone-driver shape as test/xa/xa_direct.c): it calls set/get_backup_config for all four config enums (READ_COUNT/READ_SLEEP/SIZE/WRITE_DIRECT, the last on and off to hit both F_SET and F_CLR), the getters-before-alloc EINVAL branches, and set/get_backup_callbacks, then runs DB_ENV->backup()/dbbackup() with write callbacks installed so the callback copy path in db_backup.c executes. Self-cleans its home dir and runs under a hard SIGALRM + timeout guard. Lift (coverage subset): env_backup.c 0%->96.7% line / 0%->81.8% branch; db_backup.c callback path 43.0% line / 29.6% branch.
Three recovery record handlers in db/db_rec.c -- __db_merge_recover, __db_pgno_recover, __db_pg_trunc_recover (~330 lines) -- fire only when btree compaction / page-truncation log records are replayed. No recd0NN test runs compaction under recovery, so all three were completely cold. Add test/db/recd_compact.c: it fills a small-page btree, deletes a large contiguous range to leave sparse/empty pages, runs DB->compact(DB_FREE_SPACE) in a transaction (logging __db_merge / __db_pgno / __db_pg_trunc records), then re-opens the environment under DB_RECOVER_FATAL so catastrophic recovery replays the whole log from the start, driving the redo/forward-roll branches of those handlers. It verifies the database still opens and reads back after recovery. Same self-clean + hard-timeout shape as the XA/upgrade drivers. Lift (coverage subset, combined with recd002:btree + recd016): db_rec.c 18%->~27% line, ~13%->~18% branch; merge/pgno/pg_trunc/relink no longer cold.
…vers into subset Add to the default COV_TESTS: env007 (comprehensive DB_CONFIG parser test -- writes a DB_CONFIG with many directives and confirms values via getters, exercising __env_read_db_config + __config_scan; was registered but never in the subset), recd002:btree (split recovery) and recd016:btree (catastrophic recovery) for db_rec.c branch coverage. Add a COV_BACKUP block (default on, same gating shape as COV_XA_UPG) that runs the two new standalone drivers: test/backup/run_backup_direct.sh and test/db/run_recd_compact.sh. Both self-clean and run under a hard timeout. Document the new surface in README.md (COV_BACKUP table row + section). Lift (coverage subset): env_config.c 3.2%->71.8% line / 1.2%->61.4% branch (via env007); env_backup.c 0%->96.7%/81.8%; db_rec.c 18%->27.1% line / 13.2%->18.0% branch.
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.
Tests added / wired
test/backup/backup_direct.c— C driver for the hot-backup config/callback API (all 4 config enums, WRITE_DIRECT, getters-before-alloc EINVAL, callbacks,backup()/dbbackup()) thatdb_hotbackup(NULL backup_handle) never reaches.test/db/recd_compact.c— compaction-under-recovery: compacts a sparse btree (logs merge/pgno/pg_trunc), thenDB_RECOVER_FATALreplays — the only way those ~330 lines of recover handlers run.COV_BACKUP=1block (default on), self-cleaning + timeout-guarded.No bugs found. Both drivers verified PASS under timeout on repeat runs.