dryshliak opened a new issue, #23959:
URL: https://github.com/apache/airflow/issues/23959
### Apache Airflow version
2.3.1 (latest released)
### What happened
On "airflow db upgrade" I'm getting next error.
and a ``task_map`` table to track mapping values from XCom.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/sqlalchemy/engine/base.py",
line 1705, in _execute_context
self.dialect.do_execute(
File
"/usr/local/lib/python3.9/dist-packages/sqlalchemy/engine/default.py", line
716, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.9/dist-packages/MySQLdb/cursors.py", line
206, in execute
res = self._query(query)
File "/usr/local/lib/python3.9/dist-packages/MySQLdb/cursors.py", line
319, in _query
db.query(q)
File "/usr/local/lib/python3.9/dist-packages/MySQLdb/connections.py", line
254, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (3780, "Referencing column 'task_id'
and referenced column 'task_id' in foreign key constraint
'task_map_task_instance_fkey' are incompatible.")
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.9/dist-packages/airflow/__main__.py", line
38, in main
args.func(args)
File "/usr/local/lib/python3.9/dist-packages/airflow/cli/cli_parser.py",
line 51, in command
return func(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/airflow/utils/cli.py", line
99, in wrapper
return f(*args, **kwargs)
File
"/usr/local/lib/python3.9/dist-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 "/usr/local/lib/python3.9/dist-packages/airflow/utils/session.py",
line 71, in wrapper
return func(*args, session=session, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/airflow/utils/db.py", line
1446, in upgradedb
command.upgrade(config, revision=to_revision or 'heads')
File "/usr/local/lib/python3.9/dist-packages/alembic/command.py", line
320, in upgrade
script.run_env()
File "/usr/local/lib/python3.9/dist-packages/alembic/script/base.py", line
563, in run_env
util.load_python_file(self.dir, "env.py")
File "/usr/local/lib/python3.9/dist-packages/alembic/util/pyfiles.py",
line 92, in load_python_file
module = load_module_py(module_id, path)
File "/usr/local/lib/python3.9/dist-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 "/usr/local/lib/python3.9/dist-packages/airflow/migrations/env.py",
line 107, in <module>
run_migrations_online()
File "/usr/local/lib/python3.9/dist-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.9/dist-packages/alembic/runtime/environment.py", line
851, in run_migrations
self.get_context().run_migrations(**kw)
File
"/usr/local/lib/python3.9/dist-packages/alembic/runtime/migration.py", line
620, in run_migrations
step.migration_fn(**kw)
File
"/usr/local/lib/python3.9/dist-packages/airflow/migrations/versions/0100_2_3_0_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 "/usr/local/lib/python3.9/dist-packages/alembic/operations/ops.py",
line 1254, in create_table
return operations.invoke(op)
File "/usr/local/lib/python3.9/dist-packages/alembic/operations/base.py",
line 392, in invoke
return fn(self, operation)
File
"/usr/local/lib/python3.9/dist-packages/alembic/operations/toimpl.py", line
114, in create_table
operations.impl.create_table(table)
File "/usr/local/lib/python3.9/dist-packages/alembic/ddl/impl.py", line
352, in create_table
self._exec(schema.CreateTable(table))
File "/usr/local/lib/python3.9/dist-packages/alembic/ddl/impl.py", line
193, in _exec
return conn.execute(construct, multiparams)
File "/usr/local/lib/python3.9/dist-packages/sqlalchemy/engine/base.py",
line 1200, in execute
return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
File "/usr/local/lib/python3.9/dist-packages/sqlalchemy/sql/ddl.py", line
77, in _execute_on_connection
return connection._execute_ddl(
File "/usr/local/lib/python3.9/dist-packages/sqlalchemy/engine/base.py",
line 1290, in _execute_ddl
ret = self._execute_context(
File "/usr/local/lib/python3.9/dist-packages/sqlalchemy/engine/base.py",
line 1748, in _execute_context
self._handle_dbapi_exception(
File "/usr/local/lib/python3.9/dist-packages/sqlalchemy/engine/base.py",
line 1929, in _handle_dbapi_exception
util.raise_(
File "/usr/local/lib/python3.9/dist-packages/sqlalchemy/util/compat.py",
line 211, in raise_
raise exception
File "/usr/local/lib/python3.9/dist-packages/sqlalchemy/engine/base.py",
line 1705, in _execute_context
self.dialect.do_execute(
File
"/usr/local/lib/python3.9/dist-packages/sqlalchemy/engine/default.py", line
716, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.9/dist-packages/MySQLdb/cursors.py", line
206, in execute
res = self._query(query)
File "/usr/local/lib/python3.9/dist-packages/MySQLdb/cursors.py", line
319, in _query
db.query(q)
File "/usr/local/lib/python3.9/dist-packages/MySQLdb/connections.py", line
254, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError)
(3780, "Referencing column 'task_id' and referenced column 'task_id' in foreign
key constraint 'task_map_task_instance_fkey' are incompatible.")
[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
)
### What you think should happen instead
The upgrade process should finish without errors
### How to reproduce
Install the latest version of Python 3.9 on Ubuntu 20.04 lts
Install Airflow steps
`AIRFLOW_VERSION=2.3.1
PYTHON_VERSION="$(python3 --version | cut -d " " -f 2 | cut -d "." -f 1-2)"
CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-no-providers-${PYTHON_VERSION}.txt"
pip3 install "apache-airflow[celery,redis,mysql,amazon]==${AIRFLOW_VERSION}"
--constraint "${CONSTRAINT_URL}"
`
### Operating System
Ubuntu 20.04 lts
### 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]