-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
Revert "Removing uniqueness constraints on tables table" #6777
Conversation
Hi John, Thanks for jumping on this and doing the revert. I am wondering if there is a way I can reproduce this ? Or maybe you can share the full log message ? The reason I am confused that this PR is to blame is that it only creates a constant named (and thus sized) constraint "uq_table_in_db_schema". So I am not sure why it would be causing this "long key" issue. Perhaps we can work around this by always recreating the table like we do for sqlite (like in https://github.com/apache/incubator-superset/pull/6777/files#diff-b4aec6518fae5ca2dcce669810ba5695L49). If I have the full log message or something, then I can understand this error and the cause of this revert better. |
@agrawaldevesh per the comment in my PR, by creating a uniqueness constraint on a tuple of columns the size of the constraint is defined by the combined size of the underlying columns (per here). Previous the constrain required: 4 ( |
Ah okay, So the right thing to do here is to really remove the unique constraints (and fix/ignore the resulting unit test failures by doing so). Also, is my understanding correct that in utf8mb3 in mysql, the character can take upto 3 bytes. So it shouldn't be above the 768 bytes limit all the time ? Perhaps only in certain cases ... do you have no ascii named tables ? Thanks |
@agrawaldevesh I think the right thing is to revert the PR and then remedy the issue regarding the column sizes. I'm not supportive of removing the uniqueness constraint as this can be problematic to fix in the future. Currently there are a number of instances in our deployment of duplicate entities due to missing/ill-defined uniqueness constraints. Unique indexes must have a known maximum length (a requirement of MySQL due to its internal implementation), i.e., the size constraint is irrelevant of what's currently stored in the database. |
@john-bodley , thanks for explaining !. So I think the best course of action according to you is to revert my PR and then get #5449 (the one that reduces the column size for table name) and the #5445 (wtf-forms one) in ? |
I support the revert, LGTM, let's start over clean. |
Btw, I am not sure if this issue seen by John is setup dependant or not. We use MySql too and it didn't fail for us. So I don't think my PR always makes MySQL fail (there are unit tests for that too !). Perhaps it only fails when the sizes of the actual table/schema/database names exceed a threshold. Here are some details about my mysql environment: XXX@XXX superset> SHOW VARIABLES LIKE "%version%"; XXX@XXX superset> show create table tables; |
@john-bodley, can you comment on whether this is indeed something in your environment vs indeed something that was broken by this diff. I am not sure because I am not understanding why it works with MySql in my production environment but not in yours. Thanks. |
Reverting #6718 as the resulting uniqueness is too long in MySQL, i.e.,
Per #5449 the column sizes need to be reduced in order to prevent the issue, however there are open concerns able reducing the size of the table name.
Note the title for #6718 is a little misleading as the uniqueness constraint wasn't removed but augmented.
to: @agrawaldevesh @michellethomas @mistercrunch