- 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
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:
- Quick Diagnosis Flowchart - Visual decision tree for investigation
- 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:
-
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
- Basic:
-
Graceful cleanup (kill, pkill):
- Single process:
kill <PID> - All matching:
pkill -TERM -f "pattern" - Signal sequence: SIGTERM → SIGINT → wait → force if needed
- Single process:
-
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:
-
Data loss risks:
- Unflushed buffers
- Port leakage (TIME_WAIT state)
- Resource leakage (temp files, shared memory, semaphores)
-
When force-kill is necessary:
- Process in uninterruptible sleep (D state)
- Zombie process (Z state)
- Stuck process (infinite loop, deadlock)
- Emergency cleanup
-
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:
-
Immediate verification:
- Run verification script
- Manual pgrep double-check
- Port leakage check
-
Post-cleanup validation:
- Check for zombie processes
- Check for uninterruptible sleep
- Ensure clean system state
-
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
--killflag - Success: Exit code 0, no processes found
Level 2: Force Kill (Manual)
- Trigger: Standard cleanup fails
- Action:
kill -9 <PID>orpkill -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
- Quick Diagnosis Flowchart - Visual decision tree
- Investigation Procedures - 4-step systematic approach
- Cleanup Commands and Safety - pgrep/pkill/kill usage
- Force-Kill Warnings - Risks and mitigations
- Verification Procedures - 3 verification levels
- Escalation Paths - 4-level escalation model
- Prevention Strategies - Code, test, and CI level
- 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
- ✅ Documentation exists at specified path
- ✅ Step-by-step investigation guide provided (4 steps with sub-procedures)
- ✅ Cleanup commands documented (pgrep, pkill, kill with examples)
- ✅ Force-kill warnings section included (risks, use cases, mitigations)
- ✅ Verification procedures documented (immediate, post-cleanup, automated, CI)
- ✅ 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:
-
References existing docs:
- Links to
orphaned-process-verification.md - Links to
post-test-orphan-verification-integration.md - Links to CLAUDE.md test hygiene section
- Links to
-
No duplication:
- Verification procedures focus on using the detection script
- CI integration focus on workflow integration
- This guide focuses on troubleshooting and escalation
-
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 casespost-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