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

VStream: Skip vindex keyrange filtering when we can #14384

Merged
merged 7 commits into from
Oct 30, 2023

Conversation

mattlord
Copy link
Contributor

@mattlord mattlord commented Oct 28, 2023

Description

We were always adding in_keyrange filters for a vstream when the target keyspace was sharded. This PR adds a check to see if the shard mappings are 1:1 and the key ranges are equal for both shards — if so then we do not add the in_keyrange filter.

When that filter is in place, every row/binlog event on the VReplication stream source must have its KeyspaceID calculated before adding it to the vstream for the target. This same filter from the VReplication record is also used when a VDiff is performed for the workflow. In the case of VDiff, this means that each source tablet needs to calculate the KeyspaceID for every record read from its mysqld before adding it to the vstream used for the diff.

This additional vindex work can be costly — in particular during the VDiff where you are reading every row from each table that you're diffing in quick succession — and especially so for more complex vindex types such as unicode_loose_md5, so skipping that work whenever possible is a good optimization.

That is what this PR does.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on the CI
  • Documentation was added or is not required

@vitess-bot
Copy link
Contributor

vitess-bot bot commented Oct 28, 2023

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 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 Oct 28, 2023
@github-actions github-actions bot added this to the v19.0.0 milestone Oct 28, 2023
@mattlord mattlord added Component: VReplication Type: Enhancement Logical improvement (somewhere between a bug and feature) labels Oct 28, 2023
@mattlord mattlord force-pushed the vstream_keyrange_optimization branch 6 times, most recently from 2c45ace to 4077675 Compare October 29, 2023 00:55
@mattlord mattlord force-pushed the vstream_keyrange_optimization branch 5 times, most recently from c959721 to 6effef3 Compare October 29, 2023 18:37
@mattlord mattlord removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request labels Oct 29, 2023
@mattlord mattlord marked this pull request as ready for review October 29, 2023 18:55
@mattlord mattlord force-pushed the vstream_keyrange_optimization branch from 6effef3 to 8d19288 Compare October 29, 2023 19:03
Copy link
Contributor

@dbussink dbussink left a comment

Choose a reason for hiding this comment

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

This is a very useful optimization and we'll also look at optimizing this when we do need to call this as well.

@mattlord mattlord merged commit 208042b into vitessio:main Oct 30, 2023
115 checks passed
@mattlord mattlord deleted the vstream_keyrange_optimization branch October 30, 2023 13:36
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
Status: Done
Development

Successfully merging this pull request may close these issues.

Feature Request: Optimize in_keyrange filtering for VReplication workflows
3 participants