Skip to content

Commit

Permalink
Fix Orphaned tasks stuck in CeleryExecutor as running (#16550)
Browse files Browse the repository at this point in the history
(cherry picked from commit 90f0088)
  • Loading branch information
Jorricks authored and ashb committed Jun 22, 2021
1 parent 7603ef6 commit c6313e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 1 addition & 3 deletions airflow/executors/celery_executor.py
Expand Up @@ -369,9 +369,7 @@ def _check_for_stalled_adopted_tasks(self):
"\n\t".join([repr(x) for x in timedout_keys]),
)
for key in timedout_keys:
self.event_buffer[key] = (State.FAILED, None)
del self.tasks[key]
del self.adopted_task_timeouts[key]
self.change_state(key, State.FAILED)

def debug_dump(self) -> None:
"""Called in response to SIGUSR2 by the scheduler"""
Expand Down
2 changes: 2 additions & 0 deletions tests/executors/test_celery_executor.py
Expand Up @@ -371,10 +371,12 @@ def test_check_for_stalled_adopted_tasks(self):
key_1: queued_dttm + executor.task_adoption_timeout,
key_2: queued_dttm + executor.task_adoption_timeout,
}
executor.running = {key_1, key_2}
executor.tasks = {key_1: AsyncResult("231"), key_2: AsyncResult("232")}
executor.sync()
assert executor.event_buffer == {key_1: (State.FAILED, None), key_2: (State.FAILED, None)}
assert executor.tasks == {}
assert executor.running == set()
assert executor.adopted_task_timeouts == {}


Expand Down

0 comments on commit c6313e4

Please sign in to comment.