[
https://issues.apache.org/jira/browse/AIRFLOW-5194?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16998773#comment-16998773
]
ASF subversion and git services commented on AIRFLOW-5194:
----------------------------------------------------------
Commit 331e2c5a86b3e84e8419c18b3092ec95ecd728eb in airflow's branch
refs/heads/v1-10-test from Victor Villas
[ https://gitbox.apache.org/repos/asf?p=airflow.git;h=331e2c5 ]
[AIRFLOW-5194] Add error handler to action log (#5883)
(cherry-picked from a86b6ac01166298d0d138512c3cb0c7dc68cba79)
> Make @cli_utils.action_logging silent about missing log table
> -------------------------------------------------------------
>
> Key: AIRFLOW-5194
> URL: https://issues.apache.org/jira/browse/AIRFLOW-5194
> Project: Apache Airflow
> Issue Type: Improvement
> Components: cli
> Affects Versions: 1.10.4
> Reporter: Victor Villas Bôas Chaves
> Priority: Minor
> Fix For: 2.0.0, 1.10.7
>
>
> https://issues.apache.org/jira/browse/AIRFLOW-2253 introduced
> `@cli_utils.action_logging` to CLI commands, but a few of those commands are
> reasonably expected to run before the database has been initialized. On doing
> so, an `relation "log" does not exist` error pops out (see below for a
> complete output).
> https://issues.apache.org/jira/browse/AIRFLOW-2436 was created and solved
> that problem in the `initdb` command itself, but this still affects two
> commands that are often used before tables exist: `version` and `upgradedb`
> (which is frequently used as a kind of `initdb` that won't load default
> connections, so quite a few people use it to initialize the db as well).
>
> {code:java}
> [root@ip-10-0-11-97 ~]# /usr/local/bin/airflow version
> /usr/local/lib/python3.7/site-packages/airflow/configuration.py:614:
> DeprecationWarning: You have two airflow.cfg files: /root/airflow/airflow.cfg
> and /airflow/airflow.cfg. Airflow used to look at ~/airflow/airflow.cfg, even
> when AIRFLOW_HOME was set to a different value. Airflow will now only read
> /airflow/airflow.cfg, and you should remove the other file
> category=DeprecationWarning,
> [2019-08-13 11:13:39,985] {settings.py:213} INFO - settings.configure_orm():
> Using pool settings. pool_size=5, max_overflow=10, pool_recycle=1800, pid=3547
> /usr/local/lib64/python3.7/site-packages/psycopg2/__init__.py:144:
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in
> order to keep installing from binary please use "pip install psycopg2-binary"
> instead. For details see:
> <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
> """)
> [2019-08-13 11:13:40,188] {__init__.py:51} INFO - Using executor
> CeleryExecutor
> [2019-08-13 11:13:40,524] {cli_action_loggers.py:70} ERROR - Failed on
> pre-execution callback using <function default_action_log at 0x7fc6e1afe200>
> Traceback (most recent call last):
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py",
> line 1244, in _execute_context
> cursor, statement, parameters, context
> File
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/default.py", line
> 552, in do_execute
> cursor.execute(statement, parameters)
> psycopg2.ProgrammingError: relation "log" does not exist
> LINE 1: INSERT INTO log (dttm, dag_id, task_id, event, execution_dat...
> ^
> The above exception was the direct cause of the following exception:
> Traceback (most recent call last):
> File
> "/usr/local/lib/python3.7/site-packages/airflow/utils/cli_action_loggers.py",
> line 68, in on_pre_execution
> cb(**kwargs)
> File
> "/usr/local/lib/python3.7/site-packages/airflow/utils/cli_action_loggers.py",
> line 99, in default_action_log
> session.add(log)
> File "/usr/lib64/python3.7/contextlib.py", line 119, in __exit__
> next(self.gen)
> File "/usr/local/lib/python3.7/site-packages/airflow/utils/db.py", line 45,
> in create_session
> session.commit()
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py",
> line 1027, in commit
> self.transaction.commit()
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py",
> line 494, in commit
> self._prepare_impl()
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py",
> line 473, in _prepare_impl
> self.session.flush()
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py",
> line 2459, in flush
> self._flush(objects)
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py",
> line 2597, in _flush
> transaction.rollback(_capture_exception=True)
> File
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/util/langhelpers.py",
> line 68, in __exit__
> compat.reraise(exc_type, exc_value, exc_tb)
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/util/compat.py",
> line 153, in reraise
> raise value
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py",
> line 2557, in _flush
> flush_context.execute()
> File
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line
> 422, in execute
> rec.execute(self)
> File
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line
> 589, in execute
> uow,
> File
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/persistence.py",
> line 245, in save_obj
> insert,
> File
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/persistence.py",
> line 1138, in _emit_insert_statements
> statement, params
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py",
> line 988, in execute
> return meth(self, multiparams, params)
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/sql/elements.py",
> line 287, in _execute_on_connection
> return connection._execute_clauseelement(self, multiparams, params)
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py",
> line 1107, in _execute_clauseelement
> distilled_params,
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py",
> line 1248, in _execute_context
> e, statement, parameters, cursor, context
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py",
> line 1466, in _handle_dbapi_exception
> util.raise_from_cause(sqlalchemy_exception, exc_info)
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/util/compat.py",
> line 398, in raise_from_cause
> reraise(type(exception), exception, tb=exc_tb, cause=cause)
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/util/compat.py",
> line 152, in reraise
> raise value.with_traceback(tb)
> File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py",
> line 1244, in _execute_context
> cursor, statement, parameters, context
> File
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/default.py", line
> 552, in do_execute
> cursor.execute(statement, parameters)
> sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "log"
> does not exist
> LINE 1: INSERT INTO log (dttm, dag_id, task_id, event, execution_dat...
> ^
> [SQL: INSERT INTO log (dttm, dag_id, task_id, event, execution_date, owner,
> extra) VALUES (%(dttm)s, %(dag_id)s, %(task_id)s, %(event)s,
> %(execution_date)s, %(owner)s, %(extra)s) RETURNING log.id]
> [parameters: {'dttm': datetime.datetime(2019, 8, 13, 11, 13, 40, 486015,
> tzinfo=<Timezone [UTC]>), 'dag_id': None, 'task_id': None, 'event':
> 'cli_version', 'execution_date': None, 'owner': 'root', 'extra':
> '{"host_name": "ip-10-0-11-97.ec2.internal", "full_command":
> "[\'/usr/local/bin/airflow\', \'version\']"}'}]
> (Background on this error at: http://sqlalche.me/e/f405)
> ____________ _____________
> ____ |__( )_________ __/__ /________ __
> ____ /| |_ /__ ___/_ /_ __ /_ __ \_ | /| / /
> ___ ___ | / _ / _ __/ _ / / /_/ /_ |/ |/ /
> _/_/ |_/_/ /_/ /_/ /_/ \____/____/|__/ v1.10.4
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)