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: Make Target Sequence Initialization More Robust #15289

Merged
merged 7 commits into from
Feb 20, 2024

Conversation

mattlord
Copy link
Contributor

@mattlord mattlord commented Feb 20, 2024

Description

This makes two key improvements to how we manage the initialization of target sequences when executing a MoveTables SwitchTraffic command and the --initialize-target-sequences flag is specified:

  1. We properly account for the case where the target table using the sequence is empty on a target shard
  2. We treat these failures as rollback / revert eligible. This makes sense because if we have not successfully completed the sequence init work then we cannot guarantee that there will not be insert errors when using the sequence after we switch traffic AND reverting back is safe AND we can safely attempt to reinitialize the target sequences again on the next attempt (assuming the failure was ephemeral or is otherwise addressed)

I think that this fix should be backported to v18 — where the initial feature was first added — as the changes are isolated to users of the new feature and this work makes that feature more robust and reliable for them.

Click here to see a manual test
pushd ${VTROOT}/examples/local

./101_initial_cluster.sh

mysql < ../common/insert_commerce_data.sql

mysql commerce -e "insert into customer (customer_id, email) values (99999, '[email protected]')" --binary-as-hex=false

vtctldclient --server localhost:15999 CreateKeyspace --durability-policy=semi_sync customer || fail "Failed to create and configure the commerce keyspace"

./301_customer_sharded.sh; ./302_new_shards.sh

sleep 30

vtctldclient ApplySchema --sql-file create_customer_sharded.sql customer

mysql commerce -e "select * from customer order by customer_id" --binary-as-hex=false
mysql commerce -e "select * from customer_seq" --binary-as-hex=false

vtctldclient MoveTables --target-keyspace customer --workflow commerce2customer create --tables 'customer,corder' --source-keyspace commerce

sleep 30

mysql customer -e "select * from customer order by customer_id" --binary-as-hex=false

# Delete the record that is on the 80- shard
primaryuid=$(vtctldclient GetTablets --keyspace customer --tablet-type primary --shard "80-" | awk '{print $1}' | cut -d- -f2 | bc)
command mysql -u root --socket=${VTDATAROOT}/vt_0000000${primaryuid}/mysql.sock --binary-as-hex=false vt_customer -e "delete from vt_customer.customer"

vtctldclient MoveTables --target-keyspace customer --workflow commerce2customer SwitchTraffic --initialize-target-sequences

mysql commerce -e "select * from customer_seq" --binary-as-hex=false

mysql customer -e "insert into customer (email) values ('[email protected]')" --binary-as-hex=false

mysql commerce -e "select * from customer_seq" --binary-as-hex=false

sleep 5

mysql customer -e "select * from customer order by customer_id" --binary-as-hex=false

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 Feb 20, 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 Feb 20, 2024
@github-actions github-actions bot added this to the v20.0.0 milestone Feb 20, 2024
Signed-off-by: Matt Lord <[email protected]>
Copy link

codecov bot commented Feb 20, 2024

Codecov Report

Attention: 22 lines in your changes are missing coverage. Please review.

Comparison is base (af38099) 67.49% compared to head (d3d05ac) 67.54%.
Report is 3 commits behind head on main.

Files Patch % Lines
go/vt/vtctl/workflow/traffic_switcher.go 0.00% 9 Missing ⚠️
go/vt/vtctl/workflow/server.go 0.00% 7 Missing ⚠️
go/vt/wrangler/traffic_switcher.go 62.50% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15289      +/-   ##
==========================================
+ Coverage   67.49%   67.54%   +0.04%     
==========================================
  Files        1561     1561              
  Lines      193355   193381      +26     
==========================================
+ Hits       130512   130616     +104     
+ Misses      62843    62765      -78     

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

Signed-off-by: Matt Lord <[email protected]>
@mattlord mattlord added Backport to: release-18.0 Backport to: release-19.0 Needs to be back ported to release-19.0 and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsIssue A linked issue is missing for this Pull Request labels Feb 20, 2024
@mattlord mattlord marked this pull request as ready for review February 20, 2024 12:43
Copy link
Contributor

@ajm188 ajm188 left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Some suggestions around the log messages purely for readability. I agree with the call to backport to 18.0

go/vt/vtctl/workflow/server.go Outdated Show resolved Hide resolved
go/vt/vtctl/workflow/traffic_switcher.go Outdated Show resolved Hide resolved
go/vt/wrangler/traffic_switcher.go Outdated Show resolved Hide resolved
go/vt/wrangler/traffic_switcher.go Outdated Show resolved Hide resolved
go/vt/wrangler/traffic_switcher.go Outdated Show resolved Hide resolved
go/vt/vtctl/workflow/traffic_switcher.go Outdated Show resolved Hide resolved
@mattlord mattlord merged commit 999f1c1 into vitessio:main Feb 20, 2024
102 checks passed
@mattlord mattlord deleted the vrepl_init_seqs branch February 20, 2024 19:02
vitess-bot pushed a commit that referenced this pull request Feb 20, 2024
vitess-bot pushed a commit that referenced this pull request Feb 20, 2024
dbussink pushed a commit that referenced this pull request Feb 20, 2024
… Robust (#15289) (#15308)

Signed-off-by: Matt Lord <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
dbussink pushed a commit that referenced this pull request Feb 20, 2024
… Robust (#15289) (#15307)

Signed-off-by: Matt Lord <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants