Skip to content

Run VStream copy only when VGTID requires it, use TablesToCopy in those cases#18938

Merged
mattlord merged 1 commit intovitessio:mainfrom
twthorn:prevent_unnecessary_vstream_copy
Nov 23, 2025
Merged

Run VStream copy only when VGTID requires it, use TablesToCopy in those cases#18938
mattlord merged 1 commit intovitessio:mainfrom
twthorn:prevent_unnecessary_vstream_copy

Conversation

@twthorn
Copy link
Contributor

@twthorn twthorn commented Nov 22, 2025

Description

We are running vstream copy whenever this TablesToCopy flag is set. It should only be used if the VGTID would trigger the copy. Otherwise, there is a race condition (clients must unset their VStream config in time to avoid repeated copies). By only running copies when the VGTID requires it, we avoid repeated copies after the operation is complete (and will ignore this flag)

Note

This is a small logic bug in #18184 . That work should result in modifying the table plan built when we specify tables to copy, but it should not cause any new/additional copy phases (than before that PR). Since that was added in v23, we should backport this fix to v23.

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

AI Disclosure

…se cases

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
@vitess-bot
Copy link
Contributor

vitess-bot bot commented Nov 22, 2025

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 Nov 22, 2025
@github-actions github-actions bot added this to the v24.0.0 milestone Nov 22, 2025
@twthorn twthorn added Component: VReplication Type: Bug and 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 NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Nov 22, 2025
@codecov
Copy link

codecov bot commented Nov 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.78%. Comparing base (e1df3d1) to head (471f694).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18938      +/-   ##
==========================================
+ Coverage   69.77%   69.78%   +0.01%     
==========================================
  Files        1608     1608              
  Lines      214842   214865      +23     
==========================================
+ Hits       149899   149945      +46     
+ Misses      64943    64920      -23     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mattlord mattlord requested review from mattlord and removed request for harshit-gangal and systay November 23, 2025 19:49
@mattlord mattlord added the Backport to: release-23.0 Needs to be backport to release-23.0 label Nov 23, 2025
@mattlord
Copy link
Member

Thanks, @twthorn ! ❤️

Copy link
Member

@beingnoble03 beingnoble03 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for fixing this!

@mattlord mattlord merged commit 8230b8a into vitessio:main Nov 23, 2025
106 of 123 checks passed
vitess-bot pushed a commit that referenced this pull request Nov 23, 2025
…se cases (#18938)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
mattlord pushed a commit that referenced this pull request Nov 23, 2025
…esToCopy in those cases (#18938) (#18940)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
twthorn added a commit to slackhq/vitess that referenced this pull request Nov 25, 2025
…se cases (vitessio#18938)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
tanjinx pushed a commit to slackhq/vitess that referenced this pull request Dec 2, 2025
…se cases (vitessio#18938) (#755)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
siddharth16396 pushed a commit to siddharth16396/postpone-complete that referenced this pull request Dec 3, 2025
…se cases (vitessio#18938)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
Signed-off-by: siddharth16396 <siddharth16396@gmail.com>
twthorn added a commit to slackhq/vitess that referenced this pull request Jan 28, 2026
…se cases (vitessio#18938)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
twthorn added a commit to slackhq/vitess that referenced this pull request Jan 28, 2026
…se cases (vitessio#18938)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>
twthorn added a commit to slackhq/vitess that referenced this pull request Jan 29, 2026
…se cases (vitessio#18938)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>
tanjinx pushed a commit to slackhq/vitess that referenced this pull request Jan 30, 2026
* Improve cgroup metric management (vitessio#18791)

Signed-off-by: Matt Lord <mattalord@gmail.com>

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* VStream: Prevent buffering entire transactions (OOM risk), instead send chunks to client (vitessio#18849)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Run VStream copy only when VGTID requires it, use TablesToCopy in those cases (vitessio#18938)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Regenerate vtgate.pb.go proto file

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Fix tests

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Complete PR vitessio#18791 backport: Update metrics_cgroup.go

Apply missing changes from PR vitessio#18791 to metrics_cgroup.go:
- Replace cgroup1Manager and cgroup2Manager with single cgroupManager
- Add errCgroupMetricsNotAvailable error variable
- Add sync.Once for lazy initialization
- Remove cgroup v1 support, only support cgroup v2
- Simplify implementation with unified cgroup manager

This fixes compilation errors in metrics_cgroup_test.go.

* Add missing github.com/containerd/cgroups dependency

Required by metrics_cgroup.go for cgroup v1/v2 support.

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Fix cgroups import to use v3

The v1 cgroups package is incompatible with Go 1.24.10.
Use cgroups/v3 consistently throughout the file.

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Fix goimports formatting

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

---------

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>
sbaker617 pushed a commit to slackhq/vitess that referenced this pull request Feb 5, 2026
* Improve cgroup metric management (vitessio#18791)

Signed-off-by: Matt Lord <mattalord@gmail.com>

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* VStream: Prevent buffering entire transactions (OOM risk), instead send chunks to client (vitessio#18849)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Run VStream copy only when VGTID requires it, use TablesToCopy in those cases (vitessio#18938)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Regenerate vtgate.pb.go proto file

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Fix tests

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Complete PR vitessio#18791 backport: Update metrics_cgroup.go

Apply missing changes from PR vitessio#18791 to metrics_cgroup.go:
- Replace cgroup1Manager and cgroup2Manager with single cgroupManager
- Add errCgroupMetricsNotAvailable error variable
- Add sync.Once for lazy initialization
- Remove cgroup v1 support, only support cgroup v2
- Simplify implementation with unified cgroup manager

This fixes compilation errors in metrics_cgroup_test.go.

* Add missing github.com/containerd/cgroups dependency

Required by metrics_cgroup.go for cgroup v1/v2 support.

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Fix cgroups import to use v3

The v1 cgroups package is incompatible with Go 1.24.10.
Use cgroups/v3 consistently throughout the file.

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

* Fix goimports formatting

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>

---------

Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>
jwangace pushed a commit to jwangace/vitess that referenced this pull request Feb 5, 2026
…esToCopy in those cases (vitessio#18938) (vitessio#18940)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
jwangace pushed a commit to jwangace/vitess that referenced this pull request Feb 5, 2026
…esToCopy in those cases (vitessio#18938) (vitessio#18940)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Signed-off-by: Jun Wang <jun.wang@demonware.net>
jwangace pushed a commit to jwangace/vitess that referenced this pull request Feb 5, 2026
…esToCopy in those cases (vitessio#18938) (vitessio#18940)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Signed-off-by: Jun Wang <jun.wang@demonware.net>
jwangace pushed a commit to jwangace/vitess that referenced this pull request Feb 5, 2026
…esToCopy in those cases (vitessio#18938) (vitessio#18940)

Signed-off-by: twthorn <thomaswilliamthornton@gmail.com>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Signed-off-by: Jun Wang <jun.wang@demonware.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: TablesToCopy flag always triggers copies even with existing GTID

3 participants