You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "pankajkoti (via GitHub)" <gi...@apache.org> on 2023/11/26 06:58:18 UTC
[PR] Send explicit task logs when marking tasks stuck in queued as failed [airflow]
pankajkoti opened a new pull request, #35857:
URL: https://github.com/apache/airflow/pull/35857
Using the feature built in #32646, when the scheduler marks
tasks stuck in queued as failed, send such an explicit log
indicating the action to the task logs so that it helps users
identify why exactly the task was marked failed in such a case.
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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
Re: [PR] Send explicit task logs when marking tasks stuck in queued as failed [airflow]
Posted by "dstandish (via GitHub)" <gi...@apache.org>.
dstandish commented on code in PR #35857:
URL: https://github.com/apache/airflow/pull/35857#discussion_r1405470805
##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1577,15 +1577,18 @@ def _fail_tasks_stuck_in_queued(self, session: Session = NEW_SESSION) -> None:
)
).all()
try:
- tis_for_warning_message = self.job.executor.cleanup_stuck_queued_tasks(tis=tasks_stuck_in_queued)
- if tis_for_warning_message:
- task_instance_str = "\n\t".join(tis_for_warning_message)
- self.log.warning(
- "Marked the following %s task instances stuck in queued as failed. "
- "If the task instance has available retries, it will be retried.\n\t%s",
- len(tasks_stuck_in_queued),
- task_instance_str,
- )
+ cleaned_up_task_instances = self.job.executor.cleanup_stuck_queued_tasks(
+ tis=tasks_stuck_in_queued
+ )
+ cleaned_up_task_instances = set(cleaned_up_task_instances)
+ for ti in tasks_stuck_in_queued:
+ if repr(ti) in cleaned_up_task_instances:
+ self._task_context_logger.error(
+ "Marking task instance %s stuck in queued as failed. "
+ "If the task instance has available retries, it will be retried.",
+ ti,
+ ti=ti,
Review Comment:
It might be a good idea to log both separately. One is for reasons of clarity. The other is that the information you need is slightly different in the two contexts. E.g. with task instance log, the message doesn't need to reference the task instance details, cus it's implied by the context. But these are things we can tweak later since everything is private.
--
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
Re: [PR] Send explicit task logs when marking tasks stuck in queued as failed [airflow]
Posted by "pankajkoti (via GitHub)" <gi...@apache.org>.
pankajkoti merged PR #35857:
URL: https://github.com/apache/airflow/pull/35857
--
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
Re: [PR] Send explicit task logs when marking tasks stuck in queued as failed [airflow]
Posted by "ephraimbuddy (via GitHub)" <gi...@apache.org>.
ephraimbuddy commented on code in PR #35857:
URL: https://github.com/apache/airflow/pull/35857#discussion_r1405348580
##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1577,15 +1577,18 @@ def _fail_tasks_stuck_in_queued(self, session: Session = NEW_SESSION) -> None:
)
).all()
try:
- tis_for_warning_message = self.job.executor.cleanup_stuck_queued_tasks(tis=tasks_stuck_in_queued)
- if tis_for_warning_message:
- task_instance_str = "\n\t".join(tis_for_warning_message)
- self.log.warning(
- "Marked the following %s task instances stuck in queued as failed. "
- "If the task instance has available retries, it will be retried.\n\t%s",
- len(tasks_stuck_in_queued),
- task_instance_str,
- )
+ cleaned_up_task_instances = self.job.executor.cleanup_stuck_queued_tasks(
+ tis=tasks_stuck_in_queued
+ )
+ cleaned_up_task_instances = set(cleaned_up_task_instances)
+ for ti in tasks_stuck_in_queued:
+ if repr(ti) in cleaned_up_task_instances:
+ self._task_context_logger.error(
+ "Marking task instance %s stuck in queued as failed. "
+ "If the task instance has available retries, it will be retried.",
+ ti,
+ ti=ti,
Review Comment:
Looks good but we would lose this information if the user disables the feature. I think both scheduler and task should have the information for the time being.
Another thing that worries me is the performance implication but in theory, I don't think there would be many tasks stuck in queued state.
--
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
Re: [PR] Send explicit task logs when marking tasks stuck in queued as failed [airflow]
Posted by "pankajkoti (via GitHub)" <gi...@apache.org>.
pankajkoti commented on PR #35857:
URL: https://github.com/apache/airflow/pull/35857#issuecomment-1826679595
<img width="1717" alt="Screenshot 2023-11-26 at 12 23 20 PM" src="https://github.com/apache/airflow/assets/10206082/e8d87e6e-1b39-487f-a606-06d06905bffd">
--
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
Re: [PR] Send explicit task logs when marking tasks stuck in queued as failed [airflow]
Posted by "ephraimbuddy (via GitHub)" <gi...@apache.org>.
ephraimbuddy commented on code in PR #35857:
URL: https://github.com/apache/airflow/pull/35857#discussion_r1405350011
##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1577,15 +1577,18 @@ def _fail_tasks_stuck_in_queued(self, session: Session = NEW_SESSION) -> None:
)
).all()
try:
- tis_for_warning_message = self.job.executor.cleanup_stuck_queued_tasks(tis=tasks_stuck_in_queued)
- if tis_for_warning_message:
- task_instance_str = "\n\t".join(tis_for_warning_message)
- self.log.warning(
- "Marked the following %s task instances stuck in queued as failed. "
- "If the task instance has available retries, it will be retried.\n\t%s",
- len(tasks_stuck_in_queued),
- task_instance_str,
- )
+ cleaned_up_task_instances = self.job.executor.cleanup_stuck_queued_tasks(
+ tis=tasks_stuck_in_queued
+ )
+ cleaned_up_task_instances = set(cleaned_up_task_instances)
+ for ti in tasks_stuck_in_queued:
+ if repr(ti) in cleaned_up_task_instances:
+ self._task_context_logger.error(
+ "Marking task instance %s stuck in queued as failed. "
+ "If the task instance has available retries, it will be retried.",
+ ti,
+ ti=ti,
Review Comment:
Nice
--
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
Re: [PR] Send explicit task logs when marking tasks stuck in queued as failed [airflow]
Posted by "pankajkoti (via GitHub)" <gi...@apache.org>.
pankajkoti closed pull request #35857: Send explicit task logs when marking tasks stuck in queued as failed
URL: https://github.com/apache/airflow/pull/35857
--
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
Re: [PR] Send explicit task logs when marking tasks stuck in queued as failed [airflow]
Posted by "pankajkoti (via GitHub)" <gi...@apache.org>.
pankajkoti commented on PR #35857:
URL: https://github.com/apache/airflow/pull/35857#issuecomment-1826680847
cc: @RNHTTR @vatsrahul1001
--
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
Re: [PR] Send explicit task logs when marking tasks stuck in queued as failed [airflow]
Posted by "pankajkoti (via GitHub)" <gi...@apache.org>.
pankajkoti commented on code in PR #35857:
URL: https://github.com/apache/airflow/pull/35857#discussion_r1405349816
##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1577,15 +1577,18 @@ def _fail_tasks_stuck_in_queued(self, session: Session = NEW_SESSION) -> None:
)
).all()
try:
- tis_for_warning_message = self.job.executor.cleanup_stuck_queued_tasks(tis=tasks_stuck_in_queued)
- if tis_for_warning_message:
- task_instance_str = "\n\t".join(tis_for_warning_message)
- self.log.warning(
- "Marked the following %s task instances stuck in queued as failed. "
- "If the task instance has available retries, it will be retried.\n\t%s",
- len(tasks_stuck_in_queued),
- task_instance_str,
- )
+ cleaned_up_task_instances = self.job.executor.cleanup_stuck_queued_tasks(
+ tis=tasks_stuck_in_queued
+ )
+ cleaned_up_task_instances = set(cleaned_up_task_instances)
+ for ti in tasks_stuck_in_queued:
+ if repr(ti) in cleaned_up_task_instances:
+ self._task_context_logger.error(
+ "Marking task instance %s stuck in queued as failed. "
+ "If the task instance has available retries, it will be retried.",
+ ti,
+ ti=ti,
Review Comment:
We won't loose this information. Even if the user disables the feature the TCL would log this information using this site's logger in the scheduler itself https://github.com/apache/airflow/pull/32646/files#diff-fb48bd1344270ccbaadb60b2b7fbc5d74bb5440f908eedd384bd25ada648c05dR91
Yes, we can test the performance. If it hits the performance badly, we can disable the feature and still have logs as mentioned above.
--
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
Re: [PR] Send explicit task logs when marking tasks stuck in queued as failed [airflow]
Posted by "pankajkoti (via GitHub)" <gi...@apache.org>.
pankajkoti commented on code in PR #35857:
URL: https://github.com/apache/airflow/pull/35857#discussion_r1405350927
##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1577,15 +1577,18 @@ def _fail_tasks_stuck_in_queued(self, session: Session = NEW_SESSION) -> None:
)
).all()
try:
- tis_for_warning_message = self.job.executor.cleanup_stuck_queued_tasks(tis=tasks_stuck_in_queued)
- if tis_for_warning_message:
- task_instance_str = "\n\t".join(tis_for_warning_message)
- self.log.warning(
- "Marked the following %s task instances stuck in queued as failed. "
- "If the task instance has available retries, it will be retried.\n\t%s",
- len(tasks_stuck_in_queued),
- task_instance_str,
- )
+ cleaned_up_task_instances = self.job.executor.cleanup_stuck_queued_tasks(
+ tis=tasks_stuck_in_queued
+ )
+ cleaned_up_task_instances = set(cleaned_up_task_instances)
+ for ti in tasks_stuck_in_queued:
+ if repr(ti) in cleaned_up_task_instances:
+ self._task_context_logger.error(
+ "Marking task instance %s stuck in queued as failed. "
+ "If the task instance has available retries, it will be retried.",
+ ti,
+ ti=ti,
Review Comment:
And the call site logger is set from the scheduler component while initialising TCL instance here: https://github.com/apache/airflow/pull/32646/files#diff-b0491913f69327937706aea8fc77a71efeb979897898e405ade2b162ad862476R239
--
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
Re: [PR] Send explicit task logs when marking tasks stuck in queued as failed [airflow]
Posted by "ephraimbuddy (via GitHub)" <gi...@apache.org>.
ephraimbuddy commented on code in PR #35857:
URL: https://github.com/apache/airflow/pull/35857#discussion_r1405351054
##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1577,15 +1577,18 @@ def _fail_tasks_stuck_in_queued(self, session: Session = NEW_SESSION) -> None:
)
).all()
try:
- tis_for_warning_message = self.job.executor.cleanup_stuck_queued_tasks(tis=tasks_stuck_in_queued)
- if tis_for_warning_message:
- task_instance_str = "\n\t".join(tis_for_warning_message)
- self.log.warning(
- "Marked the following %s task instances stuck in queued as failed. "
- "If the task instance has available retries, it will be retried.\n\t%s",
- len(tasks_stuck_in_queued),
- task_instance_str,
- )
+ cleaned_up_task_instances = self.job.executor.cleanup_stuck_queued_tasks(
+ tis=tasks_stuck_in_queued
+ )
+ cleaned_up_task_instances = set(cleaned_up_task_instances)
+ for ti in tasks_stuck_in_queued:
+ if repr(ti) in cleaned_up_task_instances:
+ self._task_context_logger.error(
Review Comment:
```suggestion
self._task_context_logger.warning(
```
--
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