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

VReplication: use proper column collations in vstreamer #15313

Merged
merged 12 commits into from
Feb 26, 2024

Conversation

mattlord
Copy link
Contributor

@mattlord mattlord commented Feb 21, 2024

Description

In order to address the problem described in #15338, this PR does the following:

  • Leverages optional metadata in row based binary log's TableMapEvents when present
  • Leverages the column collation information provided by the target mysqld instance when possible

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

Copy link
Contributor

vitess-bot bot commented Feb 21, 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 Feb 21, 2024
@github-actions github-actions bot added this to the v20.0.0 milestone Feb 21, 2024
go/vt/vttablet/tabletserver/vstreamer/testenv/testenv.go Outdated Show resolved Hide resolved
go/mysql/binlog_event.go Outdated Show resolved Hide resolved
@mattlord mattlord force-pushed the vstream_col_colls branch 2 times, most recently from 6d6e605 to 3aa6bbf Compare February 21, 2024 19:03
@mattlord mattlord removed NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsWebsiteDocsUpdate What it says labels Feb 21, 2024
Signed-off-by: Matt Lord <[email protected]>
@mattlord mattlord force-pushed the vstream_col_colls branch 2 times, most recently from bab31e3 to 6992ba1 Compare February 22, 2024 01:42
@mattlord mattlord added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: VReplication labels Feb 22, 2024
Signed-off-by: Matt Lord <[email protected]>
Copy link
Collaborator

@vmg vmg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct to me, although as I pointed out, storing only textual collations makes this needlessly complex.

// override for text based columns ONLY. This means that the
// array position needs to be mapped to the ordered list of
// text based columns in the table.
ColumnCollationIDs []collations.ID
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a lot of the code is going to be easier to write and easier to follow if this slice has one entry for each column and you simply fill the non-text columns with a Binary collation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soooo... I agree! But unfortunately I'd have to perform the same logic to fill in those gaps as the binlog row metadata does not include the column's index or name. I'll think about it some more though.

Copy link
Contributor Author

@mattlord mattlord Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I explored this path, but we don't have access to the collation ENV in order to properly fill in the gaps here. So leaving it as-is for now, where users of this (vstreamer) have access to both the collation ENV and mysqld.

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 82.89474% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 65.43%. Comparing base (696fe0e) to head (2a0ad87).
Report is 54 commits behind head on main.

Files Patch % Lines
go/mysql/binlog_event_rbr.go 70.96% 9 Missing ⚠️
...vttablet/tabletserver/vstreamer/testenv/testenv.go 80.95% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15313      +/-   ##
==========================================
- Coverage   67.41%   65.43%   -1.99%     
==========================================
  Files        1560     1561       +1     
  Lines      192752   193585     +833     
==========================================
- Hits       129952   126678    -3274     
- Misses      62800    66907    +4107     

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

@mattlord mattlord removed the NeedsIssue A linked issue is missing for this Pull Request label Feb 23, 2024
@mattlord mattlord changed the title VReplication: parse and use collations in binlog_row_metadata VReplication: use proper column collations in vstreamer Feb 23, 2024
@mattlord mattlord removed the NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work label Feb 23, 2024
@mattlord mattlord marked this pull request as ready for review February 23, 2024 03:07
@mattlord mattlord requested a review from dbussink February 23, 2024 03:08
pos = read

// Read any text based column collation values provided in the optional metadata.
//log.Errorf("DEBUG: Remaining optional metadata bytes for %s: %v", result.Name, data[pos:])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these DEBUG logging statements will be removed before merging.

Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work ❤️

@mattlord mattlord merged commit 8de1c91 into vitessio:main Feb 26, 2024
102 checks passed
@mattlord mattlord deleted the vstream_col_colls branch February 26, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: VReplication Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug Report: VStream does not handle column collations properly
4 participants