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

br/stream: Added toolkit for managing migrations #55665

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

YuJuncen
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #55661

Problem Summary:
See the issue.

What changed and how does it work?

We added some new interfaces that helps to manipulate migrations. They are provided by a wrapper over ExternalStorage named MigrationExt.

  • MergeAndMigrateTo is the main interface for executing pending migrations.
  • Load loads the persisted migrations.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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 ti-chi-bot bot added do-not-merge/invalid-title 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. labels Aug 26, 2024
@YuJuncen YuJuncen changed the title Added toolkit for managing br/stream: Added toolkit for managing Aug 26, 2024
Copy link

tiprow bot commented Aug 26, 2024

Hi @YuJuncen. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@YuJuncen YuJuncen changed the title br/stream: Added toolkit for managing br/stream: Added toolkit for managing migrations Aug 26, 2024
Copy link

codecov bot commented Aug 26, 2024

Codecov Report

Attention: Patch coverage is 9.33165% with 719 lines in your changes missing coverage. Please review.

Project coverage is 75.5147%. Comparing base (b520f61) to head (6ce016f).
Report is 16 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55665        +/-   ##
================================================
+ Coverage   73.3867%   75.5147%   +2.1280%     
================================================
  Files          1620       1643        +23     
  Lines        447041     455667      +8626     
================================================
+ Hits         328069     344096     +16027     
+ Misses        98877      89986      -8891     
- Partials      20095      21585      +1490     
Flag Coverage Δ
integration 32.5841% <9.3316%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 61.6396% <9.3316%> (+16.1103%) ⬆️

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 6, 2024
err := os.Remove(path)
if err != nil &&
l.IgnoreEnoentForDelete &&
stderrors.Is(err, syscall.ENOENT) {
Copy link
Contributor

Choose a reason for hiding this comment

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

local external storage also support windows, so can syscall.ENOENT also match the error occur in windows system?

br/pkg/storage/local.go Show resolved Hide resolved
HandingMetaEditDone()
}

func NewProgressBarHooks(console glue.ConsoleOperations) *ProgressBarHooks {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it dead code? or will be called outside?


me := new(pb.MetaEdit)
me.Path = path
for _, ds := range meta.FileGroups {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we also append the me.DeleteLogicalFiles because m.applyMetaEditTo uses it?


// MergeAndMigrateTo will merge the migrations from BASE until the specified SN, then migrate to it.
// Finally it writes the new BASE and remove stale migrations from the storage.
func (m MigrationExt) MergeAndMigrateTo(
Copy link
Contributor

Choose a reason for hiding this comment

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

I found there are many functions only used in unit test, so I prefer to move these functions to another file with suffix _test.go to read and check codes for production more clearly.

@YuJuncen
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Sep 27, 2024

@YuJuncen: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 27, 2024
@YuJuncen
Copy link
Contributor Author

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Sep 27, 2024
Copy link

tiprow bot commented Sep 27, 2024

@YuJuncen: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow 6ce016f link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link

ti-chi-bot bot commented Sep 27, 2024

@YuJuncen: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/build 6ce016f link true /test build
idc-jenkins-ci-tidb/check_dev 6ce016f link true /test check-dev
idc-jenkins-ci-tidb/unit-test 6ce016f link true /test unit-test
idc-jenkins-ci-tidb/check_dev_2 6ce016f link true /test check-dev2

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Copy link
Contributor

@Leavrth Leavrth left a comment

Choose a reason for hiding this comment

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

rest LGTM. There are some functions used by another PR, so need to review again with the PR.

if err != nil {
emitErr(cannotBeRetryByRerunBase(
errors.Annotatef(err, "failed to open meta %s", path)))
return
Copy link
Contributor

Choose a reason for hiding this comment

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

should we limit the error number?

for _, edit := range s2 {
target, ok := edits[edit.GetPath()]
if !ok {
edits[edit.GetPath()] = edit
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also create a new &pb.MetaEdit the same as edit in s1?

Comment on lines +1070 to +1077
err = m.applyMetaEditTo(ctx, me, meta)
if err != nil {
updateResult(func(r *MigratedTo) {
r.Warnings = append(r.Warnings, errors.Annotatef(err, "during handling %s", me.Path))
r.NewBase.EditMeta = append(r.NewBase.EditMeta, me)
})
}
m.cleanUpFor(ctx, me, out)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about clean up log files before clean up metadata? Maybe the log files will be left in the external storage forever.

Copy link

ti-chi-bot bot commented Sep 29, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Leavrth

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Sep 29, 2024
Copy link

ti-chi-bot bot commented Sep 29, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-29 06:51:55.745135737 +0000 UTC m=+164871.165349008: ☑️ agreed by Leavrth.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. ok-to-test Indicates a PR is ready to be tested. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the toolkit for managing Migrations.
2 participants