Skip to content

Resolve OOM When Reading Large Logs in Webserver #49470

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

Open
wants to merge 37 commits into
base: main
Choose a base branch
from

Conversation

jason810496
Copy link
Member

related issue: #45079
related PR: #45129
related discussion on slack: https://apache-airflow.slack.com/archives/CCZRF2U5A/p1736767159693839

Why

In short, this PR aims to eliminate OOM issues by:

  • Replacing full log sorting with a K-Way Merge
  • Making the entire log reading path streamable (using yield generators instead of returning a list of strings)

More detailed reasoning is already described in the linked issue.

Due to too many conflicts with the old PR (#45129), this PR reworks the changes on top of the latest FileTaskHandler.

What

This PR ports the original changes from #45129 to the current version of FileTaskHandler with the following updates:

  • Fixed line-splitting error when reading in chunks using buffered line-splitting with a carry-over
  • Adopted the new log metadata structure
  • Introduced buffering for the log reader

Note: Recent Changes in FileTaskHandler

@jason810496 jason810496 self-assigned this Apr 20, 2025
@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:logging area:UI Related to UI/UX. For Frontend Developers. labels Apr 20, 2025
@jason810496 jason810496 removed the area:UI Related to UI/UX. For Frontend Developers. label Apr 20, 2025
@jason810496 jason810496 force-pushed the refactor/rework-webserver-oom-for-large-log-read branch 10 times, most recently from d47a49b to 2f5a202 Compare April 25, 2025 13:00
@jason810496 jason810496 force-pushed the refactor/rework-webserver-oom-for-large-log-read branch 2 times, most recently from 4e1bcb4 to 358f231 Compare April 26, 2025 13:22
@jason810496 jason810496 marked this pull request as ready for review April 27, 2025 05:44
@jason810496 jason810496 force-pushed the refactor/rework-webserver-oom-for-large-log-read branch from 358f231 to 9900b2e Compare April 27, 2025 05:44
jason810496 added 25 commits May 2, 2025 00:46
- Fix events utils
- Add convert_list_to_stream, mock_parsed_logs_factory utils
- Fix the following test after refactoring FileTaskHandler
    - test_file_task_handler_when_ti_value_is_invalid
    - test_file_task_handler
    - test_file_task_handler_running
    - test_file_task_handler_rotate_size_limit
    - test__read_when_local
    - test__read_served_logs_checked_when_done_and_no_local_or_remote_logs
    - test_interleave_interleaves
    - test_interleave_logs_correct_ordering
    - test_interleave_logs_correct_dedupe
- Add new test for refactoring FileTaskHandler
    - test__stream_lines_by_chunk
    - test__log_stream_to_parsed_log_stream
    - test__sort_key
    - test__is_sort_key_with_default_timestamp
    - test__is_logs_stream_like
    - test__add_log_from_parsed_log_streams_to_heap
- sequential yield instead of parallel yield for all log_stream
- don't concat buffer with empty str, yield directly from buffer
Fix wasb test, spelling
@jason810496 jason810496 force-pushed the refactor/rework-webserver-oom-for-large-log-read branch from 3d90512 to df20991 Compare May 1, 2025 16:47
@jason810496 jason810496 marked this pull request as ready for review May 2, 2025 02:25
@jason810496 jason810496 requested review from ashb, uranusjr and dstandish May 2, 2025 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:API Airflow's REST/HTTP API area:logging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants