气流1.10:sqlalchemy.orm.exc.NoResultFound:找不到one()的行

时间:2019-01-29 01:50:32

标签: python-3.x airflow

遵循本教程时:

http://michal.karzynski.pl/blog/2017/03/19/developing-workflows-with-apache-airflow/

,或者当您创建任何DAG并尝试通过以下脚本使用API​​运行它时:

for i in {1..10}; do
    RUN_ID=BASH_REST_CALL__$(uuidgen)
    curl -X POST \
      http://localhost:8080/api/experimental/dags/my_test_dag/dag_runs \
      -H 'Cache-Control: no-cache' \
      -H 'Content-Type: application/json'  -d "{\"run_id\": \"${RUN_ID}\"}" &
 done

在一些回复中,您可以看到:

                          ____/ (  (    )   )  \___
                         /( (  (  )   _    ))  )   )\
                       ((     (   )(    )  )   (   )  )
                     ((/  ( _(   )   (   _) ) (  () )  )
                    ( (  ( (_)   ((    (   )  .((_ ) .  )_
                   ( (  )    (      (  )    )   ) . ) (   )
                  (  (   (  (   ) (  _  ( _) ).  ) . ) ) ( )
                  ( (  (   ) (  )   (  ))     ) _)(   )  )  )
                 ( (  ( \ ) (    (_  ( ) ( )  )   ) )  )) ( )
                  (  (   (  (   (_ ( ) ( _    )  ) (  )  )   )
                 ( (  ( (  (  )     (_  )  ) )  _)   ) _( ( )
                  ((  (   )(    (     _    )   _) _(_ (  (_ )
                   (_((__(_(__(( ( ( |  ) ) ) )_))__))_)___)
                   ((__)        \\||lll|l||///          \_))
                            (   /(/ (  )  ) )\   )
                          (    ( ( ( | | ) ) )\   )
                           (   /(| / ( )) ) ) )) )
                         (     ( ((((_(|)_)))))     )
                          (      ||\(|(|)|/||     )
                        (        |(||(||)||||        )
                          (     //|/l|||)|\\ \     )
                        (/ / //  /|//||||\\  \ \  \ _)
-------------------------------------------------------------------------------
Node: 5b104ab0dac5
-------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.6/site-packages/airflow/api/auth/backend/default.py", line 32, in decorated
    return function(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/airflow/www/api/experimental/endpoints.py", line 78, in trigger_dag
    dr = trigger.trigger_dag(dag_id, run_id, conf, execution_date)
  File "/usr/local/lib/python3.6/site-packages/airflow/api/common/experimental/trigger_dag.py", line 101, in trigger_dag
    replace_microseconds=replace_microseconds,
  File "/usr/local/lib/python3.6/site-packages/airflow/api/common/experimental/trigger_dag.py", line 77, in _trigger_dag
    external_trigger=True,
  File "/usr/local/lib/python3.6/site-packages/airflow/utils/db.py", line 73, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/airflow/models.py", line 4382, in create_dagrun
    run.refresh_from_db()
  File "/usr/local/lib/python3.6/site-packages/airflow/utils/db.py", line 73, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/airflow/models.py", line 5064, in refresh_from_db
    DR.run_id == self.run_id
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3046, in one
    raise orm_exc.NoResultFound("No row was found for one()")
sqlalchemy.orm.exc.NoResultFound: No row was found for one()

1 个答案:

答案 0 :(得分:1)

我得到同样的错误。我认为这是由于同时插入许多任务。由于某种原因,它使其爆炸。如果在其中应该添加一个sleep命令,它应该可以工作,但这显然并不理想,因为有时您一次插入多个任务。

我认为这也可能是由于mysql与postgres对时间戳的处理方式不同。似乎气流团队主要在postgres上进行测试。我现在更新为使用postgres而不是mysql。我会更新。