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

VDiff: Add control for start/resume and stop #16654

Merged
merged 25 commits into from
Sep 7, 2024

Conversation

mattlord
Copy link
Contributor

@mattlord mattlord commented Aug 27, 2024

Description

VDiffs can be pretty resource intensive and for larger clusters and tables, it can be very desirable to have greater control over how they are executed. This PR implements two feature requests that allow you to fully control when and where it's running — on a shard by shard basis.

Example usage in the PR branch:

cd examples/local
alias vtctldclient='command vtctldclient --server=localhost:15999'

./101_initial_cluster.sh; mysql < ../common/insert_commerce_data.sql; ./201_customer_tablets.sh; ./202_move_tables.sh; ./203_switch_reads.sh; ./204_switch_writes.sh; ./205_clean_commerce.sh; ./301_customer_sharded.sh; ./302_new_shards.sh; ./303_reshard.sh; ./304_switch_reads.sh; ./305_switch_writes.sh; ./306_down_shard_0.sh; ./307_delete_shard_0.sh

vtctldclient ApplyVSchema --vschema-file /tmp/customer.json customer

vtctldclient MoveTables --workflow commerce2customer --target-keyspace customer create --source-keyspace commerce --tables "product"

❯ vtctldclient --server localhost:15999 vdiff --workflow commerce2customer --target-keyspace customer create --auto-start=false
VDiff 280206aa-72ef-4073-aee8-76b219d55c08 scheduled on target shards, use show to view progress

❯ vtctldclient vdiff --workflow commerce2customer --target-keyspace customer show ca5cb9fe-900a-43ec-b5be-e80a67fa8ec3 --verbose --format json
{
  "Workflow": "commerce2customer",
  "Keyspace": "customer",
  "State": "stopped",
  "UUID": "ca5cb9fe-900a-43ec-b5be-e80a67fa8ec3",
  "RowsCompared": 0,
  "HasMismatch": false,
  "Shards": "-80,80-"
}

❯ vtctldclient vdiff --workflow commerce2customer --target-keyspace customer resume ca5cb9fe-900a-43ec-b5be-e80a67fa8ec3 --target-shards "80-"
VDiff resume scheduled

❯ vtctldclient vdiff --workflow commerce2customer --target-keyspace customer show ca5cb9fe-900a-43ec-b5be-e80a67fa8ec3 --verbose --format json
{
  "Workflow": "commerce2customer",
  "Keyspace": "customer",
  "State": "stopped",
  "UUID": "ca5cb9fe-900a-43ec-b5be-e80a67fa8ec3",
  "RowsCompared": 2,
  "HasMismatch": false,
  "Shards": "-80,80-",
  "StartedAt": "2024-08-29 18:28:37",
  "TableSummary": {
    "product": {
      "TableName": "product",
      "State": "completed",
      "RowsCompared": 2,
      "MatchingRows": 2,
      "MismatchedRows": 0,
      "ExtraRowsSource": 0,
      "ExtraRowsTarget": 0
    }
  },
  "Reports": {
    "product": {
      "80-": {
        "TableName": "product",
        "ProcessedRows": 2,
        "MatchingRows": 2,
        "MismatchedRows": 0,
        "ExtraRowsSource": 0,
        "ExtraRowsTarget": 0
      }
    }
  }
}

❯ vtctldclient vdiff --workflow commerce2customer --target-keyspace customer resume ca5cb9fe-900a-43ec-b5be-e80a67fa8ec3 --target-shards "-80"
VDiff resume scheduled

❯ vtctldclient vdiff --workflow commerce2customer --target-keyspace customer show ca5cb9fe-900a-43ec-b5be-e80a67fa8ec3 --verbose --format json
{
  "Workflow": "commerce2customer",
  "Keyspace": "customer",
  "State": "completed",
  "UUID": "ca5cb9fe-900a-43ec-b5be-e80a67fa8ec3",
  "RowsCompared": 2,
  "HasMismatch": false,
  "Shards": "-80,80-",
  "StartedAt": "2024-08-29 18:28:37",
  "CompletedAt": "2024-08-29 19:07:34",
  "TableSummary": {
    "product": {
      "TableName": "product",
      "State": "completed",
      "RowsCompared": 2,
      "MatchingRows": 2,
      "MismatchedRows": 0,
      "ExtraRowsSource": 0,
      "ExtraRowsTarget": 0
    }
  },
  "Reports": {
    "product": {
      "-80": {
        "TableName": "product",
        "ProcessedRows": 0,
        "MatchingRows": 0,
        "MismatchedRows": 0,
        "ExtraRowsSource": 0,
        "ExtraRowsTarget": 0
      },
      "80-": {
        "TableName": "product",
        "ProcessedRows": 2,
        "MatchingRows": 2,
        "MismatchedRows": 0,
        "ExtraRowsSource": 0,
        "ExtraRowsTarget": 0
      }
    }
  }
}

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: Update docs for 16654 and 16709 website#1835

Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: VReplication labels Aug 27, 2024
Copy link
Contributor

vitess-bot bot commented Aug 27, 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 Aug 27, 2024
@github-actions github-actions bot added this to the v21.0.0 milestone Aug 27, 2024
@mattlord mattlord removed NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsIssue A linked issue is missing for this Pull Request labels Aug 27, 2024
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 66 lines in your changes missing coverage. Please review.

Project coverage is 68.94%. Comparing base (5ced946) to head (9eabc9d).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vttablet/tabletmanager/vdiff/action.go 0.00% 47 Missing ⚠️
...d/vtctldclient/command/vreplication/vdiff/vdiff.go 45.45% 6 Missing ⚠️
.../vtctldclient/command/vreplication/common/utils.go 0.00% 5 Missing ⚠️
go/vt/vtctl/grpcvtctldserver/server.go 0.00% 3 Missing ⚠️
go/vt/vtctl/workflow/utils.go 82.35% 3 Missing ⚠️
go/vt/vtctl/workflow/server.go 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16654      +/-   ##
==========================================
+ Coverage   68.92%   68.94%   +0.01%     
==========================================
  Files        1565     1565              
  Lines      201682   201745      +63     
==========================================
+ Hits       139010   139090      +80     
+ Misses      62672    62655      -17     

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

Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord force-pushed the vdiff_start_ctrl branch 2 times, most recently from 1d08739 to f570e78 Compare August 27, 2024 15:24
@mattlord mattlord changed the title VDiff: Add control for start and stop VDiff: Add control for start/resume and stop Aug 27, 2024
@mattlord mattlord force-pushed the vdiff_start_ctrl branch 2 times, most recently from b358fda to 827805a Compare August 27, 2024 15:43
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
mattlord added a commit to vitessio/website that referenced this pull request Aug 30, 2024
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord removed the NeedsWebsiteDocsUpdate What it says label Aug 30, 2024
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.

Other than preferring auto-start to do-not-start as the flag name, everything looks good!

@@ -670,6 +670,7 @@ message VDiffCoreOptions {
int64 max_extra_rows_to_compare = 7;
bool update_table_stats = 8;
int64 max_diff_seconds = 9;
bool do_not_start = 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably call it auto-start to be consistent with the workflow create commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I started with, but the problem then is that if you do not specify the field — which older clients would not do — then the default/zero value is false and it's not started.

Copy link
Contributor

Choose a reason for hiding this comment

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

autoStart := subFlags.Bool("auto_start", true, "If false, streams will start in the Stopped state and will need to be explicitly started")

Shouldn't this definition, from vrep workflows, work? Default is true and user needs to specify --auto_start=false to start vdiff in a stopped state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an issue at the proto / RPC layer. Any client sending an older request object will not include that field. So it will be false (the zero value) on the server side

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try making it optional so that it's a *bool. Then we start it unless a value of false was specifically provided (would be nil in older client requests).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made that change here: 0020b0f

I'm good either way, so let's go with that if you prefer it.

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

@maxenglander maxenglander left a comment

Choose a reason for hiding this comment

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

❤️

Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord merged commit 10710d8 into vitessio:main Sep 7, 2024
132 checks passed
@mattlord mattlord deleted the vdiff_start_ctrl branch September 7, 2024 15:31
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
3 participants