-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Triggerer crashes when a trigger function is changed #31743
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval. |
Hi, I have the exact same issue. However, I have some additional context that might be beneficial. For example, if you change the name of the apply_function you will notice you get the exact same issue (without changing the file name). I have checked on my instance and the gitsync container for the triggerer is running without issues (atleast from the logs). I have further investigated this by doing the following actions :
To me it seems that the DAG on the Triggerer side is not correctly being synced to be in line with what is on the web UI/worker. This is very weird as I have checked the trigger-gitsync container logs to see whether a refresh was done and it did log a refresh. *edit : obviously it should not be necessary to recreate a container in order to get this updated. |
Hi, if no one's working on it, I'd like to take a look 🙂 |
Hello guys, anything I can do to help as well? |
Hi, I think I have a clue on how to fix it. It might be related to trigger cache. I was working on another PR but will have some time to work on it tomorrow. 💪 |
I format the error message a bit for better understanding.
|
Hi @zoid-w, thank you for your reproducing steps. It's really helpful for me to track this issue Hi @pauloventurab, it appears that the root cause of the problem can be traced back to these lines. Restarting the As for what you suggested in
This might not be something we can do for now as we cannot pass a |
In general, you need to restart services when you change things like this. If you modify a plugin, for example, you need to restart the scheduler and/or the webserver. This is no different; if you change a trigger, you need to restart the triggerer service. Airflow’s service processes are all built with this design in mind, restarting is an expected operation, should not cause any data breakage, and can be performed liberally. Maybe some notes should be added to documentation about this, at the same place where we walk through how to implement a trigger. I think it’s generally accepted that plugin changes require rebooting the processes, but triggers may be greener and less understood. I also wonder whether it is possible for Airflow to detect changes like this and automatically suggest restarting, instead of failing later. But this may be much more difficult since Python code changes are not that easy to detect in the first place. This topic is much more involved and should be explored separately if desired. |
Can confirm that the caching mechanism is indeed the reason for this behavior. if you would like to bypass it you could mitigate this in a practical sense by renaming the file as well since the path to the class would not be cached then (possibly some people might not have cli access to the triggerer service or something). On a seperate note : My knowledge of async coding in python is quite limited, but maybe a time-based release of cached paths might be a good idea. |
I'm not sure whether cleaning up the cache in |
As #32140 has been merged, should we close this one? Or is there anything we could try to improve it? Thanks 🙂 |
Yeah. I am closing this one, unless someone has an idea that we should somehow dynamically restart Triggerer. I think with the current state state of how async loop and python interpreter works and I agree with @uranusjr that detection of such a situation automatically is likely not something that can be done reliably, we need to defer to human's judgment on it. The note from #32140 and this discussion should be enough for anyone to be able to find out what's going on and implement Trigger restarts automatically when the code they "know" might impact it would change. |
Apache Airflow version
2.6.1
What happened
Hi guys,
i'm using the AwaitMessageTriggerFunctionSensor from Kafka with the following example on your Docs:
https://github.com/apache/airflow/blob/providers-apache-kafka/1.1.0/tests/system/providers/apache/kafka/example_dag_event_listener.py
The issue is the apply_function. When I want to change the name of my file and the use "my_file_name.await_function" it says:
Can you give a hand here please?
My file is inside dag main folder. and I just copied the example and paste here, changing the name of the file and the apply_function to "my_file_name.await_function"
Thanks
What you think should happen instead
I think it should work, and maybe also simplify the apply_function to the function name without the module importation, just the function inside the dag, could be a task as well.
How to reproduce
I don't know how to help improve it.
Operating System
Kubernetes cluster - Linux
Versions of Apache Airflow Providers
apache-airflow-providers-apache-kafka==1.0.0
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: