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 2020/09/11 13:52:54 UTC

[GitHub] [airflow] ashb opened a new pull request #10881: Mark task as failed when it fails "sending" in Celery

ashb opened a new pull request #10881:
URL: https://github.com/apache/airflow/pull/10881


   If a task failed hard on celery, _before_ being able to execute the
   airflow code the task would end up stuck in queued state. This change
   makes it get retried.
   
   This was discovered in load testing the HA work (but unrelated to HA
   changes), where I swamped the kube-dns pod, meaning the worker was
   sometimes unable to resolve the db name via DNS, so the state in the DB
   was never updated.
   
   Sadly this is very hard to exercise in unit tests. Open to ideas how we might be able to test this.
   
   <!--
   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 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/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+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 [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#discussion_r487291820



##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       Agreed, and I normally do our this way. Wonder why I didn't this time




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
turbaszek commented on pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#issuecomment-691231895






----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
turbaszek commented on pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#issuecomment-691231895






----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb merged pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
ashb merged pull request #10881:
URL: https://github.com/apache/airflow/pull/10881


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] kaxil commented on pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
kaxil commented on pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#issuecomment-691174561


   One test is failing
   ```
   FAILED tests/executors/test_celery_executor.py::TestCeleryExecutor::test_error_sending_task
   ```


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#discussion_r487291820



##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       Agreed, and I normally do our this way. Wonder why I didn't this time

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       Agreed, and I normally do our this way. Wonder why I didn't this time

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       Agreed, and I normally do our this way. Wonder why I didn't this time

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       Agreed, and I normally do our this way. Wonder why I didn't this time

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       Agreed, and I normally do our this way. Wonder why I didn't this time

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       Agreed, and I normally do our this way. Wonder why I didn't this time

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       Agreed, and I normally do our this way. Wonder why I didn't this time

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       Agreed, and I normally do our this way. Wonder why I didn't this time




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] kaxil commented on pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
kaxil commented on pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#issuecomment-691174561






----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] kaxil commented on pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
kaxil commented on pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#issuecomment-691174561






----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on a change in pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#discussion_r487200043



##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       No hard opinion but for me this looks more readable
   ```suggestion
                   self.event_buffer[key] = (State.FAILED, None)
   ```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#discussion_r487291820



##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       Agreed, and I normally do our this way. Wonder why I didn't this time




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on a change in pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#discussion_r487200043



##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       No hard opinion but for me this looks more readable
   ```suggestion
                   self.event_buffer[key] = (State.FAILED, None)
   ```

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       No hard opinion but for me this looks more readable
   ```suggestion
                   self.event_buffer[key] = (State.FAILED, None)
   ```

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       No hard opinion but for me this looks more readable
   ```suggestion
                   self.event_buffer[key] = (State.FAILED, None)
   ```

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       No hard opinion but for me this looks more readable
   ```suggestion
                   self.event_buffer[key] = (State.FAILED, None)
   ```

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       No hard opinion but for me this looks more readable
   ```suggestion
                   self.event_buffer[key] = (State.FAILED, None)
   ```

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       No hard opinion but for me this looks more readable
   ```suggestion
                   self.event_buffer[key] = (State.FAILED, None)
   ```

##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       No hard opinion but for me this looks more readable
   ```suggestion
                   self.event_buffer[key] = (State.FAILED, None)
   ```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on a change in pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#discussion_r487200043



##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       No hard opinion but for me this looks more readable
   ```suggestion
                   self.event_buffer[key] = (State.FAILED, None)
   ```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on a change in pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#discussion_r487200043



##########
File path: airflow/executors/celery_executor.py
##########
@@ -188,14 +189,13 @@ def _process_tasks(self, task_tuples_to_send: List[TaskInstanceInCelery]) -> Non
         self.log.debug('Sent all tasks.')
 
         for key, _, result in key_and_async_results:
+            self.queued_tasks.pop(key)
             if isinstance(result, ExceptionWithTraceback):
                 self.log.error(  # pylint: disable=logging-not-lazy
                     CELERY_SEND_ERR_MSG_HEADER + ":%s\n%s\n", result.exception, result.traceback
                 )
+                self.event_buffer[key] = State.FAILED, None

Review comment:
       No hard opinion but for me this looks more readable
   ```suggestion
                   self.event_buffer[key] = (State.FAILED, None)
   ```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on pull request #10881: Mark task as failed when it fails "sending" in Celery

Posted by GitBox <gi...@apache.org>.
turbaszek commented on pull request #10881:
URL: https://github.com/apache/airflow/pull/10881#issuecomment-691231895


   @olchas this sounds like it may solve the issue you observed when cluster was scaling up


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org