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: copy full backup to pitr storage #57716

Merged
merged 81 commits into from
Jan 16, 2025

Conversation

YuJuncen
Copy link
Contributor

@YuJuncen YuJuncen commented Nov 26, 2024

What problem does this PR solve?

Issue Number: close #58685

Problem Summary:
Now, a log backup task cannot back full restorations happen in the cluster up.

What changed and how does it work?

This PR makes BR upload the SSTs it imported to the log backup storage.

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

Signed-off-by: hillium <yujuncen@pingcap.com>
Signed-off-by: hillium <yujuncen@pingcap.com>
Signed-off-by: hillium <yujuncen@pingcap.com>
@YuJuncen YuJuncen marked this pull request as draft November 26, 2024 09:50
@ti-chi-bot ti-chi-bot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 26, 2024
Copy link

tiprow bot commented Nov 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.

@BornChanger
Copy link
Contributor

/retest

Copy link

tiprow bot commented Jan 15, 2025

@BornChanger: 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.

@pingcap pingcap deleted a comment from tiprow bot Jan 15, 2025
@@ -0,0 +1,487 @@
package snapclient
Copy link
Contributor

Choose a reason for hiding this comment

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

missing license header?

@@ -0,0 +1,261 @@
package snapclient
Copy link
Contributor

Choose a reason for hiding this comment

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

missing license header?

Signed-off-by: hillium <yu745514916@live.com>
Copy link

ti-chi-bot bot commented Jan 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3pointer, BornChanger

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 Jan 15, 2025
Copy link

ti-chi-bot bot commented Jan 15, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-01-15 09:32:53.752043993 +0000 UTC m=+111045.207090143: ☑️ agreed by BornChanger.
  • 2025-01-15 14:36:45.94279874 +0000 UTC m=+129277.397844889: ☑️ agreed by 3pointer.

Copy link

tiprow bot commented Jan 15, 2025

@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 50b70a4 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.

Signed-off-by: hillium <yu745514916@live.com>
@BornChanger
Copy link
Contributor

/retest

Copy link

tiprow bot commented Jan 15, 2025

@BornChanger: 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.

Copy link
Contributor

@Tristan1900 Tristan1900 left a comment

Choose a reason for hiding this comment

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

lgtm overall, just a bunch of nit comments

Subsystem: "br",
Name: "restore_import_file_seconds",

Help: "The time cost for importing a file. (including the time costed in queuing)",
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: cost is same for present and past tense.

collector.SetSuccessStatus(success)
}

// Succeed returns whether the last call to `SetSuccessStatus` passes `true`.
func Succeed() bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

typo? success

@@ -40,6 +40,7 @@ var (
ErrEnvNotSpecified = errors.Normalize("environment variable not found", errors.RFCCodeText("BR:Common:ErrEnvNotSpecified"))
ErrUnsupportedOperation = errors.Normalize("the operation is not supported", errors.RFCCodeText("BR:Common:ErrUnsupportedOperation"))
ErrInvalidRange = errors.Normalize("invalid restore range", errors.RFCCodeText("BR:Common:ErrInvalidRange"))
ErrMigrationNotFound = errors.Normalize("no migrtion found", errors.RFCCodeText("BR:Common:ErrMigrationNotFound"))
Copy link
Contributor

Choose a reason for hiding this comment

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

typo migrtion in error message

@@ -82,3 +83,22 @@ type Progress interface {
// called.
Close()
}

type CounterProgress struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like this is only used in test, should we move it to the test file instead?

@@ -55,6 +55,10 @@ type Glue struct {
startDomainMu *sync.Mutex
}

func WrapSession(se sessiontypes.Session) glue.Session {
Copy link
Contributor

Choose a reason for hiding this comment

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

also only used in test, should we move it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We cannot move this to test file because this function uses the private structure tidbSession. This function is somehow a public constructor of tidbSession.

@@ -98,6 +98,10 @@ func InitMetrics() {
InitInfoSchemaV2Metrics()
timermetrics.InitTimerMetrics()

// For now, those metrics are initialized but not registered.
Copy link
Contributor

Choose a reason for hiding this comment

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

it's a bit weird to print metrics instead of integrating it into the existing dashboard, is it because br cannot publish stats to prometheus?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, perhaps we need a Push Gateway... Raw Prometheus isn't pretty friendly to batch operations...

const JitterMs = 5000

retry := utils.InitialRetryState(math.MaxInt, 1*time.Second, 60*time.Second)
jitter := time.Duration(rand.Uint32()%JitterMs+(JitterMs/2)) * time.Millisecond
Copy link
Contributor

Choose a reason for hiding this comment

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

the jitter is a bit weird, looks like it's always going to be above 2500? I guess why don't we set jitter to be 2500 and just do rand.Uint32()%JitterMs

also can move this to a method in the retry module, feels like going to be needed in many case so don't need to rewrite the jitter calculation every time

@@ -242,3 +252,18 @@ func (wm *WithMigrations) Compactions(ctx context.Context, s storage.ExternalSto
return Subcompactions(ctx, name, s)
})
}

func (wm *WithMigrations) IngestedSSTs(ctx context.Context, s storage.ExternalStorage) iter.TryNextor[*backuppb.IngestedSSTs] {
Copy link
Contributor

Choose a reason for hiding this comment

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

one question, IDE has warning about the style

Struct WithMigrations has methods on both value and pointer receivers. Such usage is not recommended by the Go Documentation. 

and for many other structs as well. I'm wondering if we are doing impl for both on purpose or by accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of times are by accident. A typical scenario is that a structure was treated as value type (which has only value receivers) at the beginning, but with developing, we have noticed that sometimes it need to be a reference type (say, needing mutate its content by a method), then a method with pointer was added.

}
}

type pitrCollector struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

can add some comment to this struct since its logic is important to the whole feature.

s.SstOutputs = files
}

type AddedSSTs struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add some comment to this struct.
also from the logic looks like it represents one sst? can we drop the s in the name as it's suggesting the other way

Signed-off-by: hillium <yu745514916@live.com>
@YuJuncen
Copy link
Contributor Author

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 16, 2025
Signed-off-by: hillium <yu745514916@live.com>
@YuJuncen
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 16, 2025
Signed-off-by: hillium <yu745514916@live.com>
@ti-chi-bot ti-chi-bot bot merged commit c9215ec into pingcap:master Jan 16, 2025
29 checks passed
YuJuncen added a commit to YuJuncen/tidb that referenced this pull request Jan 16, 2025
@YuJuncen YuJuncen mentioned this pull request Jan 16, 2025
13 tasks
YuJuncen added a commit to YuJuncen/tidb that referenced this pull request Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm 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.

br: allow restore while log backup is enabled
4 participants