v20 backport: Online DDL: avoid SQL's CONVERT(...)
, convert programmatically if needed
#16602
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Manual backport of #16597 to release-20.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 thatvreplication
andvstreamer
both issue aSET NAMES binary
. We will want to change that in the future, but this PR in the meantime confirms to thebinary
connection charset.So we used
convert()
to turn textual values intoutf8mb4
. On the other side,vplayer
is reading events from the binary log. It used programmatic conversion (charset.Convert()
) of the data toutf8mb4
to align withvcopier
.What we are doing now:
convert()
, solving the sorting issue described in Bug Report: OnlineDDL PK conversion results in table scans #16023 (comment)vcopier
read data, We do introduce programmatic conversion of non-utf columns into their designated charsets.vplayer
, we do not convert at all if both source and target have same charsetvplayer
, we do apply programmatic conversion of non-utf columns into their designated charsets, in a similar logic as forvcopier
.charset.Convert()
error, we translate it intoERROR 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 thebinary
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
Deployment Notes