-
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.67%
========================================
Files 1583 1584 +1
Lines 254363 254703 +340
========================================
+ Hits 172140 172376 +236
- Misses 82223 82327 +104 ☔ 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.
@@ -158,7 +178,7 @@ var ( | |||
// externalize makes a LookupVindexExternalize call to a vtctld. | |||
externalize = &cobra.Command{ | |||
Use: "externalize", | |||
Short: "Externalize the Lookup Vindex. If the Vindex has an owner the VReplication workflow will also be deleted.", | |||
Short: "Externalize the Lookup Vindex. If the Vindex has an owner the VReplication workflow will also be stopped.", |
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.
Would it be challenging or problematic to add a --delete
flag for externalize for those that want to retain the old behavior? Then we can continue using the WorkflowDeleted
response field too.
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.
done 👍
if resp.WorkflowDeleted { | ||
output = output + fmt.Sprintf(" and the %s VReplication workflow has been deleted", baseOptions.Name) | ||
} |
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 it would also be nice to note when it was NOT deleted and why as the user is likely going to want to follow-up on this at some point.
Nit, but I don't think we need to specify the name yet again here, we can instead say and the VReplication workflow...
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.
done 👍
if resp.WorkflowStarted { | ||
output = output + fmt.Sprintf(" and the %s VReplication workflow has been started", baseOptions.Name) |
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.
Same comments here from the complete command.
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.
done.
go/vt/vtctl/workflow/server.go
Outdated
@@ -127,6 +127,9 @@ const ( | |||
lockTablesCycles = 2 | |||
// Time to wait between LOCK TABLES cycles on the sources during SwitchWrites. | |||
lockTablesCycleDelay = time.Duration(100 * time.Millisecond) | |||
|
|||
SqlFreezeWorkflow = "update _vt.vreplication set message = '%s' where db_name=%s and workflow=%s" |
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.
We can set the message directly here using the const as we always want to freeze it with the query.
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.
done.
// LookupVindexComplete checks if the lookup vindex has been externalized, | ||
// and if the vindex has an owner, it deletes the workflow. |
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 that the criteria should be the lookup vindex backfill workflow is "done", meaning it was externalized, which in turn means that it's no longer write_only and it has an owner (the source table).
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.
Same comment about the validateExternalized()
go/vt/vtctl/workflow/server.go
Outdated
// Stop the workflow. | ||
_, err = s.tmc.UpdateVReplicationWorkflow(ctx, tabletInfo.Tablet, &tabletmanagerdatapb.UpdateVReplicationWorkflowRequest{ | ||
Workflow: req.Name, | ||
State: ptr.Of(binlogdatapb.VReplicationWorkflowState_Stopped), | ||
}) | ||
if err != nil { | ||
return vterrors.Wrapf(err, "failed to stop workflow %s on shard %s/%s", req.Name, tabletInfo.Keyspace, tabletInfo.Shard) | ||
} | ||
// Mark workflow as frozen. | ||
query := fmt.Sprintf(SqlFreezeWorkflow, Frozen, | ||
encodeString(tabletInfo.DbName()), encodeString(req.Name)) | ||
_, err = s.tmc.VReplicationExec(ctx, tabletInfo.Tablet, query) |
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 that we should update the message in the UpdateVReplicationWorkflow
call above, which means we'll have to add support for that to the RPC as an optional proto field.
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.
Done, thanks for this! This is much cleaner now.
// LookupVindexInternalize internalizes a lookup vindex. If the vindex has an | ||
// owner then the stopped 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.
I think it's also worth checking that it does not have the write_only flag set as well.
I think it's worth defining what it means for a vindex to be externalized as 1) having an owner 2) having write_only == false, so that we can check for that everywhere using a function.
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.
Added check for write_only
, but shouldn't we check if all the streams are running if it's an unowned vindex, and all the streams are stopped if it's an owned vindex? Added validateExternalized()
func for this, please have a look.
Please let me know if that's the right thing?
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]>
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