Troubleshooting & Debugging Scenarios
Real-world debugging scenarios across all domains — each walks through a symptom, root cause analysis, and the fix.
Kubernetes (1)
- Kubernetes: Why Is My Pod Stuck in ContainerCreating for 10 Minutes With No Error Events? A scenario-based debugging walkthrough: one pod sits in ContainerCreating for twelve minutes while every other pod scheduled to the same node starts in seconds. The root cause is a ReadWriteOnce volume still attached to a dead node, so the attach-detach controller never creates a VolumeAttachment for the new node and the kubelet's mount wait silently times out. Trace the fix through kubectl get volumeattachments, the kubelet's unattached-versus-unmounted volume lists, and the out-of-service taint.
Docker (2)
- Docker: Why Does My Image Run Locally but Fail With exec format error in CI? A scenario-based debugging walkthrough: an image built and pushed from an Apple Silicon laptop runs perfectly there but dies instantly with `exec /app/server: exec format error` on an amd64 CI runner. The root cause is that a plain `docker build` publishes a single-platform manifest for the builder's own architecture, and Docker's classic image store cannot hold a manifest list at all. Trace the fix through `docker buildx imagetools inspect`, the OCI image index, and a docker-container-driver multi-platform push.
- Docker: Why Is My Container OOMKilled When docker stats Shows It Under the Limit? A scenario-based debugging walkthrough: a container exits 137 with State.OOMKilled true while the application's own heap gauge and `docker stats` both show it comfortably under `--memory`. The root cause is that the kernel checks `memory.current` — anonymous memory plus page cache plus slab — against `memory.max`, while `docker stats` subtracts `inactive_file` first and the JVM reports only its heap. Trace the fix through the cgroup v2 files, `memory.events`, and container-aware heap sizing.
Microservices (1)
- Microservices: Why Does My Distributed Trace Show Gaps Between Services? A scenario-based debugging walkthrough: an OpenTelemetry trace shows 500ms gaps between service calls even though network latency is <5ms. The root cause is async context propagation loss when using Task.Run without Activity.Current. Trace the fix through W3C traceparent headers, ActivitySource, and baggage.
CI/CD (3)
- CI/CD: Why Are My GitHub Actions Secrets Empty Strings on Pull Requests from Forks? A scenario-based debugging walkthrough: a workflow secret resolves normally on same-repo pull requests and silently becomes an empty string on pull requests from forks. The root cause is that GitHub withholds every secret except GITHUB_TOKEN from a pull_request run triggered by a fork, because that run executes the fork's own code. Trace the fix through the masked-value log output, the pull_request vs pull_request_target context difference, and the workflow_run artifact handoff that solves it without re-introducing the pwn-request hole.
- CI/CD: Why Does the Test Suite Pass on Every Developer Machine and Fail Only on the Runner? A scenario-based debugging walkthrough: a build that succeeds on every macOS and Windows developer machine and fails deterministically on ubuntu-latest with a module-not-found error. The root cause is filesystem case sensitivity on the Linux runner combined with Git's core.ignoreCase, which makes a case-only filename correction invisible to git status locally. Trace the fix through git ls-files, the two-step git mv, and a case-collision guard step in the workflow.
- CI/CD: Why Does actions/cache Report a Miss on Every Single Run? A scenario-based debugging walkthrough: actions/cache writes a new entry on every run but never restores one, so the build never gets faster. The root cause is a primary key built from the commit SHA with restore-keys that repeat the same unmatchable prefix, compounded by GitHub's branch-scoping rule for cache reads. Trace the fix through the real 'Cache not found for input keys' log line, the Actions caches list, and the key-version-branch lookup the action actually performs.
Databases (3)
- Databases: Why Is the Same Query 8ms in Dev and 4 Seconds in Production? A scenario-based debugging walkthrough: an indexed query that takes 8ms in dev does a 4-second sequential scan in production against the same schema. The root cause is stale planner statistics — autovacuum's analyze threshold scales with table size, so a 204-million-row table needs 20 million modifications before autoanalyze fires. Trace the fix through EXPLAIN (ANALYZE, BUFFERS) estimated-vs-actual rows, pg_stat_user_tables.n_mod_since_analyze, and pg_stats.most_common_freqs.
- Databases: Why Do Two Transactions Deadlock Only Under Concurrent Load? A scenario-based debugging walkthrough: Postgres logs deadlock detected dozens of times an hour at peak traffic, always between the same two statements, and never once in staging. The root cause is two code paths updating the same rows in opposite primary-key order, producing a cycle in the wait-for graph. Trace the fix through the server log's DETAIL block, ShareLock on transaction, deadlock_timeout, and log_lock_waits.
- Databases: Why Does the App Time Out Acquiring a Connection While the Database Is Idle? A scenario-based debugging walkthrough: Npgsql throws connection pool has been exhausted while Postgres sits at 4% CPU with two active queries. The root cause is a transaction held open across a 2.4-second external HTTP call, so pooled connections are occupied without the database doing any work. Trace the fix through pg_stat_activity state = idle in transaction, wait_event ClientRead, and Little's Law pool sizing.
Observability (1)
- Observability: Why Does My Trace End at the Publish Call and Reappear as a Second, Parentless Trace? A scenario-based debugging walkthrough: a checkout trace ends cleanly at 84ms while the customer waits 41 seconds, and the work that actually took the time shows up as a separate root trace. The root cause is that OpenTelemetry's active Context is scoped to one execution unit and nothing writes traceparent into the broker's message headers. Trace the fix through the W3C traceparent wire format, TextMapPropagator Inject/Extract, and the exported span's all-zero parentSpanId.
ASP.NET WebAPI (2)
- ASP.NET WebAPI: Why Is This Request Timing Out After 30 Seconds? A scenario-based debugging walkthrough: a WebAPI endpoint that reliably hangs for 30 seconds then returns 502 from the load balancer. The root cause is a synchronous blocking call inside an async endpoint, which exhausts the ASP.NET thread pool. Trace the fix through Kestrel connection logs, thread-pool counters, and adding ConfigureAwait.
- ASP.NET WebAPI: Why Does the Authorized Endpoint Return 401 When the Token Is Valid? A scenario-based debugging walkthrough: a JWT-protected WebAPI endpoint rejects every request with 401 even though the same token works against the identity server's introspection endpoint. The root cause is misordered middleware — authentication runs before the JWT bearer handler has been registered. Trace the fix through middleware order, Minimal API vs controller divergence, and capture the pipeline with IStartupFilter.
Azure (2)
- Azure: Why Are My Azure SQL Queries Slow After 1 PM Every Day? A scenario-based debugging walkthrough: an API backed by Azure SQL that is fast in the morning but degrades sharply after 1 PM. The root cause is the DTU service tier's resource governor throttling the database under sustained load combined with an implicit table scan on a frequently queried indexed view. Trace the fix through Query Performance Insight, sys.dm_db_resource_stats, and index tuning.
- Azure: Why Is My App Service Returning 503 Service Unavailable Every 10 Minutes? A scenario-based debugging walkthrough: an ASP.NET Core app on Azure App Service that returns 503 every 10 minutes on the dot. The root cause is the default App Service auto-heal recycling combined with a process-wide singleton that cannot recover from an unrecoverable state. Trace the fix through App Service diagnostic logs, Kudu process dumps, and WinDBG analysis.
AWS (2)
- AWS: Why Does My EC2 Instance Get S3 Access Denied When the Role Looks Correct? A scenario-based debugging walkthrough: an EC2 instance with an IAM role that should have full S3 read access consistently returns AccessDenied. The root cause is an S3 bucket policy that grants access by IAM user principal ARN but the EC2 role uses a role principal ARN, which does not match. Trace the fix through IAM policy evaluation logic, the S3 Access Analyzer, and CloudTrail event history.
- AWS: Why Is My ALB Returning 504 When the EC2 Instance Is Healthy? A scenario-based debugging walkthrough: an Application Load Balancer that returns 504 Gateway Timeout even though the target group health checks pass and the EC2 instance responds to direct HTTP calls. The root cause is the ALB's idle timeout combined with the application's streaming response behavior — the ALB closes the connection before the server finishes sending data. Trace the fix through ALB access logs, connection timing analysis, and response buffer tuning.
By Symptom Pattern
Thread Pool / Async Starvation
- ASP.NET WebAPI: Why Is This Request Timing Out After 30 Seconds? — Synchronous EF call blocks thread pool under load
- Kubernetes: Pod Evicted Under Disk Pressure — Memory pressure triggers disk pressure eviction
Authentication / Authorization Failures
- ASP.NET WebAPI: Why Does the Authorized Endpoint Return 401 When the Token Is Valid? — Middleware order: authentication runs before controller endpoints are registered
- Azure: Managed Identity Token Not Found — IMDS endpoint unreachable from container
Network / Load Balancer Timeouts
- AWS: ALB Returns 504 When EC2 Instance Is Healthy — ALB idle timeout (60s) < server processing time for large uploads
- Azure: App Service Returns 503 Every 10 Minutes — HttpClient socket exhaustion triggers auto-heal recycle
Database / Storage Performance
- Azure SQL: Why Are My Azure SQL Queries Slow After 1 PM Every Day? — DTU throttling from sustained table scans on unindexed views
- AWS S3: Access Denied Despite Correct IAM Role — Bucket policy principal mismatch (user ARN vs role ARN)
Distributed System Debugging
- System Design: Tracing a Request Across Microservices — Correlation IDs, W3C traceparent, and OpenTelemetry context propagation
- System Design: Debugging Latency Spikes in Event-Driven Architecture — Queue depth, consumer lag, and backpressure signals
Contributing New Scenarios
Each scenario follows the Symptom → Reproduce → Root Cause → Fix → Prevention template:
## The symptom
> "User-visible error message or behavior"
## Reproduce
Minimal code/config to trigger the issue locally
## The root cause chain
1. Immediate trigger
2. Underlying mechanism
3. Confirming evidence (logs, metrics, counters)
## The fix
Code/config change with explanation
## Deeper checks for production
- Additional monitoring
- Related configs to verify
## Prevention checklist
- [ ] Items to add to code review / CI
Want to add a scenario? Open a PR with a new post in _posts/ tagged with both the domain (e.g., kubernetes) and troubleshooting + debugging.