You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/04/14 13:46:23 UTC
[GitHub] [airflow] malthe opened a new pull request, #23016: Use inherited 'trigger_tasks' method
malthe opened a new pull request, #23016:
URL: https://github.com/apache/airflow/pull/23016
This is a follow-up to #21316 which did not take into account that `CeleryExecutor` overrides `trigger_tasks` and thus would ignore if a task was already running.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ashb commented on a diff in pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
ashb commented on code in PR #23016:
URL: https://github.com/apache/airflow/pull/23016#discussion_r858574382
##########
airflow/executors/base_executor.py:
##########
@@ -212,9 +216,15 @@ def trigger_tasks(self, open_slots: int) -> None:
del self.attempts[key]
del self.queued_tasks[key]
else:
- del self.queued_tasks[key]
- self.running.add(key)
- self.execute_async(key=key, command=command, queue=queue, executor_config=ti.executor_config)
+ task_tuples.append((key, command, queue, ti.executor_config))
+
+ self._process_tasks(task_tuples)
Review Comment:
```suggestion
if task_tuples:
self._process_tasks(task_tuples)
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil commented on a diff in pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
kaxil commented on code in PR #23016:
URL: https://github.com/apache/airflow/pull/23016#discussion_r857792428
##########
tests/executors/test_celery_executor.py:
##########
@@ -225,19 +225,19 @@ def test_retry_on_error_sending_task(self, caplog):
# Test that when heartbeat is called again, task is published again to Celery Queue
executor.heartbeat()
- assert dict(executor.task_publish_retries) == {key: 2}
+ assert dict(executor.task_publish_retries) == {key: 1}
Review Comment:
I think that is because now we use "Counter" from collections that starts with "0", whereas previously we started with "1" with OrderedDict
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] github-actions[bot] commented on pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #23016:
URL: https://github.com/apache/airflow/pull/23016#issuecomment-1108981494
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] malthe commented on pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
malthe commented on PR #23016:
URL: https://github.com/apache/airflow/pull/23016#issuecomment-1099298755
@potiuk I believe the consequences are bad ... here's the story:
1. We now queue up (internally in the executor) tasks without checking if they're running.
2. When they're going to be executed, we then check that they're not already running.
3. But this check is done in `trigger_tasks` and `CeleryExecutor` does not carry over this check.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil commented on a diff in pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
kaxil commented on code in PR #23016:
URL: https://github.com/apache/airflow/pull/23016#discussion_r857809473
##########
tests/executors/test_celery_executor.py:
##########
@@ -225,19 +225,19 @@ def test_retry_on_error_sending_task(self, caplog):
# Test that when heartbeat is called again, task is published again to Celery Queue
executor.heartbeat()
- assert dict(executor.task_publish_retries) == {key: 2}
+ assert dict(executor.task_publish_retries) == {key: 1}
Review Comment:
and before the condition was
https://github.com/apache/airflow/blob/d4a33480550db841657b998c0b4464feffec0ef9/airflow/executors/celery_executor.py#L288-L290
and now it is
https://github.com/apache/airflow/blob/5b5511e6e095e68d41a0713aa563772fe847a4c8/airflow/executors/celery_executor.py#L269
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ashb commented on pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
ashb commented on PR #23016:
URL: https://github.com/apache/airflow/pull/23016#issuecomment-1109621724
I'm not sure this works given two times every combo of tests for the "Helm Chart: Celery Executor" failed.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] malthe commented on a diff in pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
malthe commented on code in PR #23016:
URL: https://github.com/apache/airflow/pull/23016#discussion_r857975098
##########
tests/executors/test_celery_executor.py:
##########
@@ -225,19 +225,19 @@ def test_retry_on_error_sending_task(self, caplog):
# Test that when heartbeat is called again, task is published again to Celery Queue
executor.heartbeat()
- assert dict(executor.task_publish_retries) == {key: 2}
+ assert dict(executor.task_publish_retries) == {key: 1}
Review Comment:
Exactly – and this is definitely a bit of a tricky change, but I do think it makes sense because the code is just easier with the new indexing logic.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ashb commented on pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
ashb commented on PR #23016:
URL: https://github.com/apache/airflow/pull/23016#issuecomment-1109641716
Errors from the kind cluster logs:
```
2022-04-26T06:51:03.460594936Z stdout F [2022-04-26 06:51:03,458] {scheduler_job.py:753} ERROR - Exception when executing SchedulerJob._run_scheduler_loop
2022-04-26T06:51:03.460604836Z stdout F Traceback (most recent call last):
2022-04-26T06:51:03.460608336Z stdout F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/scheduler_job.py", line 736, in _execute
2022-04-26T06:51:03.460611436Z stdout F self._run_scheduler_loop()
2022-04-26T06:51:03.460614236Z stdout F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/scheduler_job.py", line 826, in _run_scheduler_loop
2022-04-26T06:51:03.460616936Z stdout F self.executor.heartbeat()
2022-04-26T06:51:03.460625336Z stdout F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/executors/base_executor.py", line 167, in heartbeat
2022-04-26T06:51:03.460628136Z stdout F self.trigger_tasks(open_slots)
2022-04-26T06:51:03.460630736Z stdout F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/executors/base_executor.py", line 221, in trigger_tasks
2022-04-26T06:51:03.460633436Z stdout F self._process_tasks(task_tuples)
2022-04-26T06:51:03.460636636Z stdout F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/executors/celery_executor.py", line 255, in _process_tasks
2022-04-26T06:51:03.460639936Z stdout F first_task = next(t[3] for t in task_tuples_to_send)
2022-04-26T06:51:03.460643536Z stdout F StopIteration
2022-04-26T06:51:03.460752837Z stdout F [2022-04-26 06:51:03,460] {celery_executor.py:315} DEBUG - No task to query celery, skipping sync
```
```
2022-04-26T06:51:05.052664545Z stderr F Traceback (most recent call last):
2022-04-26T06:51:05.052947248Z stderr F File "/home/airflow/.local/bin/airflow", line 8, in <module>
2022-04-26T06:51:05.052950848Z stderr F sys.exit(main())
2022-04-26T06:51:05.052953748Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/__main__.py", line 38, in main
2022-04-26T06:51:05.052956548Z stderr F args.func(args)
2022-04-26T06:51:05.052960048Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/cli_parser.py", line 51, in command
2022-04-26T06:51:05.052963248Z stderr F return func(*args, **kwargs)
2022-04-26T06:51:05.052965948Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/cli.py", line 99, in wrapper
2022-04-26T06:51:05.052968648Z stderr F return f(*args, **kwargs)
2022-04-26T06:51:05.052971848Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/commands/scheduler_command.py", line 75, in scheduler
2022-04-26T06:51:05.052975148Z stderr F _run_scheduler_job(args=args)
2022-04-26T06:51:05.052978248Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/commands/scheduler_command.py", line 46, in _run_scheduler_job
2022-04-26T06:51:05.052981548Z stderr F job.run()
2022-04-26T06:51:05.052984248Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/base_job.py", line 244, in run
2022-04-26T06:51:05.052986848Z stderr F self._execute()
2022-04-26T06:51:05.053002149Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/scheduler_job.py", line 736, in _execute
2022-04-26T06:51:05.053005749Z stderr F self._run_scheduler_loop()
2022-04-26T06:51:05.053008549Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/scheduler_job.py", line 826, in _run_scheduler_loop
2022-04-26T06:51:05.053011449Z stderr F self.executor.heartbeat()
2022-04-26T06:51:05.053014749Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/executors/base_executor.py", line 167, in heartbeat
2022-04-26T06:51:05.053017649Z stderr F self.trigger_tasks(open_slots)
2022-04-26T06:51:05.053020249Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/executors/base_executor.py", line 221, in trigger_tasks
2022-04-26T06:51:05.053022949Z stderr F self._process_tasks(task_tuples)
2022-04-26T06:51:05.053025949Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/executors/celery_executor.py", line 255, in _process_tasks
2022-04-26T06:51:05.053028749Z stderr F first_task = next(t[3] for t in task_tuples_to_send)
2022-04-26T06:51:05.053031549Z stderr F StopIteration
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #23016:
URL: https://github.com/apache/airflow/pull/23016#issuecomment-1099270886
Quick question - before diving in - what are consequence of not having it in @malthe ? It touches deep internals of Airlfow and it should be really carefully reviewed, so I guess it might not make it to 2.3.0 as it is a bit risky ?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ashb commented on a diff in pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
ashb commented on code in PR #23016:
URL: https://github.com/apache/airflow/pull/23016#discussion_r857768244
##########
tests/executors/test_celery_executor.py:
##########
@@ -225,19 +225,19 @@ def test_retry_on_error_sending_task(self, caplog):
# Test that when heartbeat is called again, task is published again to Celery Queue
executor.heartbeat()
- assert dict(executor.task_publish_retries) == {key: 2}
+ assert dict(executor.task_publish_retries) == {key: 1}
Review Comment:
Why did these numbers change? Ideally this refactor shouldn't have changed anything about the behaviour, no?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #23016:
URL: https://github.com/apache/airflow/pull/23016#issuecomment-1108492280
So I guess this one needs to be at least considered seriously for 2.3.0 - but I am not too deep in this to verify if this is a good/badly needed fix @ashb @ephraimbuddy @dstandish @jedcunningham - maybe you can take a look before cutting 2.3.0 ?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ashb merged pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
ashb merged PR #23016:
URL: https://github.com/apache/airflow/pull/23016
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil commented on a diff in pull request #23016: Use inherited 'trigger_tasks' method
Posted by GitBox <gi...@apache.org>.
kaxil commented on code in PR #23016:
URL: https://github.com/apache/airflow/pull/23016#discussion_r857809473
##########
tests/executors/test_celery_executor.py:
##########
@@ -225,19 +225,19 @@ def test_retry_on_error_sending_task(self, caplog):
# Test that when heartbeat is called again, task is published again to Celery Queue
executor.heartbeat()
- assert dict(executor.task_publish_retries) == {key: 2}
+ assert dict(executor.task_publish_retries) == {key: 1}
Review Comment:
and before the condition was
https://github.com/apache/airflow/blob/d4a33480550db841657b998c0b4464feffec0ef9/airflow/executors/celery_executor.py#L288-L290
and now it is
https://github.com/apache/airflow/blob/5b5511e6e095e68d41a0713aa563772fe847a4c8/airflow/executors/celery_executor.py#L268-L269
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org