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: Fix workflow update changed handling #15621

Merged
merged 3 commits into from
Apr 3, 2024

Conversation

mattlord
Copy link
Contributor

@mattlord mattlord commented Apr 3, 2024

Description

The rows affected value in the UpdateVReplicationWorkflow tabletmanager RPC (see the PR changes) which is then turned into a boolean changed value in the corresponding UpdateWorkflow vtctld RPC was inadvertently broken in: #14447

This PR corrects that and also addresses an oversight in adding support for changing the State in the tabletmanager RPC (we should be passing the simulated NULL for the client command as we don't allow you to modify the state via the workflow update client command). Note that this had no real practical impact as the workflow is stopped and started as part of the update so the intermediate state of Unknown was extremely brief.

Lastly, we close the testing gap here by confirming the changed value from the client command.

I wanted to backport this to v18 as it's a small and safe change and that's where these bugs were introduced.

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 Apr 3, 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 Apr 3, 2024
@github-actions github-actions bot added this to the v20.0.0 milestone Apr 3, 2024
@mattlord mattlord added Backport to: release-18.0 Backport to: release-19.0 Needs to be back ported to release-19.0 and removed Backport to: release-18.0 Backport to: release-19.0 Needs to be back ported to release-19.0 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 Apr 3, 2024
@mattlord mattlord marked this pull request as ready for review April 3, 2024 04:25
@mattlord mattlord changed the title Fix workflow update changed handling VReplication: Fix workflow update changed handling Apr 3, 2024
This was inadvertently broken in vitessio#14447

Signed-off-by: Matt Lord <[email protected]>
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

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

Project coverage is 68.12%. Comparing base (37cc00a) to head (a57df52).
Report is 11 commits behind head on main.

Files Patch % Lines
...ctldclient/command/vreplication/workflow/update.go 0.00% 1 Missing ⚠️
go/vt/vtctl/vtctl.go 0.00% 1 Missing ⚠️
go/vt/vttablet/tabletmanager/rpc_vreplication.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15621      +/-   ##
==========================================
+ Coverage   68.03%   68.12%   +0.09%     
==========================================
  Files        1561     1556       -5     
  Lines      195526   194984     -542     
==========================================
- Hits       133023   132840     -183     
+ Misses      62503    62144     -359     

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

Copy link
Member

@derekperkins derekperkins left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -112,6 +112,7 @@ func commandUpdate(cmd *cobra.Command, args []string) error {
TabletSelectionPreference: tsp,
OnDdl: binlogdatapb.OnDDLAction(onddl),
Shards: baseOptions.Shards,
State: binlogdatapb.VReplicationWorkflowState(textutil.SimulatedNullInt), // We don't allow changing this in the client command
Copy link
Member

Choose a reason for hiding this comment

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

If we're not using the cli, is there documentation for when the zero value isn't sufficient for a no-op? Does it make sense to at least add field level comments to the proto?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I've added comments here: 3dd0e13

Copy link
Member

Choose a reason for hiding this comment

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

That's helpful. Is it backwards compatible if we add optional to those fields?

Copy link
Contributor Author

@mattlord mattlord Apr 3, 2024

Choose a reason for hiding this comment

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

In the go protobuf implementation everything is optional. And unfortunately it does not support the more recent optional protobuf behavior where code is then injected to detect if a value was explicitly provided in the message. That's what the simulated NULL stuff is all about, because there's literally no way to determine if a value was actually provided or not (type's ZeroValue). I'm not terribly happy with it, but I could not find a less bad option today. I'd love to get rid of the simulated NULL whenever a better option appears.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, my understanding is now dated! The go implementation DOES now support truly optional field behavior: https://github.com/protocolbuffers/protobuf/blob/v3.25.0/docs/field_presence.md

It does that by making the specified type, e.g. string, a pointer (*string). I'm looking into whether or not that's backward compatible now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#15627 ❤️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a TODO in the comments as well to link everything together.

1. Add comments to the workflow update related proto messages
2. Remove/reserve an unused shards field in the WorkflowUpdateRequest msg
3. Add a wait to the mulit_tenant_test to address an obvserved flake

Signed-off-by: Matt Lord <[email protected]>
@@ -190,6 +190,7 @@ func TestMultiTenantSimple(t *testing.T) {
for _, ks := range []string{sourceKeyspace, sourceAliasKeyspace} {
lastIndex = insertRows(lastIndex, ks)
}
waitForWorkflowState(t, vc, fmt.Sprintf("%s.%s", targetKeyspace, mt.workflowName), binlogdatapb.VReplicationWorkflowState_Running.String())
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 unrelated, but addresses a test flake that was observed on the PR CI runs.

message UpdateVReplicationWorkflowRequest {
string workflow = 1;
repeated string cells = 2;
repeated topodata.TabletType tablet_types = 3;
TabletSelectionPreference tablet_selection_preference = 4;
binlogdata.OnDDLAction on_ddl = 5;
binlogdata.VReplicationWorkflowState state = 6;
repeated string shards = 7;
reserved 7; // unused, was: repeated string shards
Copy link
Contributor Author

@mattlord mattlord Apr 3, 2024

Choose a reason for hiding this comment

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

This was errantly added in v19 and was missed during review. It caused no harm, but was entirely unnecessary/unused.

@mattlord mattlord merged commit 0e2f175 into vitessio:main Apr 3, 2024
106 checks passed
@mattlord mattlord deleted the workflow_update branch April 3, 2024 17:55
mattlord added a commit that referenced this pull request Apr 3, 2024
…5621) (#15629)

Signed-off-by: Matt Lord <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Co-authored-by: Matt Lord <[email protected]>
mattlord added a commit that referenced this pull request Apr 3, 2024
…5621) (#15628)

Signed-off-by: Matt Lord <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Co-authored-by: Matt Lord <[email protected]>
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.

vtctldclient: WorkflowUpdate response does not set Changed
3 participants