Skip to content

test(coverage): cover deadlock detector + DB_REGISTER (lock_deadlock.c 0.7%→66%, env_register.c 0%→55%) - #74

Closed
gburd wants to merge 1 commit into
masterfrom
agent/register-deadlock
Closed

test(coverage): cover deadlock detector + DB_REGISTER (lock_deadlock.c 0.7%→66%, env_register.c 0%→55%)#74
gburd wants to merge 1 commit into
masterfrom
agent/register-deadlock

Conversation

@gburd

@gburd gburd commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Wire the two multi-process suites that reach the previously-cold deadlock
detector and process-registry crash/recovery paths into run_coverage.sh.

What

New COV_DEAD_REG block (on by default), modeled on the existing COV_REP
block (driver-per-test, per-test timeout, orphan-worker cleanup — these tests
reset TESTDIR and each spawns child tclsh via wrap.tcl, so a hung worker
must not wedge the whole run):

  • Deadlock detectordead001..dead006 spawn ddscript.tcl workers via
    wrap.tcl to build a ring/clump lock cycle; __lock_detect
    (src/lock/lock_deadlock.c) picks a victim. dead002/dead003 set
    -lock_detect so detection runs in-process in each worker (which flushes
    its own .gcda); dead001/004/005 use the standalone db_deadlock.
  • DB_REGISTERenv007 + env012 use envscript.tcl to open the env with
    DB_REGISTER, "crash" a process (kill without close), then reopen with
    -recover/-failchk so a survivor detects the dead slot
    (__envreg_register/__envreg_isalive, src/env/env_register.c) and runs
    recovery.

No new test files — these tests already existed; they just were never in the
coverage run. Proc counts are trimmed to {2 4} ({4} for dead005) so each
finishes well inside the 300s timeout; the full {2 4 10} matrix adds only
minutes, no new lines.

Measured coverage (gcc --coverage, lcov from .libs)

file before after (line) after (branch)
lock/lock_deadlock.c 0.7% 65.9% 43.2%
env/env_register.c 0.0% 54.7% 43.1%
env/env_failchk.c 17.4% 65.2% 38.6% (bonus, DB_REGISTER failchk path)

Tests run vs hang

All eight pass reliably under timeout (300s each), workers cleaned up between
runs:

PASS dead001  PASS dead002  PASS dead003  PASS dead004
PASS dead005  PASS dead006  PASS env007   PASS env012

At the full untrimmed {2 4 10} matrix dead003/005/006 exceed 300s (slow,
not deadlocked — the 10-proc iterations just take minutes and add no new lines),
which is why the wired proc counts are trimmed. No real bug found: the detector
resolves every cycle and picks the expected victim; DB_REGISTER correctly
detects the crashed slot and recovers.

README updated (new env var row, a descriptive block, and the least-covered
table refreshed for the three files that moved off the floor).

…_coverage.sh

Add a COV_DEAD_REG block (on by default) that runs the two multi-process
suites reaching the deadlock detector and the process-registry crash/
recovery path, which the single-tclsh COV_TESTS loop cannot:

- dead001..dead006 spawn ddscript.tcl workers via wrap.tcl to build a
  ring/clump lock cycle; __lock_detect (src/lock/lock_deadlock.c) then
  picks a victim. dead002/003 run detection in-process in each worker.
- env007 + env012 use envscript.tcl to open the env with DB_REGISTER,
  "crash" a process, and let a survivor detect the dead slot
  (__envreg_register/__envreg_isalive, src/env/env_register.c) and run
  recovery/failchk.

Like the COV_REP block these run driver-per-test with a per-test timeout
and orphan-worker cleanup (they reset TESTDIR and a hung worker must not
wedge the run). Proc counts are trimmed to {2 4} ({4} for dead005) so
each finishes well inside the 300s timeout; the full {2 4 10} matrix adds
only minutes, no new lines.

Measured on r-class box (gcc --coverage, lcov from .libs):
  lock/lock_deadlock.c  0.7% -> 65.9% line (43.2% branch)
  env/env_register.c    0.0% -> 54.7% line (43.1% branch)
  env/env_failchk.c    17.4% -> 65.2% line (bonus, DB_REGISTER failchk path)

All eight tests pass reliably under timeout. README documents the block
and updates the least-covered table.
@gburd

gburd commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by rebased branch onto master (#72/#75); reopening.

@gburd gburd closed this Jul 29, 2026
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