AlekseiSaff opened a new issue #19559:
URL: https://github.com/apache/airflow/issues/19559


   ### Apache Airflow version
   
   2.1.4
   
   ### Operating System
   
   CentOS 7.9
   
   ### Versions of Apache Airflow Providers
   
   during aurflow db upgrade receiving an error
   
   > INFO  [alembic.runtime.migration] Running upgrade ccde3e26fe78 -> 
83f031fd9f1c, improve mssql compatibility
   INFO  [alembic.runtime.migration] Running upgrade 83f031fd9f1c -> 
e9304a3141f0, make xcom pkey columns non-nullable
   INFO  [alembic.runtime.migration] Running upgrade e9304a3141f0 -> 
30867afad44a, Rename concurrency column in dag table to max_active_tasks
   INFO  [alembic.runtime.migration] Running upgrade 30867afad44a -> 
54bebd308c5f, Add trigger table and task info
   INFO  [alembic.runtime.migration] Running upgrade 54bebd308c5f -> 
142555e44c17, Add data_interval_[start|end] to DagModel and DagRun.
   INFO  [alembic.runtime.migration] Running upgrade 142555e44c17 -> 
7b2661a43ba3, TaskInstance keyed to DagRun
   /usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/default.py:608 
Warning: (1280, "Name 'task_instance_pkey' ignored for PRIMARY key.")
   Traceback (most recent call last):
     File "/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/base.py", 
line 1277, in _execute_context
       cursor, statement, parameters, context
     File 
"/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/default.py", line 
608, in do_execute
       cursor.execute(statement, parameters)
     File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 
255, in execute
       self.errorhandler(self, exc, value)
     File "/usr/local/lib64/python3.6/site-packages/MySQLdb/connections.py", 
line 50, in defaulterrorhandler
       raise errorvalue
     File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 
252, in execute
       res = self._query(query)
     File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 
378, in _query
       db.query(q)
     File "/usr/local/lib64/python3.6/site-packages/MySQLdb/connections.py", 
line 280, in query
       _mysql.connection.query(self, query)
   _mysql_exceptions.OperationalError: (1005, 'Can\'t create table 
`airflow`.`task_reschedule` (errno: 150 "Foreign key constraint is incorrectly 
formed")')
   
   The above exception was the direct cause of the following exception:
   
   Traceback (most recent call last):
     File "/usr/local/bin/airflow", line 8, in <module>
       sys.exit(main())
     File "/usr/local/lib/python3.6/site-packages/airflow/__main__.py", line 
48, in main
       args.func(args)
     File "/usr/local/lib/python3.6/site-packages/airflow/cli/cli_parser.py", 
line 48, in command
       return func(*args, **kwargs)
     File "/usr/local/lib/python3.6/site-packages/airflow/utils/cli.py", line 
92, in wrapper
       return f(*args, **kwargs)
     File 
"/usr/local/lib/python3.6/site-packages/airflow/cli/commands/db_command.py", 
line 48, in upgradedb
       db.upgradedb()
     File "/usr/local/lib/python3.6/site-packages/airflow/utils/session.py", 
line 70, in wrapper
       return func(*args, session=session, **kwargs)
     File "/usr/local/lib/python3.6/site-packages/airflow/utils/db.py", line 
868, in upgradedb
       command.upgrade(config, 'heads')
     File "/usr/local/lib/python3.6/site-packages/alembic/command.py", line 
298, in upgrade
       script.run_env()
     File "/usr/local/lib/python3.6/site-packages/alembic/script/base.py", line 
489, in run_env
       util.load_python_file(self.dir, "env.py")
     File "/usr/local/lib/python3.6/site-packages/alembic/util/pyfiles.py", 
line 98, in load_python_file
       module = load_module_py(module_id, path)
     File "/usr/local/lib/python3.6/site-packages/alembic/util/compat.py", line 
184, in load_module_py
       spec.loader.exec_module(module)
     File "<frozen importlib._bootstrap_external>", line 678, in exec_module
     File "<frozen importlib._bootstrap>", line 219, in 
_call_with_frames_removed
     File "/usr/local/lib/python3.6/site-packages/airflow/migrations/env.py", 
line 107, in <module>
       run_migrations_online()
     File "/usr/local/lib/python3.6/site-packages/airflow/migrations/env.py", 
line 101, in run_migrations_online
       context.run_migrations()
     File "<string>", line 8, in run_migrations
     File 
"/usr/local/lib/python3.6/site-packages/alembic/runtime/environment.py", line 
846, in run_migrations
       self.get_context().run_migrations(**kw)
     File 
"/usr/local/lib/python3.6/site-packages/alembic/runtime/migration.py", line 
520, in run_migrations
       step.migration_fn(**kw)
     File 
"/usr/local/lib/python3.6/site-packages/airflow/migrations/versions/7b2661a43ba3_taskinstance_keyed_to_dagrun.py",
 line 321, in upgrade
       ondelete=ondelete,
     File "/usr/lib64/python3.6/contextlib.py", line 88, in __exit__
       next(self.gen)
     File "/usr/local/lib/python3.6/site-packages/alembic/operations/base.py", 
line 354, in batch_alter_table
       impl.flush()
     File "/usr/local/lib/python3.6/site-packages/alembic/operations/batch.py", 
line 83, in flush
       fn(*arg, **kw)
     File "/usr/local/lib/python3.6/site-packages/alembic/ddl/impl.py", line 
244, in add_constraint
       self._exec(schema.AddConstraint(const))
     File "/usr/local/lib/python3.6/site-packages/alembic/ddl/impl.py", line 
140, in _exec
       return conn.execute(construct, *multiparams, **params)
     File "/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/base.py", 
line 1011, in execute
       return meth(self, multiparams, params)
     File "/usr/local/lib64/python3.6/site-packages/sqlalchemy/sql/ddl.py", 
line 72, in _execute_on_connection
       return connection._execute_ddl(self, multiparams, params)
     File "/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/base.py", 
line 1073, in _execute_ddl
       compiled,
     File "/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/base.py", 
line 1317, in _execute_context
       e, statement, parameters, cursor, context
     File "/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/base.py", 
line 1511, in _handle_dbapi_exception
       sqlalchemy_exception, with_traceback=exc_info[2], from_=e
     File "/usr/local/lib64/python3.6/site-packages/sqlalchemy/util/compat.py", 
line 182, in raise_
       raise exception
     File "/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/base.py", 
line 1277, in _execute_context
       cursor, statement, parameters, context
     File 
"/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/default.py", line 
608, in do_execute
       cursor.execute(statement, parameters)
     File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 
255, in execute
       self.errorhandler(self, exc, value)
     File "/usr/local/lib64/python3.6/site-packages/MySQLdb/connections.py", 
line 50, in defaulterrorhandler
       raise errorvalue
     File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 
252, in execute
       res = self._query(query)
     File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 
378, in _query
       db.query(q)
     File "/usr/local/lib64/python3.6/site-packages/MySQLdb/connections.py", 
line 280, in query
       _mysql.connection.query(self, query)
   sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1005, 
'Can\'t create table `airflow`.`task_reschedule` (errno: 150 "Foreign key 
constraint is incorrectly formed")')
   [SQL: ALTER TABLE task_reschedule ADD CONSTRAINT task_reschedule_ti_fkey 
FOREIGN KEY(dag_id, task_id, run_id) REFERENCES task_instance (dag_id, task_id, 
run_id) ON DELETE CASCADE]
   (Background on this error at: http://sqlalche.me/e/13/e3q8)
   [lt@lt-hkg1-avm04 experiments]$ 
   
   
   
   ### Deployment
   
   Other
   
   ### Deployment details
   
   _No response_
   
   ### What happened
   
   _No response_
   
   ### What you expected to happen
   
   succesfull upgrade to 2.2
   
   
   ### How to reproduce
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to