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

*: support 2-phases flashback cluster #38164

Merged
merged 36 commits into from
Oct 26, 2022

Conversation

Defined2014
Copy link
Contributor

@Defined2014 Defined2014 commented Sep 26, 2022

What problem does this PR solve?

Issue Number: close #38554, #37961

Problem Summary:

What is changed and how it works?

  • change flashback to two phases, first stage lock all regions, second stage do flashback.
  • close all cross flashback cluster connection.

Above two reasons, we could remove many useless codes in Flashback. Like history flashback time ranges, auto analyze max time etc.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 26, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bb7133
  • xhebox

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/invalid-title release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 26, 2022
@Defined2014 Defined2014 changed the title [WIP] Flashback 2 phase [WIP] *: support 2-phases flashback cluster Sep 27, 2022
@Defined2014 Defined2014 requested a review from a team as a code owner September 29, 2022 12:19
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 29, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 8, 2022
@ti-chi-bot ti-chi-bot removed the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Oct 26, 2022
Defined2014 and others added 2 commits October 26, 2022 10:16
Co-authored-by: bb7133 <bb7133@gmail.com>
@Defined2014
Copy link
Contributor Author

Change flashback to two phases

This is not needed before 'flashback cluster' is released as a feature. Please change it to 'None'

Done, PTAL @bb7133

Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 26, 2022
Copy link
Contributor

@xhebox xhebox left a comment

Choose a reason for hiding this comment

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

LGTM, two questions

infoschema/builder.go Show resolved Hide resolved
domain/schema_validator.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 26, 2022
@xhebox
Copy link
Contributor

xhebox commented Oct 26, 2022

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 06bdda7

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Oct 26, 2022
ddl/cluster.go Outdated
// Split region by keyRanges, make sure no unrelated key ranges be locked.
splitRegionsByKeyRanges(d, keyRanges)
totalRegions.Store(0)
for _, ranges := range keyRanges {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for _, ranges := range keyRanges {
for _, range := range keyRanges {

ddl/cluster.go Outdated
endKey = rangeEndKey
}

logutil.BgLogger().Info("send prepare flashback request", zap.Uint64("region_id", loc.Region.GetID()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logutil.BgLogger().Info("send prepare flashback request", zap.Uint64("region_id", loc.Region.GetID()),
logutil.BgLogger().Info("[ddl] send prepare flashback request", zap.Uint64("region_id", loc.Region.GetID()),

ddl/cluster.go Outdated

endKey := loc.EndKey
isLast := len(endKey) == 0 || (len(rangeEndKey) > 0 && bytes.Compare(endKey, rangeEndKey) >= 0)
// If it is the last region
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// If it is the last region
// If it is the last region.

ddl/cluster.go Outdated
@@ -422,16 +565,25 @@ func (w *worker) onFlashbackCluster(d *ddlCtx, t *meta.Meta, job *model.Job) (ve
job.SchemaState = model.StatePublic
return ver, nil
}

keyRanges, err := GetFlashbackKeyRanges(sess, tablecodec.EncodeTablePrefix(0))
keyRanges, err := GetFlashbackKeyRanges(sess)
if err != nil {
return ver, errors.Trace(err)
}

for _, ranges := range keyRanges {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for _, ranges := range keyRanges {
for _, range := range keyRanges {

ddl/cluster.go Outdated
// use commitTS - 1 as startTS, make sure it less than commitTS.
stats, err := sendFlashbackToVersionRPC(ctx, d.store.(tikv.Storage), flashbackTS, commitTS-1, commitTS, r)
completedRegions.Add(uint64(stats.CompletedRegions))
logutil.BgLogger().Info("flashback cluster stats",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logutil.BgLogger().Info("flashback cluster stats",
logutil.BgLogger().Info("[ddl] flashback cluster stats",

ddl/cluster.go Outdated
if err = flashbackToVersion(context.Background(), d, flashbackTS, ranges.StartKey, ranges.EndKey); err != nil {
if err = flashbackToVersion(d.ctx, d,
func(ctx context.Context, r tikvstore.KeyRange) (rangetask.TaskStat, error) {
// use commitTS - 1 as startTS, make sure it less than commitTS.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// use commitTS - 1 as startTS, make sure it less than commitTS.
// Use commitTS - 1 as startTS, make sure it less than commitTS.

ddl/cluster.go Outdated

return keyRanges, nil
func prepareFlashbackToVersion(
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that this function code is the same as flashbackToVersion. Is it duplicated?

@xhebox
Copy link
Contributor

xhebox commented Oct 26, 2022

/hold

@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 26, 2022
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Oct 26, 2022
@xhebox
Copy link
Contributor

xhebox commented Oct 26, 2022

/unhold

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 26, 2022
@Defined2014
Copy link
Contributor Author

/unhold

@Defined2014
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 45054eb

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Oct 26, 2022
@Defined2014
Copy link
Contributor Author

/run-build

@ti-chi-bot ti-chi-bot merged commit 4bdd20b into pingcap:master Oct 26, 2022
@Defined2014 Defined2014 deleted the flashback-2-phase branch October 26, 2022 09:02
@sre-bot
Copy link
Contributor

sre-bot commented Oct 26, 2022

TiDB MergeCI notify

✅ Well Done! New fixed [3] after this pr merged.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/common-test ✅ all 11 tests passed 10 min Fixed
idc-jenkins-ci-tidb/sqllogic-test-2 ✅ all 28 tests passed 6 min 3 sec Fixed
idc-jenkins-ci-tidb/sqllogic-test-1 ✅ all 26 tests passed 5 min 34 sec Fixed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 29 min Existing passed
idc-jenkins-ci/integration-cdc-test 🟢 all 38 tests passed 21 min Existing passed
idc-jenkins-ci-tidb/integration-common-test 🟢 all 17 tests passed 17 min Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 6 min 34 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 3 min 14 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 3 min 4 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

restart tidb during flashback, flashback ddl will hang
6 participants