pdftract/notes/bf-md1uka.md
jedarden f5b8489676 docs(bf-md1uka): add troubleshooting guide for orphaned processes
- Added comprehensive troubleshooting section with investigation procedures
- Documented cleanup commands: pgrep, pkill, kill with safety warnings
- Included force-kill warnings with data loss risks and mitigations
- Provided verification procedures (immediate, post-cleanup, automated)
- Added 4-level escalation path for stubborn orphans
- Implemented decision flowchart and step-by-step investigation guide
- Closes bf-md1uka. Verification: notes/bf-md1uka.md
2026-07-07 02:55:19 -04:00

6.6 KiB

Verification: bf-md1uka - Troubleshooting Section and Cleanup Procedures

Summary

Implemented comprehensive troubleshooting documentation for orphaned process management, meeting all acceptance criteria.

Acceptance Criteria Status

Troubleshooting section exists in documentation

Created new file: docs/test-hygiene/troubleshooting-orphaned-processes.md

This is a standalone troubleshooting guide that complements:

  • orphaned-process-verification.md (verification procedures)
  • post-test-orphan-verification-integration.md (CI integration)

Provides step-by-step investigation guide

The guide includes:

  1. Quick Diagnosis Flowchart - Visual decision tree for investigation
  2. Step-by-step Investigation Procedures:
    • Step 1: Confirm orphan existence
    • Step 2: Analyze process details (PPID, state, age)
    • Step 3: Identify legitimate processes vs. true orphans
    • Step 4: Find the leaking test

Documents cleanup commands: pgrep, pkill, kill

Comprehensive command coverage:

  1. Detection commands (pgrep):

    • Basic: pgrep -af "pattern"
    • With full details: ps -fp $(pgrep -d "," "pattern")
    • With age info: ps -eo pid,etime,cmd | grep pattern
  2. Graceful cleanup (kill, pkill):

    • Single process: kill <PID>
    • All matching: pkill -TERM -f "pattern"
    • Signal sequence: SIGTERM → SIGINT → wait → force if needed
  3. Force cleanup (kill -9, pkill -9):

    • Last resort when graceful fails
    • Documented with warnings and mitigations

Quick Reference section provides all commands in a condensed format.

Includes warnings about force-killing processes

Dedicated section: "Force-Kill Warnings"

Covers:

  1. Data loss risks:

    • Unflushed buffers
    • Port leakage (TIME_WAIT state)
    • Resource leakage (temp files, shared memory, semaphores)
  2. When force-kill is necessary:

    • Process in uninterruptible sleep (D state)
    • Zombie process (Z state)
    • Stuck process (infinite loop, deadlock)
    • Emergency cleanup
  3. Mitigating risks:

    • Always try graceful first
    • Check for child processes before killing parent
    • Clean up resources after force kill

Shows how to verify cleanup success

Three levels of verification:

  1. Immediate verification:

    • Run verification script
    • Manual pgrep double-check
    • Port leakage check
  2. Post-cleanup validation:

    • Check for zombie processes
    • Check for uninterruptible sleep
    • Ensure clean system state
  3. Automated verification:

    • In-test RAII guards
    • CI integration (already documented)
    • Test teardown patterns

Provides escalation path for stubborn orphans

Four-level escalation model:

Level 1: Standard Cleanup (Automated)

  • Trigger: Verification script finds orphans
  • Action: Run --kill flag
  • Success: Exit code 0, no processes found

Level 2: Force Kill (Manual)

  • Trigger: Standard cleanup fails
  • Action: kill -9 <PID> or pkill -9 -f "pattern"
  • Investigation: Check process state (D/Z states)
  • Warning: Data loss risks documented

Level 3: Stubborn Processes (Advanced)

  • Trigger: Force kill doesn't work, process respawns
  • Investigation: Check PPID, look for respawners, check for fork bombs
  • Resolution: Kill parent, stop service, system-level cleanup

Level 4: Kernel/System Issues (Escalate to Admin)

  • Trigger: Cannot kill even as root, stuck in D state
  • Investigation: Check NFS mounts, hung block devices
  • Resolution: Unmount stale filesystems, may require reboot
  • Escalation: Document and contact admin

Implementation Details

File Created

docs/test-hygiene/troubleshooting-orphaned-processes.md

Structure

  1. Quick Diagnosis Flowchart - Visual decision tree
  2. Investigation Procedures - 4-step systematic approach
  3. Cleanup Commands and Safety - pgrep/pkill/kill usage
  4. Force-Kill Warnings - Risks and mitigations
  5. Verification Procedures - 3 verification levels
  6. Escalation Paths - 4-level escalation model
  7. Prevention Strategies - Code, test, and CI level
  8. Quick Reference Commands - Condensed command reference

Key Features

  • Decision matrix for identifying legitimate vs. orphaned processes
  • Process age analysis (recent vs. stale)
  • Parent process (PPID) analysis (alive vs. dead)
  • Process state analysis (S/D/Z states)
  • System resource cleanup (ports, temp files, shared memory)
  • Fork bomb detection (process count analysis)
  • Resawner investigation (systemd, init scripts)

Testing Verification

PASS Criteria

  1. Documentation exists at specified path
  2. Step-by-step investigation guide provided (4 steps with sub-procedures)
  3. Cleanup commands documented (pgrep, pkill, kill with examples)
  4. Force-kill warnings section included (risks, use cases, mitigations)
  5. Verification procedures documented (immediate, post-cleanup, automated, CI)
  6. Escalation paths provided (4 levels with triggers, actions, warnings)

WARN Criteria

None - all acceptance criteria fully met.

Integration with Existing Documentation

This new guide complements existing documentation:

  1. References existing docs:

    • Links to orphaned-process-verification.md
    • Links to post-test-orphan-verification-integration.md
    • Links to CLAUDE.md test hygiene section
  2. No duplication:

    • Verification procedures focus on using the detection script
    • CI integration focus on workflow integration
    • This guide focuses on troubleshooting and escalation
  3. Cross-referenced:

    • Other docs reference this guide for troubleshooting
    • Shared terminology and process patterns

Commands to Verify

# Check file exists
ls -la docs/test-hygiene/troubleshooting-orphaned-processes.md

# Check documentation structure
ls -la docs/test-hygiene/

# Verify links and references
grep -r "troubleshooting-orphaned-processes" docs/

Notes

  • The escalation path goes from automated → manual → advanced → admin
  • Force-kill is treated as a last resort with comprehensive warnings
  • System-level cleanup commands include safety checks
  • Kernel-level issues are flagged for admin escalation
  • Prevention strategies cover code, test, and CI levels

Next Steps

Consider adding cross-references from:

  • orphaned-process-verification.md → link to troubleshooting for stubborn cases
  • post-test-orphan-verification-integration.md → link to troubleshooting when CI fails

Implementation Date

2026-07-07

Commit

Ready to commit with message:

docs(bf-md1uka): add troubleshooting guide for orphaned processes