uranusjr commented on code in PR #74794:
URL: https://github.com/apache/airflow/pull/74794#discussion_r4629413867
##########
airflow-core/src/airflow/dag_processing/manager.py:
##########
@@ -747,10 +760,12 @@ def _run_parsing_loop(self):
self._collect_results()
self._refresh_dag_bundles(known_files=known_files)
- if not self._file_queue:
- # Generate more file paths to process if we processed all the
files already. Note for this to
- # clear down, we must have cleared all files found from
scanning the dags dir _and_ have
- # cleared all files added as a result of callbacks
+ if not any(
+ file not in self._processors and file not in
self._pending_publications
+ for file in self._file_queue
+ ):
+ # Busy requested files stay queued; they must not prevent
other bundles from filling
+ # spare slots once the ordinary batch has drained.
self.prepare_file_queue(known_files=known_files)
Review Comment:
This final call now runs on every loop while every queued file is busy,
rescanning all files, including a per-file getmtime under `modified_time` sort.
Some gating would be good.
##########
airflow-core/src/airflow/dag_processing/manager.py:
##########
@@ -2333,29 +2487,35 @@ def _start_new_processes(self):
self._readmit_files_with_source()
bundle_to_team = self._get_team_names({file.bundle_name for file in
self._file_queue})
- while (
- self._parallelism > len(self._processors) +
len(self._pending_publications) and self._file_queue
- ):
+ # Requested work skipped in this pass goes back to the front once the
pass is over.
+ requested_later: dict[DagFileInfo, None] = {}
+ for _ in range(len(self._file_queue)):
+ if len(self._processors) + len(self._pending_publications) >=
self._parallelism:
+ break
file, _ = self._file_queue.popitem(last=False)
+ has_priority_request = self._has_priority_request(file)
# Stop creating duplicate processor i.e. processor with the same
filepath
if file in self._processors or file in self._pending_publications:
- if file in self._priority_files:
- self._files_awaiting_source[file] = None
+ if has_priority_request or file in self._callback_to_execute:
+ requested_later[file] = None
Review Comment:
DB-mode scheduling change needs to be called out (at least in the PR
description?)
##########
airflow-core/src/airflow/dag_processing/processor.py:
##########
@@ -257,8 +272,16 @@ def _parse_file(msg: DagFileParseRequest, log:
FilteringBoundLogger) -> DagFileP
)
if msg.callback_requests:
+ targets_loaded = any(_is_callback_target_loaded(bag, request) for
request in msg.callback_requests)
+ if targets_loaded and conf.getboolean("dag_processor",
"use_execution_api"):
Review Comment:
The parse child decides the mode from the configuration, while the manager
decides it from its injected `api_client`. Maybe put `callbacks_require_ack`
and/or `team_name` on DagFileParseRequest instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]