Skip to content

Conversation

@beingnoble03
Copy link
Member

@beingnoble03 beingnoble03 commented Feb 15, 2025

Description

This PR adds WorkflowAddTables in VtctldServer. This can be used to add tables to an existing VReplication MoveTables/Materialize workflow. It adds binlogsource rules in the existing workflow streams, and inserts the copy state row in _vt.copy_state and restarts the workflow. Also adds a add-reference-tables sub-command for materialize command, which can be used as following:

vtctldclient Materialize --target-keyspace=customer --workflow=w1 add-reference-tables --tables="corder,customer"

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

@vitess-bot
Copy link
Contributor

vitess-bot bot commented Feb 15, 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 Feb 15, 2025
@github-actions github-actions bot added this to the v22.0.0 milestone Feb 15, 2025
@codecov
Copy link

codecov bot commented Feb 15, 2025

Codecov Report

Attention: Patch coverage is 68.72852% with 91 lines in your changes missing coverage. Please review.

Project coverage is 67.50%. Comparing base (673e0d3) to head (2e7e19e).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtctl/workflow/server.go 77.77% 34 Missing ⚠️
...nt/command/vreplication/materialize/materialize.go 16.66% 20 Missing ⚠️
go/vt/vtctl/workflow/materializer.go 82.95% 15 Missing ⚠️
go/vt/vtctl/grpcvtctldserver/server.go 0.00% 12 Missing ⚠️
go/vt/vtctl/grpcvtctldclient/client_gen.go 0.00% 5 Missing ⚠️
...vttablet/tabletmanager/vreplication/vreplicator.go 50.00% 3 Missing ⚠️
go/vt/vtctl/localvtctldclient/client_gen.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17804      +/-   ##
==========================================
- Coverage   67.54%   67.50%   -0.05%     
==========================================
  Files        1601     1601              
  Lines      261484   261816     +332     
==========================================
+ Hits       176612   176726     +114     
- Misses      84872    85090     +218     

☔ 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.

@beingnoble03 beingnoble03 force-pushed the add-tables-materialize branch from ed0f3e9 to 7d4356f Compare February 17, 2025 07:04
@beingnoble03 beingnoble03 force-pushed the add-tables-materialize branch from 7d4356f to 5b317c5 Compare February 17, 2025 19:43
@beingnoble03 beingnoble03 force-pushed the add-tables-materialize branch from 7b4c750 to bdc7309 Compare February 18, 2025 11:15
@beingnoble03 beingnoble03 added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: VReplication 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 Feb 22, 2025
Copy link
Member

@mattlord mattlord 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 looking really good! Please let me know what you think about my comments.

Copy link
Member

@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.

lgtm!

I suggest we also update TestReferenceTableMaterialize to add another ref table to the workflow so we also test this in e2e.

@beingnoble03
Copy link
Member Author

@rohit-nayak-ps done. ptal at de2e068

Copy link
Contributor

@shlomi-noach shlomi-noach left a comment

Choose a reason for hiding this comment

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

I'm concerned about the wording here. The PR as well as the code label this as "materialization" but then again the same logic applies for MoveTables if I understand correctly. This will cause confusion down the line. Let's think about better terms that will apply to materialization, movetables, or any other type of workflow.

message MaterializeCreateResponse {
}

message MaterializeAddTablesRequest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will there likewise be a MoveTablesAddTablesRequest?

Copy link
Member Author

Choose a reason for hiding this comment

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

noted, since this API works for both Materialize and MoveTables wfs, WorkflowAddTables seems like a better name imo.

return err
}
vr.insertLog(LogCopyRestart, fmt.Sprintf("Copy phase restarted for %d table(s)", numTablesToCopy))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: this change seems unrelated to this PR specifically, is that correct? Or is this PR creating the only scenario where this change is needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, we need it here. When we are adding reference tables and inserting rows in _vt.copy_state, streams will jump back to Copying phase, this is when we need to log Copy phase restarted.

}
return nil
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: say we run this on a multisharded cluster. One shard fails, we get an error, correct? What then happens if we attempt to add the table again on all shards? Will the shards that already know about the table accept the request silently or will they return an error?

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like it will silently accept the request and insert another row in copy_state. Although I don't think it will cause any issues since vcopier will anyway look at the max(id) row from copy_state for a specific table and vrepl_id. Do you think we need any changes here? Not sure if we should delete the copy_state row in all other shards if it fails in one shard before we return error?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure!

@beingnoble03
Copy link
Member Author

@shlomi-noach thanks for the review. Please have a look at the comments.

@frouioui frouioui modified the milestones: v22.0.0, v23.0.0 Apr 1, 2025
Copy link
Contributor

@shlomi-noach shlomi-noach left a comment

Choose a reason for hiding this comment

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

My one remaining question is about idempotency: what happens if you add a table that is already listed. Otherwise looks good.

@beingnoble03
Copy link
Member Author

My one remaining question is about idempotency: what happens if you add a table that is already listed. Otherwise looks good.

Did you mean if we try to add a table that already has a filter rule? We have a check here that throws an error in that case: https://github.com/vitessio/vitess/pull/17804/files#diff-327b08a43697d540e06dfd4e4c4d0cb617dc66f9ad3d74c451b926405c9faae5R1017-R1023

Signed-off-by: Noble Mittal <[email protected]>
@rohit-nayak-ps rohit-nayak-ps merged commit f0e9a2d into vitessio:main Apr 24, 2025
106 of 109 checks passed
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.

Feature Request: ability to update Materialize workflow with new reference tables

5 participants