AlekseiSaff opened a new issue, #23443:
URL: https://github.com/apache/airflow/issues/23443
### Apache Airflow version
2.2.5
### What happened
On "airflow db upgrade" I'm getting next error.
[2022-05-03 19:05:47,066] {db.py:1410} INFO - Creating tables
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade 587bdf053233 ->
5e3ec427fdd3, Increase length of email and username in ``ab_user`` and
``ab_register_user`` table to ``256`` characters
INFO [alembic.runtime.migration] Running upgrade 5e3ec427fdd3 ->
786e3737b18f, Add ``timetable_description`` column to DagModel for UI.
INFO [alembic.runtime.migration] Running upgrade 786e3737b18f ->
f9da662e7089, Add ``LogTemplate`` table to track changes to config values
``log_filename_template``
INFO [alembic.runtime.migration] Running upgrade f9da662e7089 ->
e655c0453f75, Add ``map_index`` column to TaskInstance to identify task-mapping,
and a ``task_map`` table to track mapping values from XCom.
/home/lt/.local/lib/python3.9/site-packages/airflow/configuration.py:474
DeprecationWarning: The sql_alchemy_conn option in [core] has been moved to the
sql_alchemy_conn option in [database] - the old setting has been used, but
please update your config.
Traceback (most recent call last):
File
"/home/lt/.local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line
1705, in _execute_context
self.dialect.do_execute(
File
"/home/lt/.local/lib/python3.9/site-packages/sqlalchemy/engine/default.py",
line 716, in do_execute
cursor.execute(statement, parameters)
File "/home/lt/.local/lib/python3.9/site-packages/MySQLdb/cursors.py",
line 206, in execute
res = self._query(query)
File "/home/lt/.local/lib/python3.9/site-packages/MySQLdb/cursors.py",
line 319, in _query
db.query(q)
File "/home/lt/.local/lib/python3.9/site-packages/MySQLdb/connections.py",
line 254, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1005, 'Can\'t create table
`airflow`.`task_map` (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 "/home/lt/.local/lib/python3.9/site-packages/airflow/__main__.py",
line 38, in main
args.func(args)
File
"/home/lt/.local/lib/python3.9/site-packages/airflow/cli/cli_parser.py", line
51, in command
return func(*args, **kwargs)
File "/home/lt/.local/lib/python3.9/site-packages/airflow/utils/cli.py",
line 99, in wrapper
return f(*args, **kwargs)
File
"/home/lt/.local/lib/python3.9/site-packages/airflow/cli/commands/db_command.py",
line 82, in upgradedb
db.upgradedb(to_revision=to_revision, from_revision=from_revision,
show_sql_only=args.show_sql_only)
File
"/home/lt/.local/lib/python3.9/site-packages/airflow/utils/session.py", line
71, in wrapper
return func(*args, session=session, **kwargs)
File "/home/lt/.local/lib/python3.9/site-packages/airflow/utils/db.py",
line 1411, in upgradedb
command.upgrade(config, revision=to_revision or 'heads')
File "/home/lt/.local/lib/python3.9/site-packages/alembic/command.py",
line 320, in upgrade
script.run_env()
File "/home/lt/.local/lib/python3.9/site-packages/alembic/script/base.py",
line 563, in run_env
util.load_python_file(self.dir, "env.py")
File
"/home/lt/.local/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 92,
in load_python_file
module = load_module_py(module_id, path)
File
"/home/lt/.local/lib/python3.9/site-packages/alembic/util/pyfiles.py", line
108, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in
_call_with_frames_removed
File
"/home/lt/.local/lib/python3.9/site-packages/airflow/migrations/env.py", line
107, in <module>
run_migrations_online()
File
"/home/lt/.local/lib/python3.9/site-packages/airflow/migrations/env.py", line
101, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File
"/home/lt/.local/lib/python3.9/site-packages/alembic/runtime/environment.py",
line 851, in run_migrations
self.get_context().run_migrations(**kw)
File
"/home/lt/.local/lib/python3.9/site-packages/alembic/runtime/migration.py",
line 620, in run_migrations
step.migration_fn(**kw)
File
"/home/lt/.local/lib/python3.9/site-packages/airflow/migrations/versions/0100_e655c0453f75_add_taskmap_and_map_id_on_taskinstance.py",
line 75, in upgrade
op.create_table(
File "<string>", line 8, in create_table
File "<string>", line 3, in create_table
File
"/home/lt/.local/lib/python3.9/site-packages/alembic/operations/ops.py", line
1254, in create_table
return operations.invoke(op)
File
"/home/lt/.local/lib/python3.9/site-packages/alembic/operations/base.py", line
392, in invoke
return fn(self, operation)
File
"/home/lt/.local/lib/python3.9/site-packages/alembic/operations/toimpl.py",
line 114, in create_table
operations.impl.create_table(table)
File "/home/lt/.local/lib/python3.9/site-packages/alembic/ddl/impl.py",
line 352, in create_table
self._exec(schema.CreateTable(table))
File "/home/lt/.local/lib/python3.9/site-packages/alembic/ddl/impl.py",
line 193, in _exec
return conn.execute(construct, multiparams)
File
"/home/lt/.local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line
1200, in execute
return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
File "/home/lt/.local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py",
line 77, in _execute_on_connection
return connection._execute_ddl(
File
"/home/lt/.local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line
1290, in _execute_ddl
ret = self._execute_context(
File
"/home/lt/.local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line
1748, in _execute_context
self._handle_dbapi_exception(
File
"/home/lt/.local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line
1929, in _handle_dbapi_exception
util.raise_(
File
"/home/lt/.local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line
211, in raise_
raise exception
File
"/home/lt/.local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line
1705, in _execute_context
self.dialect.do_execute(
File
"/home/lt/.local/lib/python3.9/site-packages/sqlalchemy/engine/default.py",
line 716, in do_execute
cursor.execute(statement, parameters)
File "/home/lt/.local/lib/python3.9/site-packages/MySQLdb/cursors.py",
line 206, in execute
res = self._query(query)
File "/home/lt/.local/lib/python3.9/site-packages/MySQLdb/cursors.py",
line 319, in _query
db.query(q)
File "/home/lt/.local/lib/python3.9/site-packages/MySQLdb/connections.py",
line 254, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError)
(1005, 'Can\'t create table `airflow`.`task_map` (errno: 150 "Foreign key
constraint is incorrectly formed")')
[SQL:
CREATE TABLE task_map (
dag_id VARCHAR(250) COLLATE utf8mb3_bin NOT NULL,
task_id VARCHAR(250) COLLATE utf8mb3_bin NOT NULL,
run_id VARCHAR(250) COLLATE utf8mb3_bin NOT NULL,
map_index INTEGER NOT NULL,
length INTEGER NOT NULL,
`keys` JSON,
PRIMARY KEY (dag_id, task_id, run_id, map_index),
CONSTRAINT task_map_length_not_negative CHECK (length >= 0),
CONSTRAINT task_map_task_instance_fkey FOREIGN KEY(dag_id, task_id,
run_id, map_index) REFERENCES task_instance (dag_id, task_id, run_id,
map_index) ON DELETE CASCADE
)
]
(Background on this error at: http://sqlalche.me/e/14/e3q8)
### What you think should happen instead
Upgrade process should finish without errors
### How to reproduce
install 2.3.0 packages on top of 2.2.5 and run airflow db upgrade
### Operating System
CentOS 7.9
### Versions of Apache Airflow Providers
_No response_
### Deployment
Other
### Deployment details
_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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]