Skip to content

Skip log accumulator disk spill when reading finished task logs - #70671

Open
jason810496 wants to merge 3 commits into
apache:mainfrom
jason810496:refactor/logging/bypass-accumulator-terminal-reads
Open

Skip log accumulator disk spill when reading finished task logs#70671
jason810496 wants to merge 3 commits into
apache:mainfrom
jason810496:refactor/logging/bypass-accumulator-terminal-reads

Conversation

@jason810496

Copy link
Copy Markdown
Member

part of the streaming task log series

Why

FileTaskHandler._read wraps every read in LogStreamAccumulator, which eagerly drains the whole merged log stream (5000 lines to memory, the rest to a tempfile on the API server) before the first byte reaches the client — only to get the total_lines for the continuation token.

For a finished task no continuation token is ever issued (end_of_log=True on both the JSON and NDJSON paths), so the count is dead weight: every terminal-task read full-log downloads — pays a full-log disk write + read-back + re-parse and a time-to-first-byte equal to the whole drain, for nothing.

What

  • Early-return in FileTaskHandler._read bypassing LogStreamAccumulator when end_of_log is True.
  • Memory stays bounded either way — the k-way merge heap in _interleave_logs (capped at HEAP_DUMP_SIZE, flushing half when full) is what bounds the read path, not the accumulator.

Was generative AI tooling used to co-author this PR?

@jason810496 jason810496 self-assigned this Jul 29, 2026
@jason810496 jason810496 added the area:API Airflow's REST/HTTP API label Jul 29, 2026
@jason810496
jason810496 marked this pull request as ready for review July 29, 2026 10:17
@jason810496
jason810496 force-pushed the refactor/logging/bypass-accumulator-terminal-reads branch from ff86435 to d9fbcfb Compare July 30, 2026 03:21
@jason810496
jason810496 requested a review from o-nikolas as a code owner July 31, 2026 11:33
Finished-task reads drop the log_pos continuation token from 3.4.0
onward, but the provider test matrix still runs against released cores
(3.0-3.3) that emit it. Gate the S3, GCS, and WASB task-handler metadata
assertions on AIRFLOW_V_3_4_0_PLUS so both the source run and the
older-core compatibility runs pass.
@jason810496
jason810496 force-pushed the refactor/logging/bypass-accumulator-terminal-reads branch from 0fa14b3 to b0d2376 Compare July 31, 2026 15:12
@jason810496
jason810496 requested a review from shahar1 as a code owner July 31, 2026 15:12
@jason810496 jason810496 added this to the Airflow 3.4.0 milestone Aug 5, 2026
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.

1 participant