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
Add ability to generate temporary downloadable link for task logs(stored on cloud storage) on UI #44753
When a task generates many logs, the web server usually gets OOM Killed while trying to render the task logs. For this situation, we can give the user a downloadable link to the file on UI. If the task logs are located on cloud storage, we can generate the following:
changed the title [-]Add ability to generate downloadable link for task logs on UI[/-][+]Add ability to generate downloadable link for task logs(stored on cloud storage) on UI[/+]on Dec 7, 2024
changed the title [-]Add ability to generate downloadable link for task logs(stored on cloud storage) on UI[/-][+]Add ability to generate temporary downloadable link for task logs(stored on cloud storage) on UI[/+]on Dec 7, 2024
I have also espcially seen that the webserver gets OOM even if you download because the FileTaskHandler tries to sort+merge different log sources. One important thing is not only the download but also the FileTaskHandler must 1:1 stream the logs from the backend, else it will go OOM as well.
This included when I took a look last time... why actually log sorting and merging is implemented in general I doubt the usefulness because I also had situations where log sorting by timestamp gave "strange" results. In my view logs should not be modified/sorted/merged when served from webserver. This would also remove the OOM problem in general... whereas I have seen situations as well where the browser/client "dies" in rendering. So a limit in logs provided to browser might be a important feature as well (but please not like Github is doing it)
Mostly agree with @jscheffl -> but I still think merging logs might be useful in some cases, though the "naive" version it is done now should be either limited to certain log size that should be able to fit in memory or fixed to support arbitrary log size. Loading whole log to memory is generally bad idea (but OK if we can confirm they will fit in memory).
There are some algorithms that could be used to do it "well" even when the logs are huge, but they require much more sophisticated behaviour and local file storage and likely are not suitable to run in an "API" call. So I am not sure if it at all worth doing it (airflow is NOT a sophisticated logging solution) - but if we have this "download full log" (and even there we could download zipped logs from several sources without merging them) - that could be a useful counterpart for merging for big files.
There are two options how to do it, I think:
if the files are huge (and we could set arbitrary value here), only show the original task log (streaming it) and add a link to "download" the .zip file where you see the missing logs as well
if the files are huge just download the "max" part of the files - perform merge and add a note that the logs are incomplete and that you should download the whole .zip content of the several logs
Generally, yes, I think we should implement it (and prevent the OOM from happening).
Address the root cause of OOM directly at the handler level.
Though I couldn't reliably reproduce OOM on the webserver, the browser tab crashing due to large logs remains an issue.
Question
How can I reliably reproduce the OOM issue when fetching large task logs?
I’ve tried observing memory usage with Memray but found it challenging to reproduce.
@jason810496 , I think you need to put resource limits on each airflow component. On managed services, the webserver is usually limited, On Astro its about 1 vcpu and 2GiB memory.
@jason810496 , I think you need to put resource limits on each airflow component. On managed services, the webserver is usually limited, On Astro its about 1 vcpu and 2GiB memory.
Activity
[-]Add ability to generate downloadable link for task logs on UI[/-][+]Add ability to generate downloadable link for task logs(stored on cloud storage) on UI[/+][-]Add ability to generate downloadable link for task logs(stored on cloud storage) on UI[/-][+]Add ability to generate temporary downloadable link for task logs(stored on cloud storage) on UI[/+]jscheffl commentedon Dec 7, 2024
I have also espcially seen that the webserver gets OOM even if you download because the FileTaskHandler tries to sort+merge different log sources. One important thing is not only the download but also the FileTaskHandler must 1:1 stream the logs from the backend, else it will go OOM as well.
This included when I took a look last time... why actually log sorting and merging is implemented in general I doubt the usefulness because I also had situations where log sorting by timestamp gave "strange" results. In my view logs should not be modified/sorted/merged when served from webserver. This would also remove the OOM problem in general... whereas I have seen situations as well where the browser/client "dies" in rendering. So a limit in logs provided to browser might be a important feature as well (but please not like Github is doing it)
potiuk commentedon Dec 7, 2024
Mostly agree with @jscheffl -> but I still think merging logs might be useful in some cases, though the "naive" version it is done now should be either limited to certain log size that should be able to fit in memory or fixed to support arbitrary log size. Loading whole log to memory is generally bad idea (but OK if we can confirm they will fit in memory).
There are some algorithms that could be used to do it "well" even when the logs are huge, but they require much more sophisticated behaviour and local file storage and likely are not suitable to run in an "API" call. So I am not sure if it at all worth doing it (airflow is NOT a sophisticated logging solution) - but if we have this "download full log" (and even there we could download zipped logs from several sources without merging them) - that could be a useful counterpart for merging for big files.
There are two options how to do it, I think:
Generally, yes, I think we should implement it (and prevent the OOM from happening).
jason810496 commentedon Dec 8, 2024
Hi, after tracing down related GitHub issues and attempting to reproduce the OOM issue, I have some questions and ideas about related improvements.
Related Issues and Context
log_posandend_of_logmetadata usingURLSafeSerializer, theget_logAPI remain unchanged.log_posandend_of_logas query parameters for better UI pagination.As noted by @bbovenzi, this remains unresolved.
Ideas for Related Improvements
Expose
log_posandend_of_logas Query Parameters:v2.10.x.Pagination for Legacy UI:
Refactor
FileTaskHandler:Though I couldn't reliably reproduce OOM on the webserver, the browser tab crashing due to large logs remains an issue.
Question
How can I reliably reproduce the OOM issue when fetching large task logs?
I’ve tried observing memory usage with Memray but found it challenging to reproduce.
breeze start-airflow --python 3.9 --backend sqliteas the environment.Any tips on how to consistently reproduce the issue? Or is there a specific environment setup recommended for this?
rawwar commentedon Dec 8, 2024
@jason810496 , I think you need to put resource limits on each airflow component. On managed services, the webserver is usually limited, On Astro its about 1 vcpu and 2GiB memory.
jason810496 commentedon Dec 8, 2024
Thanks, I will try it with docker compose !
AryanK1511 commentedon Jul 1, 2025
rawwar commentedon Oct 28, 2025
Not sure if we need this now. Since AF3 can just stream logs. closing this.