-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
base: main
Are you sure you want to change the base?
LookupVindex: Implement internalize
command for lookup vindexes
#17429
Conversation
Signed-off-by: Noble Mittal <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Signed-off-by: Noble Mittal <[email protected]>
Signed-off-by: Noble Mittal <[email protected]>
Signed-off-by: Noble Mittal <[email protected]>
Codecov ReportAttention: Patch coverage is
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. |
Signed-off-by: Noble Mittal <[email protected]>
There was a problem hiding this 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/cmd/vtctldclient/command/vreplication/lookupvindex/lookupvindex.go
Outdated
Show resolved
Hide resolved
go/cmd/vtctldclient/command/vreplication/lookupvindex/lookupvindex.go
Outdated
Show resolved
Hide resolved
go/cmd/vtctldclient/command/vreplication/lookupvindex/lookupvindex.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Noble Mittal <[email protected]>
54753a4
to
ee296d2
Compare
Signed-off-by: Noble Mittal <[email protected]>
Signed-off-by: Noble Mittal <[email protected]>
…Workflow Signed-off-by: Noble Mittal <[email protected]>
Signed-off-by: Noble Mittal <[email protected]>
There was a problem hiding this 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.
Signed-off-by: Noble Mittal <[email protected]>
2e3db09
to
e866118
Compare
Signed-off-by: Noble Mittal <[email protected]>
There was a problem hiding this 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.", |
There was a problem hiding this comment.
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.", |
There was a problem hiding this comment.
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."
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." | ||
} |
There was a problem hiding this comment.
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?
if resp.WorkflowStarted { | ||
output = output + " and the VReplication workflow has been started." |
There was a problem hiding this comment.
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).") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)
// Now that we have checked that the vindex has been externalized, | ||
// we don't need to delete the write_only parameter from the vindex. |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
return nil, err | ||
} | ||
return resp, s.ts.RebuildSrvVSchema(ctx, nil) | ||
} | ||
|
||
// LookupVindexInternalize internalizes a lookup vindex. If the vindex has an |
There was a problem hiding this comment.
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?
Description
This PR
internalize
andcomplete
command for lookup vindexesexternalize
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 thewrite_only
vindex param back totrue
(which was deleted when lookup vindex was externalized.)Related Issue(s)
LookupVindex
has nointernalize
command (equivalent toReverseTraffic
) #15985Checklist
Deployment Notes