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

Merged
merged 8 commits into from
Oct 21, 2024

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 65.65534% with 283 lines in your changes missing coverage. Please review.

Project coverage is 58.7260%. Comparing base (1e24d39) to head (16a6fa1).
Report is 80 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #55665         +/-   ##
=================================================
- Coverage   73.3721%   58.7260%   -14.6462%     
=================================================
  Files          1626       1781        +155     
  Lines        448978     652968     +203990     
=================================================
+ Hits         329425     383462      +54037     
- Misses        99368     244837     +145469     
- Partials      20185      24669       +4484     
Flag Coverage Δ
integration 40.9284% <12.0145%> (?)
unit 74.3528% <65.6553%> (+1.8702%) ⬆️

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

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 63.7296% <65.6553%> (+18.1396%) ⬆️

@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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess for now TiDB doesn't have any compatibility promise for windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have checked that this won't make TiDB failed to compile in Windows. As this only affects test cases, I think it could be fine to don't specially handle this 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
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.

br/pkg/stream/stream_metas.go Outdated Show resolved Hide resolved
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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess no, we are copying the first one because we may modify the content of Delete[Physical|Logical]Files then. In this case we won't edit them.

br/pkg/stream/stream_metas.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 29, 2024
@YuJuncen
Copy link
Contributor Author

/test pull-br-integration-test

Some Unavailable...

Copy link

ti-chi-bot bot commented Oct 10, 2024

@YuJuncen: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test
  • /test pull-unit-test-ddlv1

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_br_integration_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_lightning_integration_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test pull-br-integration-test

Some Unavailable...

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.

Copy link

tiprow bot commented Oct 10, 2024

@YuJuncen: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test fast_test_tiprow_ddlargsv1
  • /test tidb_parser_test

Use /test all to run the following jobs that were automatically triggered:

  • fast_test_tiprow
  • tidb_parser_test

In response to this:

/test pull-br-integration-test

Some Unavailable...

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
Copy link
Contributor Author

/retest-required

Copy link

ti-chi-bot bot commented Oct 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3pointer, 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 18, 2024
Copy link

ti-chi-bot bot commented Oct 18, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-29 06:51:55.745135737 +0000 UTC m=+164871.165349008: ☑️ agreed by Leavrth.
  • 2024-10-18 03:49:22.569560308 +0000 UTC m=+588559.718470140: ☑️ agreed by 3pointer.

@YuJuncen
Copy link
Contributor Author

/test check-dev

Copy link

tiprow bot commented Oct 20, 2024

@YuJuncen: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test fast_test_tiprow_ddlargsv1
  • /test tidb_parser_test

Use /test all to run the following jobs that were automatically triggered:

  • fast_test_tiprow
  • tidb_parser_test

In response to this:

/test check-dev

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
Copy link
Contributor Author

/retest-required

@ti-chi-bot ti-chi-bot bot merged commit 64c8d31 into pingcap:master Oct 21, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved 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.
3 participants