You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Bolke de Bruin (JIRA)" <ji...@apache.org> on 2018/01/27 08:02:00 UTC

[jira] [Resolved] (AIRFLOW-1895) Broken add_time_zone migration for mysql

     [ https://issues.apache.org/jira/browse/AIRFLOW-1895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bolke de Bruin resolved AIRFLOW-1895.
-------------------------------------
       Resolution: Fixed
    Fix Version/s: 1.10.0

Issue resolved by pull request #2979
[https://github.com/apache/incubator-airflow/pull/2979]

> Broken add_time_zone migration for mysql
> ----------------------------------------
>
>                 Key: AIRFLOW-1895
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-1895
>             Project: Apache Airflow
>          Issue Type: Bug
>            Reporter: Edgar Rodriguez
>            Assignee: Edgar Rodriguez
>            Priority: Major
>             Fix For: 1.10.0
>
>
> A clean install fails when initializing the airflow DB and running the migrations with the following error:
> {code}
> (airflow) ➜  airflow airflow initdb
> [2017-12-07 16:59:26,638] {configuration.py:209} WARNING - section/key [celery/celery_ssl_active] not found in config
> [2017-12-07 16:59:26,639] {default_celery.py:45} WARNING - Celery Executor will run without SSL
> [2017-12-07 16:59:26,639] {default_celery.py:66} WARNING - You have configured a result_backend of redis://localhost:6379/0, it is highly recommended to use an alternative result_backend (i.e. a database).
> [2017-12-07 16:59:26,641] {__init__.py:45} INFO - Using executor CeleryExecutor
> [2017-12-07 16:59:26,839] {db.py:300} INFO - Creating tables
> /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/SQLAlchemy-1.2.0b1-py2.7-macosx-10.12-x86_64.egg/sqlalchemy/dialects/mysql/base.py:1713: Warning: (1287L, "'@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead")
> INFO  [alembic.runtime.migration] Context impl MySQLImpl.
> INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
> INFO  [alembic.runtime.migration] Running upgrade  -> e3a246e0dc1, current schema
> INFO  [alembic.runtime.migration] Running upgrade e3a246e0dc1 -> 1507a7289a2f, create is_encrypted
> INFO  [alembic.runtime.migration] Running upgrade 1507a7289a2f -> 13eb55f81627, maintain history for compatibility with earlier migrations
> INFO  [alembic.runtime.migration] Running upgrade 13eb55f81627 -> 338e90f54d61, More logging into task_isntance
> INFO  [alembic.runtime.migration] Running upgrade 338e90f54d61 -> 52d714495f0, job_id indices
> INFO  [alembic.runtime.migration] Running upgrade 52d714495f0 -> 502898887f84, Adding extra to Log
> INFO  [alembic.runtime.migration] Running upgrade 502898887f84 -> 1b38cef5b76e, add dagrun
> INFO  [alembic.runtime.migration] Running upgrade 1b38cef5b76e -> 2e541a1dcfed, task_duration
> INFO  [alembic.runtime.migration] Running upgrade 2e541a1dcfed -> 40e67319e3a9, dagrun_config
> INFO  [alembic.runtime.migration] Running upgrade 40e67319e3a9 -> 561833c1c74b, add password column to user
> INFO  [alembic.runtime.migration] Running upgrade 561833c1c74b -> 4446e08588, dagrun start end
> INFO  [alembic.runtime.migration] Running upgrade 4446e08588 -> bbc73705a13e, Add notification_sent column to sla_miss
> INFO  [alembic.runtime.migration] Running upgrade bbc73705a13e -> bba5a7cfc896, Add a column to track the encryption state of the 'Extra' field in connection
> INFO  [alembic.runtime.migration] Running upgrade bba5a7cfc896 -> 1968acfc09e3, add is_encrypted column to variable table
> INFO  [alembic.runtime.migration] Running upgrade 1968acfc09e3 -> 2e82aab8ef20, rename user table
> INFO  [alembic.runtime.migration] Running upgrade 2e82aab8ef20 -> 211e584da130, add TI state index
> INFO  [alembic.runtime.migration] Running upgrade 211e584da130 -> 64de9cddf6c9, add task fails journal table
> INFO  [alembic.runtime.migration] Running upgrade 64de9cddf6c9 -> f2ca10b85618, add dag_stats table
> INFO  [alembic.runtime.migration] Running upgrade f2ca10b85618 -> 4addfa1236f1, Add fractional seconds to mysql tables
> INFO  [alembic.runtime.migration] Running upgrade 4addfa1236f1 -> 8504051e801b, xcom dag task indices
> INFO  [alembic.runtime.migration] Running upgrade 8504051e801b -> 5e7d17757c7a, add pid field to TaskInstance
> INFO  [alembic.runtime.migration] Running upgrade 5e7d17757c7a -> 127d2bf2dfa7, Add dag_id/state index on dag_run table
> INFO  [alembic.runtime.migration] Running upgrade 127d2bf2dfa7 -> cc1e65623dc7, add max tries column to task instance
> [2017-12-07 16:59:28,485] {models.py:194} INFO - Filling up the DagBag from /Users/edgar_rodriguez/airflow/dags
> /Users/edgar_rodriguez/airflow/incubator-airflow/airflow/utils/helpers.py:351: DeprecationWarning: Importing BashOperator directly from <module 'airflow.operators' from '/Users/edgar_rodriguez/airflow/incubator-airflow/airflow/operators/__init__.pyc'> has been deprecated. Please import from '<module 'airflow.operators' from '/Users/edgar_rodriguez/airflow/incubator-airflow/airflow/operators/__init__.pyc'>.[operator_module]' instead. Support for direct imports will be dropped entirely in Airflow 2.0.
>   DeprecationWarning)
> INFO  [alembic.runtime.migration] Running upgrade cc1e65623dc7 -> bdaa763e6c56, Make xcom value column a large binary
> INFO  [alembic.runtime.migration] Running upgrade bdaa763e6c56 -> 947454bf1dff, add ti job_id index
> INFO  [alembic.runtime.migration] Running upgrade 947454bf1dff -> d2ae31099d61, Increase text size for MySQL (not relevant for other DBs' text types)
> INFO  [alembic.runtime.migration] Running upgrade d2ae31099d61 -> 0e2a74e0fc9f, Add time zone awareness
> Traceback (most recent call last):
>   File "/Users/edgar_rodriguez/airflow/bin/airflow", line 6, in <module>
>     exec(compile(open(__file__).read(), __file__, 'exec'))
>   File "/Users/edgar_rodriguez/airflow/incubator-airflow/airflow/bin/airflow", line 27, in <module>
>     args.func(args)
>   File "/Users/edgar_rodriguez/airflow/incubator-airflow/airflow/bin/cli.py", line 885, in initdb
>     db_utils.initdb()
>   File "/Users/edgar_rodriguez/airflow/incubator-airflow/airflow/utils/db.py", line 87, in initdb
>     upgradedb()
>   File "/Users/edgar_rodriguez/airflow/incubator-airflow/airflow/utils/db.py", line 308, in upgradedb
>     command.upgrade(config, 'heads')
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/alembic/command.py", line 174, in upgrade
>     script.run_env()
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/alembic/script/base.py", line 416, in run_env
>     util.load_python_file(self.dir, 'env.py')
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 93, in load_python_file
>     module = load_module_py(module_id, path)
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/alembic/util/compat.py", line 79, in load_module_py
>     mod = imp.load_source(module_id, path, fp)
>   File "/Users/edgar_rodriguez/airflow/incubator-airflow/airflow/migrations/env.py", line 86, in <module>
>     run_migrations_online()
>   File "/Users/edgar_rodriguez/airflow/incubator-airflow/airflow/migrations/env.py", line 81, in run_migrations_online
>     context.run_migrations()
>   File "<string>", line 8, in run_migrations
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/alembic/runtime/environment.py", line 807, in run_migrations
>     self.get_context().run_migrations(**kw)
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/alembic/runtime/migration.py", line 321, in run_migrations
>     step.migration_fn(**kw)
>   File "/Users/edgar_rodriguez/airflow/incubator-airflow/airflow/migrations/versions/0e2a74e0fc9f_add_time_zone_awareness.py", line 61, in upgrade
>     op.alter_column(table_name='sla_miss', column_name='execution_date', type_=mysql.TIMESTAMP(fsp=6))
>   File "<string>", line 8, in alter_column
>   File "<string>", line 3, in alter_column
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/alembic/operations/ops.py", line 1420, in alter_column
>     return operations.invoke(alt)
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/alembic/operations/base.py", line 318, in invoke
>     return fn(self, operation)
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/alembic/operations/toimpl.py", line 53, in alter_column
>     **operation.kw
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/alembic/ddl/mysql.py", line 67, in alter_column
>     else existing_autoincrement
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/alembic/ddl/impl.py", line 118, in _exec
>     return conn.execute(construct, *multiparams, **params)
>   File "build/bdist.macosx-10.12-x86_64/egg/sqlalchemy/engine/base.py", line 945, in execute
>   File "build/bdist.macosx-10.12-x86_64/egg/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
>   File "build/bdist.macosx-10.12-x86_64/egg/sqlalchemy/engine/base.py", line 1002, in _execute_ddl
>   File "build/bdist.macosx-10.12-x86_64/egg/sqlalchemy/engine/base.py", line 1189, in _execute_context
>   File "build/bdist.macosx-10.12-x86_64/egg/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
>   File "build/bdist.macosx-10.12-x86_64/egg/sqlalchemy/util/compat.py", line 203, in raise_from_cause
>   File "build/bdist.macosx-10.12-x86_64/egg/sqlalchemy/engine/base.py", line 1182, in _execute_context
>   File "build/bdist.macosx-10.12-x86_64/egg/sqlalchemy/engine/default.py", line 504, in do_execute
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/MySQLdb/cursors.py", line 250, in execute
>     self.errorhandler(self, exc, value)
>   File "/Users/edgar_rodriguez/airflow/lib/python2.7/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
>     raise errorvalue
> sqlalchemy.exc.DataError: (_mysql_exceptions.DataError) (1171, 'All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead') [SQL: u'ALTER TABLE sla_miss MODIFY execution_date TIMESTAMP(6) NULL']
> {code}
> Specifically the migration {{Running upgrade d2ae31099d61 -> 0e2a74e0fc9f, Add time zone awareness}} fails by not setting {{nullable=False}} in the migration upgrade for mysql:
> {code}
> op.alter_column(table_name='sla_miss', column_name='execution_date', 
>     type_=mysql.TIMESTAMP(fsp=6))
> ...
> op.alter_column(table_name='task_instance', column_name='execution_date', 
>     type_=mysql.TIMESTAMP(fsp=6))
> {code}
> **Resolution**
> Add {{nullable=False}} to these migration entries.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)