You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Failed to load task run error" occur in "on_failure_callback" after upgrading from 2.0.0 to 2.1.2 #17045
What happened: "Failed to load task run error" occur in "on_failure_callback" after task failed
What you expected to happen: The actually exception should be caught
How to reproduce it:
def validate_parameters(**kwargs):
conf = kwargs.get('dag_run').conf
kwargs['ti'].xcom_push(key='conf', value=conf)
job_identifier = conf.get('job_identifier')
s3_connection_id = conf.get('s3_connection_id')
if not job_identifier:
raise ParameterValidationException(reason='job_identifier should not be empty')
if not s3_connection_id:
raise ParameterValidationException(reason='s3_connection_id should not be empty')
def handle_failure(context):
exception = context.get('exception')
// the ParameterValidationException should be caught here, but I got "Failed to load task run error"
// other business
DEFAULT_ARGS = {
'owner': 'boss_admin',
'start_date': datetime(2021, 1, 2),
"retries": 0,
'on_failure_callback': handle_failure
}
I suggest you to switch to Airflow's official Helm rather than running your own deployment. It is proven and works and it's the easiest way to get Airflow Up-and-running on Kubernetes, I think no-one in the community has time to debug hundreds of different manual deployments like yours, but the Official Helm Chart from the community is very versatile, supported and it has a lot of problems solved that you might not realise by running your own deployment. I think this is the best route you can take.
Bottom Line Up Front: I had a similar issue, and found that the cause was a third party packages code that did not implement exceptions that could be loaded from a picklefile. This is the most likely cause of the problem.
For me, switching to Airflows official helm wasn't an option (not running Kubernetes). I did some digging around and found that this message is spawned when trying to load an original exception from a pickle file.
Unfortunately the causing error message is not logged. I applied this patch to my instance of airflow to see what error was causing the pickle.loads to fail.
@@ -115,7 +115,10 @@
return None
try:
return pickle.loads(data)
- except Exception: # pylint: disable=broad-except
+ except Exception as e: # pylint: disable=broad-except
+ log.exception("Failed to load the exception! Oh NO!!! Here is why")
+ log.exception(e.msg)
+ log.exception(e)
return "Failed to load task run error"
I found that the error was being caused because the third party tooling I was using had an error that could be pickled, but then not loaded back. This is a common issue with custom errors in python. I'm guessing that something similar is happening in your case.
Reacted by Narek Grigoryan, Kaojun Song, Alexandre Girbal, Fredrik Sannholm and Tyler Calder
Activity
eladkal commentedon Jul 17, 2021
Can you please add a minimal working reproduce example and also format your code?
Also please add the traceback
kaojunsong commentedon Jul 20, 2021
Hi @eladkal, thanks a lot for your reply.
The minimal working reproduce example is in https://github.com/kaojunsong/airflow-test/blob/main/dags/test.py
potiuk commentedon Jul 25, 2021
I run your example using local executor and it all works fine (see below).
The problem you most likely experienced was problem with retrieving task logs. You need to make sure you have
AIRFLOW__WEBSERVER__SECRET_KEYthe same for workers and webserver - then your logs will be retrieved by the webserver https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#secret-keyI am closing it now - please re-open if the issue is not fixed (but I am quite sure it will be).
kaojunsong commentedon Jul 26, 2021
@potiuk Thanks a lot for your reply.
I'm using Celery Executor. And the webserver and worker are using the same airflow.cfg: https://github.com/kaojunsong/airflow-test/blob/main/config/airflow.cfg, they are using the same secret_key, am I right? If not, how can I configure the secret_key for the workers?
And the deployment of kubenetes is in: https://github.com/kaojunsong/airflow-test/tree/main/kubenetes
kaojunsong commentedon Aug 19, 2021
@potiuk Hi, I still can't solve this issue, could you please kindly have a look?
potiuk commentedon Aug 19, 2021
I suggest you to switch to Airflow's official Helm rather than running your own deployment. It is proven and works and it's the easiest way to get Airflow Up-and-running on Kubernetes, I think no-one in the community has time to debug hundreds of different manual deployments like yours, but the Official Helm Chart from the community is very versatile, supported and it has a lot of problems solved that you might not realise by running your own deployment. I think this is the best route you can take.
See https://airflow.apache.org/docs/helm-chart/stable/index.html
Calder-Ty commentedon Aug 30, 2021
Bottom Line Up Front: I had a similar issue, and found that the cause was a third party packages code that did not implement exceptions that could be loaded from a picklefile. This is the most likely cause of the problem.
For me, switching to Airflows official helm wasn't an option (not running Kubernetes). I did some digging around and found that this message is spawned when trying to load an original exception from a pickle file.
airflow/airflow/models/taskinstance.py
Lines 136 to 147 in 9922287
Unfortunately the causing error message is not logged. I applied this patch to my instance of airflow to see what error was causing the pickle.loads to fail.
I found that the error was being caused because the third party tooling I was using had an error that could be pickled, but then not loaded back. This is a common issue with custom errors in python. I'm guessing that something similar is happening in your case.
kaojunsong commentedon Apr 28, 2022
@Calder-Ty Thanks a lot, I have fixed my issue by adding
def __reduce__(self): return ParameterValidationException, (self.reason, self.component)to my custom Exception, as the pickle library needs to unpicle data from log files.
https://www.synopsys.com/blogs/software-security/python-pickling/#:~:text=Whenever%20an%20object%20is%20pickled,reconstruct%20this%20object%20when%20unpickling.