Systematic Debugging and Root Cause Analysis Questions
Methodically diagnosing failures and identifying their true cause. Covers hypothesis-driven debugging, bisection and instrumentation, full-stack and production diagnosis, debugging under pressure, and root-cause analysis that prevents recurrence. Emphasizes a repeatable process over guesswork.
Explain the difference between correlation and causation in the context of incident diagnostics. Provide a concrete example where a metric (e.g., increased error rate) correlates with a recent deployment but is actually caused by a third variable (for example, a traffic reroute). Describe at least three methods you would use to test true causation versus coincidental correlation.
Sample Answer
Correlation is "these two things moved together"; causation is "one of them made the other happen." An incident-diagnostics investigation that stops at correlation risks fixing (or blaming) the wrong thing.
Worked example
Error rate rises right after a deploy. That's a correlation. The actual cause might be the deploy itself, or it might be a third variable: a traffic reroute that happened to land at the same time, sending a different, more error-prone traffic mix to this service, with the deploy being coincidental.
Three ways to test true causation
- Precise timing alignment: does the error rate change at the exact deploy timestamp (to the second/minute), or does it lag or lead it? A reroute event with its own distinct timestamp that better matches the error onset is evidence against the deploy being the cause.
- Controlled comparison: roll the deploy back on a subset (a canary) while leaving the traffic conditions unchanged, and see if errors clear on just that subset; if errors persist despite the rollback, the deploy wasn't the cause.
- Mechanism check: can you point to a specific code/config change in the deploy that plausibly produces this exact error, versus the reroute plausibly sending edge-case traffic (different geography, different client version) that the service already mishandled before the deploy.
Generalizing to model diagnostics
The identical discipline applies to a model metric correlating with a deployment event: before concluding the new model caused a metric drop, check whether a confound (a simultaneous data-pipeline change, a seasonal effect, a shift in the underlying user population) explains it just as well, and use the same three tests (timing precision, a controlled comparison holding the model fixed while varying the other candidate, and a plausible mechanism) before attributing cause.
Trade-offs and pitfalls
Under time pressure, mitigating based on correlation alone (rolling back the most recent deploy because it's the most recent) is often the right immediate action even before causation is proven, but the RCA writeup should not present that correlation as a proven root cause without the additional checks above.
A nightly pipeline that computes model evaluation metrics began producing noticeably lower evaluation numbers, but the production model metrics remain stable. Propose a reproducible RCA to determine whether the nightly pipeline or its source data changed, and how you would prove your conclusion rather than merely suspect it.
Sample Answer
A nightly metrics pipeline drifting lower while the live production model stays stable is strong evidence the pipeline itself changed, not the model: the investigation should first rule out the pipeline before doubting the model.
RCA plan
- Checksum the inputs: compare the checksum/hash of the dataset the nightly job consumed against the expected/previous dataset; a silent upstream data change (a new day's data with a schema drift, a partial load, a different sample) is the most common cause of "the eval script says worse, but production says fine."
- Dataset versioning: pin and log the exact dataset version/snapshot used for each nightly run so a regression can be attributed to a specific version bump rather than an ambiguous "sometime between runs."
- Golden artifacts: maintain a small, fixed, hand-verified reference dataset with known expected metric values; rerun the nightly evaluation code against that golden set specifically, and if it now produces different numbers than its own historical golden-set baseline, the bug is in the evaluation code, not the data; if the golden-set numbers are unchanged, the regression is genuinely in the day's input data. For example, the golden set's accuracy might hold steady at 0.842 across both last night's run and a rerun today, while the day's actual input checksum changed from
abc123todef456; that combination, golden set stable, real input checksum different, is the concrete evidence that the input data changed and the evaluation code did not. - Compare the nightly pipeline's own historical metric on a fixed replay dataset run-over-run, isolating whether the pipeline's code changed behavior independent of data.
Trade-offs and pitfalls
Skipping straight to "the model regressed" without checking the pipeline first risks an expensive, unnecessary retraining or rollback cycle for a bug that was actually in the measurement, not the thing being measured; the golden-artifact check is cheap and should run before any model-level conclusion is drawn.
Describe techniques to detect silent data corruption in storage systems, and how you would design automated remediation or safe rollbacks when corruption is found.
Sample Answer
Silent data corruption is the dangerous case precisely because nothing crashes or errors; the system keeps running and reporting success while the data itself is wrong, so detection has to be built in deliberately rather than relying on something failing loudly.
Detection techniques
- Checksums/CRCs: compute and store a checksum alongside data at write time, and verify it on read; a mismatch proves corruption occurred somewhere between write and read without needing to know the mechanism.
- Write-then-read verification: immediately read back what was just written and compare, catching corruption introduced by the write path itself (a common check for critical writes).
- Periodic scrubbing: proactively read and verify all stored data on a schedule (not waiting for an application to happen to read a corrupted record), surfacing corruption before something downstream actually consumes the bad data.
- Replication consistency checks: compare checksums/digests across replicas that should be identical; a divergence flags corruption on at least one replica, even before any single reader notices.
- Alerting: any of the above should page/alert immediately on a detected mismatch, since silent corruption left undetected for a long window is much harder to recover from cleanly.
What a detected mismatch actually looks like
For example, object orders/2026-07-14/part-0091 is written with checksum a1b2c3; on the next scheduled scrub, recomputing the checksum over the stored bytes returns d4e5f6 instead, a mismatch. That single mismatch is what flags this specific object, not the whole dataset, for recovery; checking replica 2 for the same object shows its checksum still matches the original a1b2c3, so remediation restores from replica 2 rather than attempting to patch the corrupted bytes in place.
Recovery and remediation
Automated remediation should default to safe rollback/recovery from a known-good replica or backup rather than attempting to "fix" the corrupted bytes in place, and should verify the recovered data against its checksum before considering the incident closed. When corruption is only discovered later (e.g., in nightly backups already taken), the recovery plan needs to first identify precisely which backups are still clean (checksum each one against its recorded value, working backward from the most recent), then restore to the last confirmed-clean point, and only then investigate how corruption entered the pipeline in the first place so it doesn't happen again.
Verified related cases
The same detection discipline (checksums, cross-region replication checks, versioned objects, reprocessing from a known-good source) applies directly to bit-flip corruption discovered in cloud object storage, and a distributed storage cluster (e.g., Ceph) returning occasionally corrupted objects is diagnosed the same way: inspect cluster health/scrub state, run an explicit scrub-and-verify pass, and repair from a known-good replica rather than attempting an in-place patch of a corrupted object.
Trade-offs and pitfalls
Scrubbing and cross-replica checks cost real I/O and compute; the practical trade-off is running them on a schedule frequent enough to bound the "how much could have silently corrupted before we noticed" window to an acceptable size, not running them continuously at full intensity, which is rarely necessary and can itself compete with production traffic for I/O bandwidth.
A Spark ETL job that used to finish in 1 hour now takes 10 hours after a recent code change. Walk through a structured approach to diagnose the regression, including which Spark UI signals you would inspect and what targeted experiments you would run to isolate the change.
Sample Answer
A Spark job whose runtime jumped 10x after a code change is a structured diagnosis problem: compare stages, not guess at code.
Diagnostic approach
- Compare Spark UI stage-by-stage between a recent successful (fast) run and the current slow run: which specific stage's duration grew disproportionately, and within that stage, shuffle read/write volume (shuffle: Spark redistributing data across the network between stages so a join or groupBy can bring matching keys together on the same worker; the UI reports how many bytes were shuffled, i.e. written and read across the network, for that stage), spilled memory to disk, and task-level skew (a few tasks taking far longer than the median, pointing at data skew on a key).
- Executor and OS-level metrics: CPU utilization (is it pegged, suggesting compute-bound, or is it idle/waiting, suggesting shuffle/IO-bound), GC time (excessive GC steals compute cycles from actual work), and disk I/O (spilling to disk is a common silent 10x-slowdown cause when a shuffle or join no longer fits comfortably in memory).
- Isolate the change itself: compare the physical execution plan (DAG stands for directed acyclic graph, Spark's plan of the stages and how data moves between them, so comparing DAGs before and after the change shows whether the execution strategy itself changed, not just how long it ran) before and after the code change for structural differences (a join strategy that changed from broadcast to shuffle join (a broadcast join copies the smaller table whole to every worker so no data has to move over the network; a shuffle join instead redistributes both tables across the network by matching key, which is far more expensive once the smaller table no longer fits comfortably in memory on every worker), an added wide transformation, meaning one like a join or groupBy that needs rows sharing a key gathered onto the same worker and therefore forces a shuffle, unlike a narrow transformation such as map or filter that each partition can finish independently), run smaller subsets of data to see if the slowdown scales linearly or catastrophically with size (catastrophic scaling points at skew or a spill threshold being crossed), and check whether data cardinality itself changed (a key that used to have low cardinality now has a long tail, causing skew that wasn't there before).
In practice, step 1 (the stage-by-stage comparison) is usually enough on its own to point at where the regression lives; steps 2 and 3 are the depth you reach for to confirm exactly why, not something you need to exhaustively run for every regression.
A concrete worked trace
Suppose the Spark UI history shows: before the code change, the join stage (call it Stage 4) processed the same roughly 1.5 million rows it always does, wrote about 3 GB of shuffle data, and finished in 6 minutes, with its slowest task at 9 seconds against an 8-second stage average, essentially no skew. After the change, Stage 4 still processes the same 1.5 million rows, but now writes roughly 300 GB of shuffle data, takes 7.5 hours, and its slowest task runs 42 minutes against a 25-second average for the rest of that stage's tasks, a sharp skew signal. Diffing the DAG for that stage shows the join operator switched from a broadcast join to a shuffle join: the smaller side of the join grew past Spark's broadcast size threshold (a configurable limit below which Spark copies a table to every worker instead of shuffling it), so every run since the code change now pays for a full network shuffle on a table that used to fit in a broadcast. That single before/after comparison, shuffle-write volume up roughly 100x and one task badly skewed, is what points the fix at the join strategy rather than at general code slowness.
A related, faster-diagnosis variant
The same "2 hours became 8 hours" pattern under time pressure narrows fastest by checking, in order: is it CPU-bound (profile/sampling shows compute-heavy stages), IO-bound (shuffle/spill metrics elevated), or data-driven (row counts/cardinality changed upstream) - each points at a different immediate mitigation (more executors for CPU-bound, tuning shuffle partitions or memory for IO-bound, or addressing an upstream data change directly).
Trade-offs and pitfalls
Reflexively adding more executors/memory as the first response can mask (temporarily) a skew problem that will resurface at the next data growth; comparing DAG plans and task-level skew before scaling resources catches the actual cause instead of paying for more hardware to paper over it.
Explain how you decide which events to log at each log level (debug/info/warn/error/fatal) and what to instrument with metrics versus traces versus logs. Provide guidelines for structured logging, correlation IDs, sampling decisions, and approaches to avoid log spam while retaining useful diagnostic signal.
Sample Answer
Logs, metrics, and traces answer different questions, and picking the wrong one first wastes the minutes that matter most in an investigation.
What each answers
- Metrics: aggregate, cheap-to-store numeric signals over time ("is error rate elevated, since when, how much"). Best for detecting that something is wrong and roughly when.
- Traces: the path and timing of one request across services ("where did this specific request spend its time, which downstream call failed"). Best for localizing where in a distributed call graph a problem lives.
- Logs: detailed, often unstructured records of what a specific component did ("what exact error, what input, what stack trace"). Best for the why once metrics and traces have pointed at a component.
Log levels and instrumentation guidelines
- debug: verbose, developer-facing detail, off by default in production.
- info: normal operational milestones (request received, job completed).
- warn: something recoverable happened that a human should notice trends in.
- error: an operation failed and needs attention.
- fatal: the process cannot continue.
Attach a correlation ID to every log line and trace span for a given request so the three signal types can be joined together later, and sample verbose logs (e.g., 1% of requests, or 100% only when an anomaly is already flagged) rather than logging everything at full volume, which both costs money and buries the useful signal.
Worked triage order
For a latency spike: check the metric first (confirm it's real and scope it: one endpoint, one region, all traffic), then the trace for a slow request in that scope (find which span is slow), then the logs for that specific span (find the exact error or slow query). Going log-first on a fleet-wide problem means grepping millions of lines before you even know what you're looking for.
Trade-offs and pitfalls
Over-logging at debug level in production is a common self-inflicted problem: it raises cost, and paradoxically makes finding the one relevant line harder. The fix is dynamic log levels (raise verbosity temporarily and narrowly, not permanently and broadly) plus structured fields so a query can filter precisely instead of relying on human eyeballing.
Unlock Full Question Bank
Get access to all 20 Systematic Debugging and Root Cause Analysis interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.