-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
airflow db upgrade failed, no generic 'DROP CONSTRAINT' in MySQL #13222
Comments
Which Database/Version do you have ? Is it MariaDB (and which version?). You only mentioned the client version in your report. Note that Airflow 2.0 has a bit higher requirements than Airflow 1.10 when it comes to the DB. MariaDB is not supported, neither MySQL 5.6 (5.7 is supported with some limitations, only MySQL 5.8 version is fully supported). If you are using non-supported version of DB you will have to upgrade/migrate to supported DB before attempting to upgrade to 2.0. See the requirements here: https://github.com/apache/airflow#requirements |
@potiuk , wow sorry, I missed specify that. innodb_version: So, I could upgrade to 2.0 ? |
I believe you should be able to, yes. Which version of Airflow you migrated from ? You know that you should first migrate to 1.10.14 first and only then migrate to 2.0 ? Not sure if that solves the problem, but It would be great to know if that solves the problem? https://airflow.apache.org/docs/apache-airflow/stable/upgrading-to-2.html |
@potiuk sure, I want to migrate from I've already read this documentation and that's why I've migrated to Furthermore, the So, upgrading to airflow 2 still broken .. 😕 |
Actually looks like Percona implements their own MySQL replacement (https://www.percona.com/doc/percona-server/5.7/index.html) , so this might be non fully-compatible MySQL engine.. Can you please escalate to them (CC: this ticket and comment) and see whether they can confirm it? It looks like MySQL client that you use might simply not recognize the constraint type that is being dropped. So this might be both - problem with the version of your client libraries or with the Percona SQL Server not able to provide the constraint type to the client. Below is the relevant code within Alembic that is responsible for the error. It looks like the foreign key constraint read from the schema ('known_event_user_id_fkey') is not properly recognized as one of the known constraint types (should be recognized as schema.ForeignKeyConstraint). It might also be a problem with some old MySQL client libraries you are using in your Airflow installation. Seems there is a similar problem reported by someone which was gone after upgrading the client libraries: https://www.reddit.com/r/flask/comments/2puang/error_using_sqlalchemy_alembic_and_flaskmigrate/ Here is the code that raises the problem:
|
I am closing that as 'invalid' for now, but please comment if you find that none of the provided directions work (or if you find that it worked, please post here confirming what worked). |
@potiuk Thank you for your explanations but I don't think so. Why: Existing airflow migration rules specify But, this migration rule Additionally, you can find a mention into the It may be fixed by adding Any opinion about this ? |
Nice find - can you try it out please if it works ? |
@potiuk so it's a bug ^^ ? It's fixed but I've changed another stuff. The constraint name So, if the goal of this migration rule is to drop all foreign keys referred to def upgrade(): # noqa: D103
# We previously had a KnownEvent's table, but we deleted the table without
# a down migration to remove it (so we didn't delete anyone's data if they
# were happing to use the feature.
#
# But before we can delete the users table we need to drop the FK
conn = op.get_bind()
inspector = Inspector.from_engine(conn)
tables = inspector.get_table_names()
if 'known_event' in tables:
for fkey in inspector.get_foreign_keys(table_name="known_event", referred_table="users"):
op.drop_constraint(
fkey['name'], 'known_event', type_="foreignkey"
)
if "chart" in tables:
op.drop_table(
"chart",
)
if "users" in tables:
op.drop_table("users") With these modifications, next migration rules are applied without any regression bugs. So, I can successfully upgrade to airflow 2. |
@potiuk I can create a PR for that if you approve these changes. |
Happy to do so ! |
@potiuk 👋 done. |
Nice! Thanks! Fixed by #13239 |
Apache Airflow version:
2.0.0
Kubernetes version (if you are using kubernetes) (use
kubectl version
): N/AEnvironment: docker swarm
Ubuntu 18.04.5 LTS (Bionic Beaver)
uname -a
):mysql-client=5.7
What happened:
When I try to upgrade airflow db with this following command:
Something wrong happened :
What you expected to happen:
database successfully upgraded (migration rules applied without errors)
How to reproduce it:
Upgrade existing database with mysql dialect from
1.10.14
to2.0.0
Anything else we need to know:
every times
The text was updated successfully, but these errors were encountered: