The full answer
AQE doesn't handle failures itself. Fault tolerance in Spark comes from the scheduler, task retries and lineage, and those work the same way whether AQE is on or off. What AQE adds is that the plan of the remaining stages is decided only after earlier stages finish, and recovery fits around that.
What happens when something fails
- A task fails: the task scheduler retries it, on another executor if possible, up to
spark.task.maxFailures(4) times. If it still fails, the stage fails and the query fails. - An executor is lost: its running tasks are rescheduled. If shuffle output on that executor is lost, the DAG scheduler re-runs only the map tasks that produced it, using lineage. An external shuffle service or shuffle tracking reduces how often this happens.
- A fetch fails in a later stage: the scheduler re-runs the parent stage that produced the missing shuffle files, then continues.
- Stage retries are limited by
spark.stage.maxConsecutiveAttempts(4 by default).
How this interacts with AQE
- AQE breaks the query into query stages at shuffle and broadcast exchanges. A completed query stage's output and statistics are kept; when a downstream stage needs recomputed input, the scheduler regenerates the lost partitions rather than re-planning the query.
- Re-optimisation only happens between query stages, based on completed stages, so a task retry inside a stage doesn't change the plan.
- Because AQE plans are built from runtime statistics, re-running the whole query can give a different final plan (for example a different number of coalesced partitions), but the results are the same.
- A converted broadcast join that runs out of memory fails like any broadcast join; the fix is a lower threshold or more memory, not a retry.
Speculative execution
spark.speculation (off by default) launches duplicate copies of very slow tasks and uses whichever finishes first. It helps with slow nodes, not with data skew, and it's separate from AQE.
What actually makes jobs resilient
- Idempotent outputs: writes to table formats such as Delta Lake commit atomically, so a failed job leaves no partial data and can be rerun.
- Checkpoints or persisted intermediate results for very long lineages.
- Sizing executors so tasks don't run out of memory, and fixing skew, which together cause most repeated task failures.
- For streaming queries, checkpoint locations let a query restart from the last committed batch.
In an interview Say clearly that AQE is an optimiser, not a recovery mechanism; explain task retries, stage re-execution and lineage; then explain that AQE works with them because it re-optimises only between completed stages.
Last updated 16 October 2026
Sources