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

LookupVindex: Implement internalize command for lookup vindexes #17429

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

beingnoble03
Copy link
Member

@beingnoble03 beingnoble03 commented Dec 24, 2024

Description

This PR

  • Implements the internalize and complete command for lookup vindexes
  • Also, modifies the externalize command where we stop the workflow and mark it as frozen instead of deleting it.
  • complete command checks if the lookup vindex is externalized, and if it has an owner, it deletes the workflow.
  • internalize command starts the frozen streams (if there's an owner) and sets the write_only vindex param back to true (which was deleted when lookup vindex was externalized.)

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

Copy link
Contributor

vitess-bot bot commented Dec 24, 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 Dec 24, 2024
@github-actions github-actions bot added this to the v22.0.0 milestone Dec 24, 2024
Copy link

codecov bot commented Dec 29, 2024

Codecov Report

Attention: Patch coverage is 52.59259% with 128 lines in your changes missing coverage. Please review.

Project coverage is 67.68%. Comparing base (9383943) to head (1631cd2).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
.../command/vreplication/lookupvindex/lookupvindex.go 12.50% 56 Missing ⚠️
go/vt/vtctl/grpcvtctldserver/server.go 0.00% 24 Missing ⚠️
go/vt/vtctl/workflow/server.go 79.13% 24 Missing ⚠️
go/vt/vtctl/grpcvtctldclient/client_gen.go 0.00% 10 Missing ⚠️
go/vt/vtctl/workflow/lookup_vindex.go 78.37% 8 Missing ⚠️
go/vt/vtctl/localvtctldclient/client_gen.go 0.00% 4 Missing ⚠️
go/vt/vtctl/workflow/utils.go 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17429      +/-   ##
==========================================
+ Coverage   67.67%   67.68%   +0.01%     
==========================================
  Files        1583     1584       +1     
  Lines      254363   254753     +390     
==========================================
+ Hits       172140   172440     +300     
- Misses      82223    82313      +90     

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

@beingnoble03 beingnoble03 added Type: 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 Dec 30, 2024
@beingnoble03 beingnoble03 marked this pull request as ready for review December 30, 2024 06:30
Copy link
Contributor

@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 good! I only had some minor comments and suggestions. Let me know what you think.

go/vt/vtctl/workflow/server.go Outdated Show resolved Hide resolved
go/vt/vtctl/workflow/server.go Show resolved Hide resolved
go/vt/vtctl/workflow/server.go Outdated Show resolved Hide resolved
go/vt/vtctl/workflow/server.go Show resolved Hide resolved
@beingnoble03 beingnoble03 force-pushed the lookup-vindex-internalize branch from 54753a4 to ee296d2 Compare January 8, 2025 21:51
@beingnoble03 beingnoble03 requested a review from mattlord January 10, 2025 19:13
Copy link
Contributor

@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! I still had a few outstanding questions/concerns though. Happy to sit down and walk through things if you like. I could be missing or misunderstanding some things as well so we could quickly get on the same page.

go/vt/vttablet/tabletmanager/rpc_vreplication.go Outdated Show resolved Hide resolved
go/vt/vtctl/workflow/lookup_vindex.go Outdated Show resolved Hide resolved
go/vt/vtctl/workflow/lookup_vindex.go Outdated Show resolved Hide resolved
go/vt/vtctl/workflow/server.go Outdated Show resolved Hide resolved
go/vt/vtctl/workflow/server.go Outdated Show resolved Hide resolved
go/vt/vtctl/workflow/server.go Outdated Show resolved Hide resolved
go/vt/vtctl/workflow/server.go Outdated Show resolved Hide resolved
@beingnoble03 beingnoble03 force-pushed the lookup-vindex-internalize branch from 2e3db09 to e866118 Compare January 14, 2025 10:26
@beingnoble03 beingnoble03 requested a review from mattlord January 14, 2025 10:48
Copy link
Contributor

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

The code all looks great now! The only thing left, IMO, is updating some of the user facing text (and dev facing comments) based on the current behavior after the changes. As you now know, this can easily get confusing so any clarity we can add is worth it.

Hopefully it makes sense. Feel free to grab me on slack if not. Thank you for hanging in there! 🙂

// complete makes a LookupVindexComplete call to a vtctld.
complete = &cobra.Command{
Use: "complete",
Short: "Complete the Lookup Vindex. If the Vindex has an owner the VReplication workflow will also be deleted.",
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be tweaked a bit now, I think. No? Maybe:

"Complete the LookupVindex workflow. The VIndex must have been previously externalized. If you want to delete the workflow without externalizing the VIndex then use the cancel command instead."

// internalize makes a LookupVindexInternalize call to a vtctld.
internalize = &cobra.Command{
Use: "internalize",
Short: "Internalize the Lookup Vindex. If the Vindex has an owner the VReplication workflow will also be started.",
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we're being a little ambiguous about the LookupVindex workflow and the VIndex that it backfills. Also, isn't it that we will restart the workflow if it does NOT have an owner? Doesn't it HAVE to not have an owner for it to be considered internalized? Are we referring to the state of the VIndex before we change anything? Internalize should require that externalize had been previously done, which means that there must be an owner (the backing table). IMO this is clearer:

"Internalize the VIndex again to continue the back fill, making it unusable for queries again."

Comment on lines +254 to +258
if resp.WorkflowDeleted {
output = output + " and the VReplication workflow has been deleted."
} else {
output = output + ". The VReplication workflow hasn't been stopped as the vindex is unowned."
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't it always be deleted if there was no error?

Comment on lines +339 to +340
if resp.WorkflowStarted {
output = output + " and the VReplication workflow has been started."
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it's an error if we internalized it but did not start the workflow. I'm not sure what the point is in that case.

// vindex has an owner as the lookup vindex will then be
// managed by VTGate.
externalize.Flags().StringVar(&externalizeOptions.Keyspace, "keyspace", "", "The keyspace containing the Lookup Vindex. If no value is specified then the table-keyspace will be used.")
externalize.Flags().BoolVar(&externalizeOptions.Delete, "delete", false, "Delete the VReplication workflow after externalizing LookupVindex, instead of stopping (default false).")
Copy link
Contributor

Choose a reason for hiding this comment

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

Less ambiguous IMO to say ... workflow after externalizing the VIndex, ...

for _, stream := range res.Streams {
// All streams need to be frozen.
if stream.State != binlogdatapb.VReplicationWorkflowState_Stopped || stream.Message != Frozen {
return vterrors.Errorf(vtrpcpb.Code_INTERNAL, "stream %d for %v.%v is not frozen: %v, %v", stream.Id, targetShard.Keyspace(), targetShard.ShardName(), stream.State, stream.Message)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but keyspace/shard is the standard vs keyspace.shard, suggestion:

return vterrors.Errorf(vtrpcpb.Code_INTERNAL, "stream %d on %v/%v is not frozen: %v, %v", stream.Id, targetShard.Keyspace(), targetShard.ShardName(), stream.State, stream.Message)

Comment on lines +584 to +585
// Now that we have checked that the vindex has been externalized,
// we don't need to delete the write_only parameter from the vindex.
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, this comment is only a little confusing to me. I think we can remove it. If it's helpful for you though fine to keep it as well. I get what you mean, but I think its meaning largely lies in the previous state of the code which is no longer visible (easily).

KeepData: true,
KeepRoutingRules: true,
}); derr != nil {
return nil, vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "failed to delete workflow %s: %v", req.Name, derr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but this doesn't feel like a precondition.

go/vt/vtctl/workflow/server.go Show resolved Hide resolved
return nil, err
}
return resp, s.ts.RebuildSrvVSchema(ctx, nil)
}

// LookupVindexInternalize internalizes a lookup vindex. If the vindex has an
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove this comment now: If the vindex has an // owner then the stopped workflow will also be started.

Since we would fail at `validateExternalized() now, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: LookupVindex has no internalize command (equivalent to ReverseTraffic)
3 participants