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: disable foreign_key_checks for bulk data cleanup #15261

Merged
merged 6 commits into from
Feb 15, 2024

Conversation

mattlord
Copy link
Contributor

@mattlord mattlord commented Feb 15, 2024

Description

VReplication performs bulk data loads and cleanup (source side on complete and target side on cancel) and for the load portion it disabled foreign_key_checks (as do other bulk data load tools such as mysqldump), however, it did NOT do this for the bulk data cleanup. This PR also disables foreign_key_checks for the cleanup step to ensure that we can successfully cleanup the data when the tables being dropped/renamed (rename only an option on complete for the original source tables) have dependent constraints.

This doesn't necessarily have to be backported to v19, but I thought we should because foreign key support exists there and this fixes an important bug related to that support AND v19 is still in RC.

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 15, 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 15, 2024
@github-actions github-actions bot added this to the v20.0.0 milestone Feb 15, 2024
@mattlord mattlord added Backport to: release-19.0 Needs to be back ported to release-19.0 and removed NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsWebsiteDocsUpdate What it says NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work labels Feb 15, 2024
@@ -34,6 +34,8 @@ import (
binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
)

const testWorkflowFlavor = workflowFlavorVtctl
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 changed to workflowFlavorRandom and also tested locally with workflowFlavorVtctld

Copy link
Contributor Author

@mattlord mattlord Feb 15, 2024

Choose a reason for hiding this comment

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

Tested locally with workflowFlavorVtctld and it passes:

❯ git diff | cat
diff --git a/go/test/endtoend/vreplication/fk_test.go b/go/test/endtoend/vreplication/fk_test.go
index b7a88aee65..b15856501a 100644
--- a/go/test/endtoend/vreplication/fk_test.go
+++ b/go/test/endtoend/vreplication/fk_test.go
@@ -34,7 +34,7 @@ import (
 	binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
 )

-const testWorkflowFlavor = workflowFlavorVtctl
+const testWorkflowFlavor = workflowFlavorVtctld

 // TestFKWorkflow runs a MoveTables workflow with atomic copy for a db with foreign key constraints.
 // It inserts initial data, then simulates load. We insert both child rows with foreign keys and those without,

 ❯ make build
Thu Feb 15 15:12:32 EST 2024: Building source tree

❯ go test -v -timeout 15m -run ^TestFKWorkflow$ vitess.io/vitess/go/test/endtoend/vreplication
VTDATAROOT is /opt/vtdataroot/vreple2e_687716
=== RUN   TestFKWorkflow
E0215 15:13:19.528356   41743 vtorc_process.go:103] configuration - {
	"Debug": true,
	"ListenAddress": ":0",
	"MySQLTopologyUser": "orc_client_user",
	"MySQLTopologyPassword": "orc_client_user_password",
	"MySQLReplicaUser": "vt_repl",
	"MySQLReplicaPassword": "",
	"RecoveryPeriodBlockSeconds": 1
}
=== RUN   TestFKWorkflow/insertInitialFKData
=== RUN   TestFKWorkflow/vtctlclient_vdiff_fktarget.fk
=== RUN   TestFKWorkflow/vtctlclient_vdiff_fktarget.fk#01
--- PASS: TestFKWorkflow (52.09s)
    --- PASS: TestFKWorkflow/insertInitialFKData (0.01s)
    --- PASS: TestFKWorkflow/vtctlclient_vdiff_fktarget.fk (5.06s)
    --- PASS: TestFKWorkflow/vtctlclient_vdiff_fktarget.fk#01 (5.06s)
PASS
ok  	vitess.io/vitess/go/test/endtoend/vreplication	53.235s

Will change it to random now and push that change.

Signed-off-by: Matt Lord <[email protected]>
Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps left a comment

Choose a reason for hiding this comment

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

Nice compact solution.

@mattlord mattlord marked this pull request as ready for review February 15, 2024 20:22
Copy link

codecov bot commented Feb 15, 2024

Codecov Report

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

Comparison is base (de3c9c5) 67.46% compared to head (c95720e) 67.47%.

Files Patch % Lines
go/vt/vtctl/workflow/traffic_switcher.go 0.00% 8 Missing ⚠️
go/vt/vttablet/tabletmanager/rpc_query.go 75.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15261   +/-   ##
=======================================
  Coverage   67.46%   67.47%           
=======================================
  Files        1560     1560           
  Lines      193186   193205   +19     
=======================================
+ Hits       130333   130359   +26     
+ Misses      62853    62846    -7     

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

@@ -54,7 +54,7 @@ func TestVDiffStats(t *testing.T) {
defer testStats.controllers[id].TableDiffPhaseTimings.Record(phase, time.Now())
time.Sleep(sleepTime)
}
want := int64(1.2 * float64(sleepTime)) // Allow 20% overhead for recording timing
want := 10 * sleepTime // Allow 10x overhead for recording timing on flaky test hosts
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This addresses unrelated test flakes seen.

@mattlord mattlord merged commit 1c9388e into vitessio:main Feb 15, 2024
105 checks passed
@mattlord mattlord deleted the vrepl_cleanup_fks branch February 15, 2024 21:46
mattlord added a commit that referenced this pull request Feb 15, 2024
… cleanup (#15261) (#15265)

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

Successfully merging this pull request may close these issues.

Bug Report: Unable to cancel movetables with keep_data=false on database with foreign keys
4 participants