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
superset db upgrade returns foreign key constraint is incorrectly formed #8808
Comments
Issue-Label Bot is automatically applying the label Links: app homepage, dashboard and code for this bot. |
it's because of this foreign key om the
The |
I'm confused that this is running ok in CI at every build, but fails in your environment. What your MySQL version? |
MariaDB 10.4.10 |
Just tested with a mariadb 10.4.10 and |
According to this link https://mariadb.org/mariadb-innodb-foreign-key-constraint-errors/, this error related to the issue that foreign key is not unique. and changing the |
Agree, but |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue |
I am facing the same issue. Looks like different charsets of the two tables is the cause. |
I am currently testing 0.36.0rc3 and I am facing the same issue, running Mariadb 10.1.36 (upgrading from 0.35.2). |
@elukey I solved this issue with upgrading the MariaDB version |
I "solved" this issue following @ayushbilala's suggestion, namely appending Edit: sqlalchemy fails to upgrade because the table is already there, so this part is still open. |
@elukey I'm curious to understand the origin of this problem. Have you changed charset and/or collation at some point, or do you think it's caused by changes in Superset? |
@villebro thanks for following up. Not that I know, but I may not have specified the correct defaults when creating the db schema for superset. Are there any? The fact that @blcksrx reported to have fixed it upgrading Mariadb makes me think that it is not superset, but possibly sqlalchemy triggering different behaviors when creating tables etc.. on different dbms? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue |
I'm having same issue while updating from 0.35.2 to 0.36.0. My mysql version is 5.7. Changing charset to utf8md4 didn't helped. Edit: I realized table charset and db charsets are not same. Making them same fixed my issue. |
Same issue here with mariadb 10.3 on Debian. In fact, sql creation code seems wrong, data type mismatch. client_id column is declared as string in query table (models/sql_lab.py line 54) : But the foreign key in tab_state in declared as an integer (models/sql_lab.py line 235) : Just modifying FK declaration with proper type make sql creation works. It seems that not all mysql / mariadb seems to behave the same way with this. |
@digitalfox All db models and query built on top of the sqlalchemy and barly can say it's a bug. Here some advice:
|
Data types mismatch, so it's not really an sqlalchemy issue in fact. One way to fix this is to change in (models/sql_lab.py. The ID field is an integer and a PK. |
Did this, now it shows |
facing this issue on percona 5.6 when upgraded from 0.21 to 1.01 |
|
* Update manila from branch 'master' to 0629aed5088877ba94af4fc331bd97cc73560fec - Merge "Fix py311 unit test issues" - Fix py311 unit test issues - Dell EMC driver had an issue with mocking an object and sending it forward. - Some of the create table statements in the database migrations didn't have the charset specified. That seemed to trick the DB engine while defining foreign keys and adding a name to them, as the default charset was defined in the schema, but not in the tables. This behavior was also noted in different places, like [1]. Fix this issue by adding the charset to all create table statements, so they match the engine default charset. [1] apache/superset#8808 Change-Id: I7cd6fa0cc8e054af112493746e753fef2024000f
- Dell EMC driver had an issue with mocking an object and sending it forward. - Some of the create table statements in the database migrations didn't have the charset specified. That seemed to trick the DB engine while defining foreign keys and adding a name to them, as the default charset was defined in the schema, but not in the tables. This behavior was also noted in different places, like [1]. Fix this issue by adding the charset to all create table statements, so they match the engine default charset. [1] apache/superset#8808 Change-Id: I7cd6fa0cc8e054af112493746e753fef2024000f
- Dell EMC driver had an issue with mocking an object and sending it forward. - Some of the create table statements in the database migrations didn't have the charset specified. That seemed to trick the DB engine while defining foreign keys and adding a name to them, as the default charset was defined in the schema, but not in the tables. This behavior was also noted in different places, like [1]. Fix this issue by adding the charset to all create table statements, so they match the engine default charset. [1] apache/superset#8808 Change-Id: I7cd6fa0cc8e054af112493746e753fef2024000f (cherry picked from commit b44c36e)
superset db upgrade returns foreign key constraint is incorrectly formed. here is the log:
Expected results
what you expected to happen.
Actual results
what actually happens.
Screenshots
If applicable, add screenshots to help explain your problem.
How to reproduce the bug
Environment
(please complete the following information):
superset version
python --version
node -v
npm -v
Checklist
Make sure these boxes are checked before submitting your issue - thank you!
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: