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/restore: use a more relax check for changefeeds when restoring #53121

Merged
merged 9 commits into from May 15, 2024

Conversation

YuJuncen
Copy link
Contributor

@YuJuncen YuJuncen commented May 9, 2024

What problem does this PR solve?

Issue Number: close #53131

Problem Summary:
In the current version, we will reject to restore once there is any changefeed.
This is too strict and not pretty friendly to the end user.

What changed and how does it work?

For now, we will only reject to restore when the changefeed:

  • Have a checkpoint earlier than the backup time for this restore.
  • Is not failed.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  1. Create such a changefeed:
function run
  changefeedctl create --sink-uri=blackhole:// --no-confirm -c $argv[1] --start-ts (pdctl service-gc-safepoint | jq .gc_safe_point)
  changefeedctl pause -c $argv[1]
end
run test
  1. Backup the cluster with:
./br backup full -s (s3path tpcc-10)
  1. Then, restore the backup, should fail:
root@xanadu ~/op# ./br restore full -s (s3path tpcc-10)
Detail BR log in /tmp/br.log.2024-05-09T14.17.38+0800
[2024/05/09 14:17:42.087 +08:00] [INFO] [collector.go:77] ["Full Restore failed summary"] [total-ranges=0] [ranges-succeed=0] [ranges-failed=0]
Error: found CDC changefeed(s): cluster/namespace: default/default changefeed(s): [test], please remove changefeed(s) before restore
  1. Resume the changefeed and wait it proceed.
changefeedctl resume -c test

5.Now the BR passed the CDC check (BR still fail due to we are trying to restore to the origin cluster, that is expected.)

root@xanadu ~/op# ./br restore full -s (s3path tpcc-10)
Detail BR log in /tmp/br.log.2024-05-09T14.23.18+0800
[2024/05/09 14:23:22.117 +08:00] [INFO] [collector.go:77] ["Full Restore failed summary"] [total-ranges=0] [ranges-succeed=0] [ranges-failed=0]
#######################################################################
# the target cluster is not fresh, cannot restore.
# you can drop existing databases and tables and start restore again
#######################################################################
Error: user db/tables: test, warehouse, district, customer, history, new_order, orders, order_line, stock, item: [BR:Restore:ErrRestoreNotFreshCluster]cluster is not fresh
  • No need to test
    • I checked and no code files have been changed.

Release note

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

Now, restore from an archive old enough won't be conflict with TiCDC changefeeds.

Signed-off-by: Yu Juncen <yu745514916@live.com>
Signed-off-by: Yu Juncen <yu745514916@live.com>
Signed-off-by: Yu Juncen <yu745514916@live.com>
Signed-off-by: Yu Juncen <yu745514916@live.com>
Signed-off-by: Yu Juncen <yu745514916@live.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 9, 2024
Copy link

tiprow bot commented May 9, 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.

Copy link

codecov bot commented May 9, 2024

Codecov Report

Attention: Patch coverage is 69.34307% with 42 lines in your changes are missing coverage. Please review.

Project coverage is 75.5631%. Comparing base (f304f04) to head (cbbd432).
Report is 56 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #53121        +/-   ##
================================================
+ Coverage   72.4716%   75.5631%   +3.0915%     
================================================
  Files          1491       1519        +28     
  Lines        429012     449567     +20555     
================================================
+ Hits         310912     339707     +28795     
+ Misses        98878      88682     -10196     
- Partials      19222      21178      +1956     
Flag Coverage Δ
integration 53.5457% <56.9343%> (?)
unit 71.2557% <63.9705%> (-0.1084%) ⬇️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 61.1969% <46.6666%> (+19.7534%) ⬆️

Signed-off-by: Yu Juncen <yu745514916@live.com>
… functions

Signed-off-by: Yu Juncen <yu745514916@live.com>
var changefeedMsgBuf strings.Builder
changefeedMsgBuf.WriteString("found CDC changefeed(s): ")
for clusterID, changefeedID := range s.changefeeds {
changefeedMsgBuf.WriteString("cluster/namespace: ")
Copy link
Member

Choose a reason for hiding this comment

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

namespace is a part of changefeed ID

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I'm going to try keep the old output format. Some of test cases rely on it.

}
switch info.State {
// https://docs.pingcap.com/zh/tidb/stable/ticdc-changefeed-overview
case "error", "failed":
Copy link
Member

Choose a reason for hiding this comment

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

error state still block gc, it's the same with warning

if err := json.Unmarshal(infoResp.Kvs[0].Value, &info); err != nil {
return 0, errors.Trace(err)
}
switch info.State {
Copy link
Member

Choose a reason for hiding this comment

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

ignore changefeeds in finished state

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

ti-chi-bot bot commented May 13, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-09 06:46:27.023852027 +0000 UTC m=+1117340.780987604: ☑️ agreed by sdojjy.
  • 2024-05-13 03:19:08.814865858 +0000 UTC m=+1450502.572001428: ☑️ agreed by Leavrth.

Copy link

ti-chi-bot bot commented May 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, Leavrth, sdojjy

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 May 15, 2024
@ti-chi-bot ti-chi-bot bot merged commit b9b330a into pingcap:master May 15, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make restore tolerates "safe" changefeeds exist
4 participants