Skip to content
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

Make Schema Tracking case-sensitive #14904

Merged

Conversation

GuptaManan100
Copy link
Member

@GuptaManan100 GuptaManan100 commented Jan 8, 2024

Description

This PR fixes the issue #14671. This fix only works with #14930, so we can't backport this without backporting that PR as well.

Since the planner and all the other components of Vitess treat table names as case-sensitive, so should schema-tracking. This PR makes this change. Surprisingly the only change that was required was in the schema of the internal tables that we create. The tables and views tables for the schema engine where using the varchar columns (with the default collation) to store the table names, causing MySQL to error out with a duplicate key error, when trying to store the information of 2 tables such that their names only differ in casing.
The columns in question have had their collations changed toutfmb3_bin, which is a case-sensitive collation resolving the issue.

Moreover, while I was working on the schema-tracker, I have added more tests, and cleaned up the artificats left from the old way of schema-tracking which can now be removed.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

…itive

Signed-off-by: Manan Gupta <manan@planetscale.com>
Copy link
Contributor

vitess-bot bot commented Jan 8, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Jan 8, 2024
@github-actions github-actions bot added this to the v19.0.0 milestone Jan 8, 2024
Signed-off-by: Manan Gupta <manan@planetscale.com>
@GuptaManan100 GuptaManan100 added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: Query Serving and removed NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Jan 8, 2024
…se sensitivity

Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
…sensitivity

Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
…required

Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
@GuptaManan100 GuptaManan100 marked this pull request as ready for review January 9, 2024 10:44
@GuptaManan100 GuptaManan100 removed the NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work label Jan 9, 2024
Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
@harshit-gangal
Copy link
Member

I think we should port it to v18 as well.

Signed-off-by: Manan Gupta <manan@planetscale.com>
@dbussink
Copy link
Contributor

dbussink commented Jan 9, 2024

I think we should port it to v18 as well.

Does this mean we need to separate out the cleanup from the fix here?

@GuptaManan100
Copy link
Member Author

Does this mean we need to separate out the cleanup from the fix here?

No, I'll just resolve the conflicts in the backports. I don't want to create a separate PR unnecessarily.

@frouioui
Copy link
Member

frouioui commented Jan 9, 2024

Nice catch and nice fix @GuptaManan100!

…b3 is deprecated

Signed-off-by: Manan Gupta <manan@planetscale.com>
@GuptaManan100 GuptaManan100 force-pushed the case-sensitive-schema-tracking branch from 9ef9fe9 to cbe4b17 Compare January 9, 2024 16:01
Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
…ma-tracking

Signed-off-by: Manan Gupta <manan@planetscale.com>
@GuptaManan100
Copy link
Member Author

This fix only works with #14930, so we can't backport this without backporting that PR as well.

Copy link

codecov bot commented Jan 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (eddb39e) 47.29% compared to head (9ca2956) 47.29%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14904      +/-   ##
==========================================
- Coverage   47.29%   47.29%   -0.01%     
==========================================
  Files        1137     1137              
  Lines      238684   238647      -37     
==========================================
- Hits       112895   112864      -31     
- Misses     117168   117169       +1     
+ Partials     8621     8614       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GuptaManan100 GuptaManan100 merged commit 4a67c0c into vitessio:main Jan 12, 2024
103 of 104 checks passed
@GuptaManan100 GuptaManan100 deleted the case-sensitive-schema-tracking branch January 12, 2024 07:19
@deepthi
Copy link
Member

deepthi commented Jan 12, 2024

Why did we choose utf8mb3 and utf8mb3_bin versus utf8mb4 and utf8mb4_bin? I ask because utf8mb3 has been deprecated.

You should also be aware that the utf8mb3 character set is deprecated and you should expect it to be removed in a future MySQL release. Please use utf8mb4 instead.

https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html

@dbussink
Copy link
Contributor

See my comment in #14904 (comment)

I deliberately suggested utf8mb3 since that still is used for internal system tables for MySQL, even though it’s deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Case-sensitive Schema Tracking
5 participants