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

v18 backport: Online DDL: avoid SQL's CONVERT(...), convert programmatically if needed #16604

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

shlomi-noach
Copy link
Contributor

@shlomi-noach shlomi-noach commented Aug 15, 2024

Manual backport of #16597 to release-18.0

(bot is not working)

Description

Fixes #16023

We have a clear picture and a fix to #16023. The original reason why we needed convert() in the first place is that vreplication and vstreamer both issue a SET NAMES binary. We will want to change that in the future, but this PR in the meantime confirms to the binary connection charset.

So we used convert() to turn textual values into utf8mb4. On the other side, vplayer is reading events from the binary log. It used programmatic conversion (charset.Convert()) of the data to utf8mb4 to align with vcopier.

What we are doing now:

  • We do not use convert(), solving the sorting issue described in Bug Report: OnlineDDL PK conversion results in table scans #16023 (comment)
  • For vcopier read data, We do introduce programmatic conversion of non-utf columns into their designated charsets.
  • For vplayer, we do not convert at all if both source and target have same charset
  • For vplayer, we do apply programmatic conversion of non-utf columns into their designated charsets, in a similar logic as for vcopier.
  • If there's a charset.Convert() error, we translate it into ERROR 1366 ("Incorrect string value ..."), which is a terminal error in vreplication, and so the migration bails out as soon as that happens. This can happen if e.g. we're converting a UTF column into ASCII and the UTF column contains a smiley emoji.

Because we do not convert the original charset to utf8mb4, we get to programmatically convert it to the specific target column. Previously (and this is perhaps the last piece of magic I have not digged into yet, and again likely to be caused by the binary charset) we did not need to convert into the target charset.

All the tests remain the same, and we introduce a couple new ones.

Related Issue(s)

Backport

I wish to backport this to all supported versions, seeing that this is a bugfix: without this fix some migrations will slow down to a near halt.

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

Signed-off-by: Shlomi Noach <[email protected]>
@shlomi-noach shlomi-noach added Type: Bug Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: VReplication Backport This is a backport Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) labels Aug 15, 2024
@shlomi-noach shlomi-noach requested a review from a team August 15, 2024 13:41
Copy link
Contributor

vitess-bot bot commented Aug 15, 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.

@github-actions github-actions bot added this to the v18.0.7 milestone Aug 15, 2024
@shlomi-noach shlomi-noach changed the title v19 backport: Online DDL: avoid SQL's CONVERT(...), convert programmatically if needed v18 backport: Online DDL: avoid SQL's CONVERT(...), convert programmatically if needed Aug 15, 2024
@shlomi-noach shlomi-noach merged commit 051a978 into release-18.0 Aug 15, 2024
212 checks passed
@shlomi-noach shlomi-noach deleted the manual-backport-16597-to-release-18.0 branch August 15, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport This is a backport Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) Component: VReplication Type: Bug Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants