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

New VReplication workflows cli UX. Allow reads/writes to be switched independently #7071

Merged
merged 26 commits into from
Jan 3, 2021

Conversation

rohit-nayak-ps
Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps commented Nov 23, 2020

The motivation and design for this issue are outlined in the RFC at #7225. Some implementation details are provided below: more detailed documentation will be added to the vitess.io website soon.

The main change is that all subcommands for a MoveTables or Reshard workflow is routed through the new VReplicationWorkflow object. VReplicationWorkflow first deduces the state of a workflow from the parameters in the _vt sidecar and topo and invokes the associated wrangler methods. The only changes made in wrangler related to this PR is to allow switching tablet types in any order.

vtctld mods

MoveTables and Reshard commands now take a -v2 parameter which causes the new functionality to be invoked. These will continue to run side-by-side with the current functionality. We will first deprecate v1 and remove v1-only code in a subsequent release making v2 functionality as default.

Routing rule changes

MoveTables v1 uses routing rules to tell vtgate, which keyspace to route queries to. In v1 we always need to run SwitchReads before SwitchWrites. MoveTables sets up routing rules pointing primary/replica/rdonly tables to the source keyspace. SwitchReads would change the routing rules for related tablet types to point to the target and reversal point it back to the source. SwitchWrites would delete all rules except the one for the table.

Since tablet types can now be switched (and reversed) in any order we keep the routing rules through the lifetime of the workflow. We keep the routing rules in place and currently DropSources does not delete them. This PR continues to keep the routing rules. A follow-up PR will add the removal of routing rules to the Complete/Abort subcommands.

Abort

It is possible to abort and cleanup a created workflow as long as traffic has not been switched. This deletes the vreplication artifacts and optionally, delete data: target tables/shards.

Progress

We report the progress of a workflow by showing the percentage of data copied across targets, if workflow is in copy state, and the lag between the last source event after the copy phase is completed. It is too expensive to get actual row counts of tables, so we use the statistics available in information_schema to approximate copy progress. This data can be significantly off (upto 50-60%) depending on the utilization of the underlying mysql server resources.

Notes:

  • We are still marking the streams as FROZEN when we switch primary traffic even though replica and rdonly traffic may not be switched yet. This will be addressed as part of a major refactor of the vreplication related tables in the sidecar _vt table.

Todos: upcoming PRs will achieve these

@rohit-nayak-ps rohit-nayak-ps changed the title WIP: New Switch Reads and Writes flow WIP: New MoveTables cli flow, also allowing reads/writes to be switched independently Dec 5, 2020
@rohit-nayak-ps rohit-nayak-ps changed the title WIP: New MoveTables cli flow, also allowing reads/writes to be switched independently WIP: New VReplication workflows cli UX. Allow reads/writes to be switched independently Dec 23, 2020
Copy link
Contributor

@sougou sougou left a comment

Choose a reason for hiding this comment

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

Looking good so far. Let's keep going.

…ble. Setup routing rules for new flow

Signed-off-by: Rohit Nayak <[email protected]>
Signed-off-by: Rohit Nayak <[email protected]>
…w Progress, ReverseReads/Writes

Signed-off-by: Rohit Nayak <[email protected]>
…raffic/ReverseTraffic instead of SwitchWrites/SwitchReads, added Complete (similar to DropSources) and Abort (drop targets) commands

Signed-off-by: Rohit Nayak <[email protected]>
Signed-off-by: Rohit Nayak <[email protected]>
Signed-off-by: Rohit Nayak <[email protected]>
Signed-off-by: Rohit Nayak <[email protected]>
Signed-off-by: Rohit Nayak <[email protected]>
@rohit-nayak-ps rohit-nayak-ps changed the title WIP: New VReplication workflows cli UX. Allow reads/writes to be switched independently New VReplication workflows cli UX. Allow reads/writes to be switched independently Dec 26, 2020
@rohit-nayak-ps rohit-nayak-ps marked this pull request as ready for review December 26, 2020 19:43
Copy link
Contributor

@sougou sougou left a comment

Choose a reason for hiding this comment

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

I eyeballed the changes. They look good. Couple comments/questions. If they're addressed, this can be merged.

go/test/endtoend/vreplication/cluster.go Outdated Show resolved Hide resolved

_ = subFlags.Bool("v2", true, "")

_ = dryRun //TODO: add dry run functionality
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw some code for dry run. Do you just have to pass the flag in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of the original dry run code will still apply here, but wanted to review and update it if necessary for the new wrappers as a separate PR that should be ready this week.

Signed-off-by: Rohit Nayak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants