Fix LocalExecutor crash on non-picklable exceptions (e.g. httpx.HTTPStatusError)#64484
Closed
Pranaykarvi wants to merge 6 commits intoapache:mainfrom
Closed
Fix LocalExecutor crash on non-picklable exceptions (e.g. httpx.HTTPStatusError)#64484Pranaykarvi wants to merge 6 commits intoapache:mainfrom
Pranaykarvi wants to merge 6 commits intoapache:mainfrom
Conversation
…handle job retries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #64476
When LocalExecutor runs a task in a subprocess, the result (including any
exception) is passed back to the scheduler via a
multiprocessing.Queue.Python serializes queue entries using pickle.
Some exceptions — such as
httpx.HTTPStatusErrorfrom the httpx library —are not pickle-safe. Their
__init__requires keyword arguments (request,response) that cannot be reconstructed during deserialization. This causes:This exception propagates out of
_read_results(), crashes the schedulerloop, and takes down the entire scheduler pod. The only recovery is to
disable the offending DAG.
Root Cause
In
_execute_work_in_subprocess, raw exception objects were placed directlyonto the result queue:
Any exception whose class is not trivially picklable would cause
deserialization to fail on the receiving end.
Fix
Wrap the exception in a plain
Exceptionbefore putting it on the queue,preserving the original type name, message, and full traceback as a string:
This is applied to both the
ExecuteTaskandExecuteCallbackbranches.A plain
Exceptionwith a string message is always pickle-safe regardlessof the original exception type.
Impact
Testing
Reproduced the crash locally using a
PythonOperatorDAG that triggers anhttpx.HTTPStatusError(as reported in #64476). After this fix thescheduler remains stable and the task is correctly marked as FAILED with
the full traceback visible in logs.