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: resolve stuck in backup #54736

Merged
merged 6 commits into from
Aug 13, 2024
Merged

Conversation

Leavrth
Copy link
Contributor

@Leavrth Leavrth commented Jul 18, 2024

What problem does this PR solve?

Issue Number: close #53480

Problem Summary:
backup br stuck waiting for any response from TiKV

What changed and how does it work?

  1. Add a timeout for each response, and if timeout, the context will be canceled.
  2. Refresh the timeout if any response arrives.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
type MockBackupServer struct {
	backuppb.BackupServer
}

func (mbs *MockBackupServer) Backup(req *backuppb.BackupRequest, server backuppb.Backup_BackupServer) error {
	time.Sleep(30 * time.Second)
	return nil
}

func TestReal(t *testing.T) {
	lis, err := net.Listen("tcp", ":12345")
	require.NoError(t, err)

	s := grpc.NewServer()

	backuppb.RegisterBackupServer(s, &MockBackupServer{})
	t.Logf("server listening at %v", lis.Addr())

	var wg sync.WaitGroup
	wg.Add(1)
	go func() {
		defer wg.Done()
		err := s.Serve(lis)
		require.NoError(t, err)
	}()

	testClient(t, lis.Addr().String())

	s.Stop()
	wg.Wait()
}

func testClient(t *testing.T, addr string) {
	ctx := context.Background()
	TIMEOUT_ONE_RESPONSE = 20 * time.Second
	bfConf := backoff.DefaultConfig
	bfConf.MaxDelay = time.Second * 3
	conn, err := grpc.DialContext(
		ctx, addr,
		grpc.WithTransportCredentials(insecure.NewCredentials()),
		grpc.WithBlock(),
		grpc.WithConnectParams(grpc.ConnectParams{Backoff: bfConf}),
		grpc.WithKeepaliveParams(keepalive.ClientParameters{
			Time:    3 * time.Second,
			Timeout: 10 * time.Second,
		}),
	)
	require.NoError(t, err)

	err = doSendBackup(ctx, backuppb.NewBackupClient(conn), backuppb.BackupRequest{}, func(br *backuppb.BackupResponse) error { return nil })
	require.NoError(t, err)
}
[2024/07/18 16:27:40.619 +08:00] [WARN] [store.go:97] ["receive a backup response timeout"]
--- FAIL: TestReal (20.00s)
    /root/tidb/br/pkg/backup/store_test.go:112: server listening at [::]:12345
    /root/tidb/br/pkg/backup/store_test.go:148: 
        	Error Trace:	/root/tidb/br/pkg/backup/store_test.go:148
        	            				/root/tidb/br/pkg/backup/store_test.go:122
        	Error:      	Received unexpected error:
        	            	rpc error: code = Canceled desc = context canceled
        	Test:       	TestReal
FAIL
FAIL	github.com/pingcap/tidb/br/pkg/backup	21.130s
FAIL
  • 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: Jianjun Liao <[email protected]>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 18, 2024
Copy link

tiprow bot commented Jul 18, 2024

Hi @Leavrth. 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 Jul 18, 2024

Codecov Report

Attention: Patch coverage is 97.36842% with 1 line in your changes missing coverage. Please review.

Project coverage is 75.4506%. Comparing base (b41ad70) to head (5083f50).
Report is 247 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #54736        +/-   ##
================================================
+ Coverage   72.8073%   75.4506%   +2.6433%     
================================================
  Files          1558       1606        +48     
  Lines        438397     476925     +38528     
================================================
+ Hits         319185     359843     +40658     
+ Misses        99609      95270      -4339     
- Partials      19603      21812      +2209     
Flag Coverage Δ
integration 50.6548% <84.2105%> (?)
unit 71.9014% <97.3684%> (+0.0880%) ⬆️

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

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 61.8538% <97.3684%> (+15.9562%) ⬆️

Copy link
Contributor

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

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 12, 2024
Copy link

ti-chi-bot bot commented Aug 13, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Aug 13, 2024
Copy link

ti-chi-bot bot commented Aug 13, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-12 08:40:32.400870394 +0000 UTC m=+170917.104340040: ☑️ agreed by YuJuncen.
  • 2024-08-13 06:15:19.382867806 +0000 UTC m=+248604.086337449: ☑️ agreed by 3pointer.

Signed-off-by: Jianjun Liao <[email protected]>
Signed-off-by: Jianjun Liao <[email protected]>
@Leavrth
Copy link
Contributor Author

Leavrth commented Aug 13, 2024

/ok-to-test

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

tiprow bot commented Aug 13, 2024

@Leavrth: 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
tidb_parser_test 5083f50 link true /test tidb_parser_test
fast_test_tiprow 5083f50 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.

@ti-chi-bot ti-chi-bot bot merged commit d04299e into pingcap:master Aug 13, 2024
25 of 28 checks passed
@BornChanger BornChanger added needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. labels Aug 14, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Aug 14, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #55403.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #55404.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Aug 14, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Aug 14, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #55405.

@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. label Aug 26, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Aug 26, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #55657.

ti-chi-bot bot pushed a commit that referenced this pull request Sep 2, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Sep 25, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Nov 7, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

backup br stuck waiting for any response from TiKV
5 participants