airflow icon indicating copy to clipboard operation
airflow copied to clipboard

Queued tasks not running

Open abridgett opened this issue 10 years ago • 13 comments

Dear Airflow Maintainers,

Before I tell you about my issue, let me describe my environment:

Environment

  • 1.7.0 (and a few unrelated fixes I submitted recently)
  • Running a Scheduler with CeleryExecutor
  • Example code to reproduce the bug (as a code snippet in markdown)
  • TimeOperator upstream of two PythonOperators (which then trigger four notifications)
  • Operating System: Linux
  • Python Version: 3.4.3(2.7.6 installed as well but it should be using v3)

Now that you know a little about me, let me tell you about the issue I am having:

Description of Issue

  • After upgrading to 1.7.0 I'm seeing tasks queued that are never run
[2016-04-11 13:36:22,579] {jobs.py:709} INFO - Done queuing tasks, calling the executor's heartbeat
[2016-04-11 13:36:22,579] {jobs.py:712} INFO - Loop took: 0.209075 seconds
[2016-04-11 13:36:22,580] {models.py:256} INFO - Finding 'running' jobs without a recent heartbeat
[2016-04-11 13:36:22,580] {models.py:262} INFO - Failing jobs without heartbeat after 2016-04-11 13:34:07.580924
[2016-04-11 13:36:27,375] {jobs.py:536} INFO - APB: process_events
[2016-04-11 13:36:27,378] {jobs.py:580} INFO - Prioritizing 0 queued jobs
[2016-04-11 13:36:27,401] {models.py:2405} INFO - Checking state for <DagRun update_hdfs @ 2016-04-09 00:00:00: scheduled__2016-04-09T00:00:00, externally triggered: False>
[2016-04-11 13:36:27,401] {jobs.py:488} INFO - Getting list of tasks to skip for active runs.
[2016-04-11 13:36:27,402] {jobs.py:503} INFO - Checking dependencies on 7 tasks instances, minus 4 skippable ones

This seems to be related to: https://github.com/airbnb/airflow/commit/d498df2e22b75f36da1f365ef0c6a55c40602b1b

If I put the direct query back in all works well, but I'm not sure how the implemented change should work - process_queue() is being called, but there is nothing in the executor_queue so the loop does nothing (in particular it's not adding anything to self.queued_tis).

AFAICT this all depends upon something calling change_state after a task is queued.

abridgett avatar Apr 11 '16 13:04 abridgett

I should mention that these two tasks that get stuck have their own pool (in airflow)

abridgett avatar Apr 11 '16 13:04 abridgett

@jlowin

bolkedebruin avatar Apr 11 '16 14:04 bolkedebruin

@abridgett there was a conflict with queueing in certain situations that I think has been fixed in Master, could you please try pulling the latest version from github and seeing if the issue is still there?

jlowin avatar Apr 11 '16 15:04 jlowin

Thanks - I will do, might be unable to test for a day or so (I had used master and seem something similar last Thursday, decided to use 1.70 instead and that had seemed okay). I don't support you know which commit(s) may have fixed it in case it's easier to apply the fix rather than go straight to master?

abridgett avatar Apr 11 '16 15:04 abridgett

I think it will be this one: https://github.com/airbnb/airflow/pull/1290/commits/b2844af020cb5a470bd83ead09ddb121923084ca But we tried to solve about a thousand "infinite retry" scenarios over the last two weeks and I'm not totally sure. It's also possible you have a genuinely new issue in which case I want to make sure we solve it!

jlowin avatar Apr 11 '16 16:04 jlowin

Super - that looks good on a test box, I'll confirm properly tomorrow

abridgett avatar Apr 11 '16 16:04 abridgett

FYI just that one commit doesn't seem sufficient. Not sure if I'll get around to updating to master today

abridgett avatar Apr 12 '16 12:04 abridgett

Deploying on a test instance that had about seven days to catchup, things seemed okay but on the last day it's got stuck again. Even had this email which seems a little odd (jobs are blocked by themselves?)

Here's a list of tasks thas missed their SLAs: 
speedmap on 2016-04-12T00:00:00
cellsmap on 2016-04-12T00:00:00
Blocking tasks:
speedmap on 2016-04-12T00:00:00
cellsmap on 2016-04-12T00:00:00

Scheduler log (there's a time delay task that ran first):

2016-04-13 11:29:26,328 INFO - Checking dependencies on 7 tasks instances, minus 1 skippable ones
2016-04-13 11:29:26,339 INFO - Adding to queue: airflow run update_hdfs cellsmap 2016-04-12T00:00:00 --local --pool cellsmap -sd DAGS_FOLDER/update_hdfs.py
2016-04-13 11:29:26,349 INFO - Adding to queue: airflow run update_hdfs speedmap 2016-04-12T00:00:00 --local --pool speedmap -sd DAGS_FOLDER/update_hdfs.py
2016-04-13 11:29:26,386 INFO - [celery] queuing ('update_hdfs', 'speedmap', datetime.datetime(2016, 4, 12, 0, 0)) through celery, queue=default
2016-04-13 11:29:26,387 INFO - [celery] queuing ('update_hdfs', 'cellsmap', datetime.datetime(2016, 4, 12, 0, 0)) through celery, queue=default
...
2016-04-13 12:30:52,260 INFO - Finding 'running' jobs without a recent heartbeat
2016-04-13 12:30:52,260 INFO - Failing jobs without heartbeat after 2016-04-13 12:28:37.260495
2016-04-13 12:30:57,162 INFO - Prioritizing 0 queued jobs
2016-04-13 12:30:57,233 INFO - Checking state for <DagRun update_hdfs @ 2016-04-12 00:00:00: scheduled__2016-04-12T00:00:00, externally triggered: False>
2016-04-13 12:30:57,237 INFO - Getting list of tasks to skip for active runs.
2016-04-13 12:30:57,238 INFO - Checking dependencies on 7 tasks instances, minus 1 skippable ones
2016-04-13 12:30:57,275 INFO - Done queuing tasks, calling the executor's heartbeat
2016-04-13 12:30:57,275 INFO - Loop took: 0.113775 seconds

abridgett avatar Apr 13 '16 12:04 abridgett

This was with master@876d765 (with https://github.com/airbnb/airflow/pull/1274 applied on top)

abridgett avatar Apr 13 '16 12:04 abridgett

I think the SLA email makes sense -- those two tasks didn't complete on time and they were also the reason (as opposed to an upstream task, for example).

But I'm still confused on the queued issue. Especially since it worked for 7 runs and then failed on the last one -- if the queuing logic were broken I think none of them would have worked.

I don't suppose there's a way you can share a minimal version of your DAG that demonstrates the issue?

jlowin avatar Apr 13 '16 13:04 jlowin

Sure, no problem. It's 200 lines long (but only a few steps so the relevant bit is probably quite small). Would rather not make it too public - email? (I'm [email protected] if you want to drop me a line)

abridgett avatar Apr 13 '16 13:04 abridgett

@jlowin Wondering if this issue is only present in 1.7x? We saw a very similar task-hanging issue on version 1.6.2, but cannot confirm if it's the same. e.g.

2016-04-28T01:09:59.70973 [2016-04-28 01:09:59,709] {jobs.py:470} INFO - Checking dependencies on 0 tasks instances, minus 0 skippable ones
2016-04-28T01:09:59.75093 [2016-04-28 01:09:59,750] {jobs.py:633} INFO - Done queuing tasks, calling the executor's heartbeat
2016-04-28T01:09:59.75105 [2016-04-28 01:09:59,750] {jobs.py:636} INFO - Loop took: 1.309239 seconds
2016-04-28T01:09:59.75341 [2016-04-28 01:09:59,753] {models.py:222} INFO - Finding 'running' jobs without a recent heartbeat
2016-04-28T01:09:59.75364 [2016-04-28 01:09:59,753] {models.py:228} INFO - Failing jobs without heartbeat after 2016-04-28 01:07:44.753553
2016-04-28T01:10:58.48647 [2016-04-28 01:10:58,486] {jobs.py:507} INFO - Prioritizing 0 queued jobs
2016-04-28T01:10:58.51371 [2016-04-28 01:10:58,513] {jobs.py:455} INFO - Getting list of tasks to skip for active runs.
2016-04-28T01:10:58.51379 [2016-04-28 01:10:58,513] {jobs.py:470} INFO - Checking dependencies on 0 tasks instances, minus 0 skippable ones

Thanks!

reconditesea avatar Apr 29 '16 06:04 reconditesea

Please track https://issues.apache.org/jira/browse/AIRFLOW-56 for this issue.

bolkedebruin avatar May 07 '16 11:05 bolkedebruin