Skip to content

Stop writing Dag processor log files when the log target is stdout - #74165

Open
luc-pimentel wants to merge 3 commits into
apache:mainfrom
luc-pimentel:fix/70968-dag-processor-stdout-logs
Open

luc-pimentel wants to merge 3 commits into
apache:mainfrom
luc-pimentel:fix/70968-dag-processor-stdout-logs

Conversation

@luc-pimentel

Copy link
Copy Markdown
Contributor

With [logging] dag_processor_log_target = stdout, the Dag processor still writes every parse's output to logs/dag_processor/<date>/<bundle>/<file>.log, and since #65528 it also prints the same lines to stdout. Nothing reads or removes those files, so the directory keeps growing. The option's description presents file and stdout as alternatives, and in Airflow 2 stdout replaced the file handler instead of adding to it.

For stdout, DagFileProcessorManager._get_logger_for_dag_file now returns a stdout logger tagged with dag_file and bundle_name instead of opening a file. That logger is the parse process's own logger, so the child's output and the supervisor's messages about the parse (such as "Process exited abnormally", which only went to the file before) reach stdout once, in the same format as #65528's output. Nothing copies to stdout a second time anymore, so the _get_target_loggers override that tagged that copy is removed, and its tests are replaced by one checking that the stdout logger carries the tags. file mode is unchanged, and the option's description now says that stdout writes no log files.

Tested on 3.3.2 and main with airflow dag-processor -n 3, using a Dag that prints one line and logs one warning when parsed (3 parses):

dag_processor_log_target Before With this change
file 1 log file with 6 parse lines, none on stdout same
stdout 1 log file with 6 parse lines, the same 6 on stdout no log directory, 6 parse lines on stdout

The new tests fail without this change.

#71052 tried the same fix and was closed under the open PR limit. If you'd rather keep stdout writing the file too, I can put this behind a new stdout_only value instead.

closes: #70968


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5.5)

Generated-by: Claude Code (Opus 5.5) following the guidelines

@luc-pimentel
luc-pimentel force-pushed the fix/70968-dag-processor-stdout-logs branch from a6f2c55 to 02e273e Compare October 5, 2026 19:08
With dag_processor_log_target set to stdout, the option promises the parse
logs on stdout, yet every parse still appends to a per-file log that
nothing reads or removes, so the log directory grows until the disk fills.
dag_processor_log_target = stdout should send the parse logs to stdout
instead of files, as the option's description says and as it worked in
Airflow 2. Every parse still appended to its file, with the stdout output
from apache#65528 on top, so the log directory kept growing although nothing
reads or removes those files.

Sending the parse process's own logger to stdout, tagged with the Dag file
and bundle, also brings the supervisor's messages about a failed parse to
stdout, and keeps each line from being printed twice.
The existing stdout test only checks the tags bound to the process
logger, so rename it to say that. The new test parses a real Dag file
and checks its log line is printed to stdout once, tagged with the Dag
file and bundle. The process logger is stdout itself now, so another
copy to stdout would print every line twice.
@luc-pimentel
luc-pimentel force-pushed the fix/70968-dag-processor-stdout-logs branch from 02e273e to 34ca954 Compare October 14, 2026 02:29
@luc-pimentel

Copy link
Copy Markdown
Contributor Author

Rebased on main and CI passes. Could someone who works on Dag processing please take a look? Thanks!


Drafted-by: Claude Code (Fable 5.1); reviewed by @luc-pimentel before posting

@luc-pimentel

Copy link
Copy Markdown
Contributor Author

I saw 3.4.0 was released today, so I ran the same repro from the description against it to see whether this bug is still there and whether the repro still holds. It does: with dag_processor_log_target = stdout, airflow dag-processor -n 3 on 3.4.0 (Python 3.12, SQLite) wrote 1 log file with 6 parse lines and printed the same 6 on stdout, the same as 3.3.2.

When a parse process dies, "Process exited abnormally" still goes only to the file in stdout mode (3 of 3 in the file, 0 on stdout).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot deactivate File-based logs for at processor

2 participants