Skip to content

Conversation

lance6716
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #60155

Problem Summary:

What changed and how does it work?

see original issue for more information

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/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. labels Apr 7, 2025
@lance6716 lance6716 requested a review from Copilot April 7, 2025 03:09
@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 7, 2025
Copy link

tiprow bot commented Apr 7, 2025

Hi @lance6716. 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

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

br/pkg/storage/gcs.go:370

  • Potential nil pointer dereference: ensure that s.clientCancel is non-nil before calling it in Close() to prevent runtime panic.
s.clientCancel()

br/pkg/storage/gcs.go:462

  • [nitpick] Consider refactoring the custom cancellation logic in Reset(). Instead of using context.Background() with a goroutine and a done channel to propagate cancellation, use context.WithCancel(ctx) to automatically inherit cancellation from the provided context.
go func() {

@lance6716 lance6716 requested a review from BornChanger April 7, 2025 03:09
Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 52.50000% with 19 lines in your changes missing coverage. Please review.

Project coverage is 74.8519%. Comparing base (867f8ed) to head (643ebce).
Report is 423 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #60402        +/-   ##
================================================
+ Coverage   73.1230%   74.8519%   +1.7289%     
================================================
  Files          1714       1760        +46     
  Lines        474566     482742      +8176     
================================================
+ Hits         347017     361342     +14325     
+ Misses       106225      98641      -7584     
- Partials      21324      22759      +1435     
Flag Coverage Δ
integration 48.7573% <50.0000%> (?)
unit 72.3221% <52.5000%> (-0.0188%) ⬇️

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

Components Coverage Δ
dumpling 52.6553% <ø> (ø)
parser ∅ <ø> (∅)
br 62.3065% <52.5000%> (+15.0546%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lance6716 lance6716 requested a review from Leavrth April 7, 2025 03:34
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 7, 2025
@lance6716 lance6716 requested a review from D3Hunter April 7, 2025 04:36
Copy link
Contributor

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

Comment on lines 459 to 484
clientCtx, clientCancel := context.WithCancel(context.Background())
done := make(chan struct{})
defer close(done)
go func() {
select {
case <-done:
case <-ctx.Done():
clientCancel()
}
}()

s.clients = make([]*storage.Client, gcsClientCnt)
eg, egCtx := util.NewErrorGroupWithRecoverWithCtx(ctx)
firstErr := atomic.NewError(nil)
wg := util.WaitGroupWrapper{}
for i := range s.clients {
eg.Go(func() error {
client, err := storage.NewClient(egCtx, s.clientOps...)
wg.RunWithLog(func() {
client, err := storage.NewClient(clientCtx, s.clientOps...)
if err != nil {
return errors.Trace(err)
firstErr.CompareAndSwap(nil, err)
clientCancel()
return
}
client.SetRetry(storage.WithErrorFunc(shouldRetry), storage.WithPolicy(storage.RetryAlways))
s.clients[i] = client
return nil
})
}
Copy link
Contributor

@D3Hunter D3Hunter Apr 10, 2025

Choose a reason for hiding this comment

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

maybe this one

	s.clients = make([]*storage.Client, 0, gcsClientCnt)
	wg := util.WaitGroupWrapper{}
	cliCh := make(chan *storage.Client)
	wg.RunWithLog(func() {
		for range gcsClientCnt {
			select {
			case cli := <-cliCh:
				s.clients = append(s.clients, cli)
			case <-ctx.Done():
				clientCancel()
				return
			case <-clientCtx.Done():
				return
			}
		}
	})
	firstErr := atomic.NewError(nil)
	for range gcsClientCnt {
		wg.RunWithLog(func() {
			client, err := storage.NewClient(clientCtx, s.clientOps...)
			if err != nil {
				firstErr.CompareAndSwap(nil, err)
				clientCancel()
				return
			}
			client.SetRetry(storage.WithErrorFunc(shouldRetry), storage.WithPolicy(storage.RetryAlways))
			select {
			case cliCh <- client:
			case <-clientCtx.Done():
			}
		})
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@D3Hunter I didn't get your point. Do you want to avoid the ugly code? ⬇️

	done := make(chan struct{})
	defer close(done)
	go func() {
		select {
		case <-done:
		case <-ctx.Done():
			clientCancel()
		}
	}()

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, the done channel is not needed, and I want the routine managed by waitGroup

Copy link

ti-chi-bot bot commented Apr 10, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, 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 Apr 10, 2025
Copy link

ti-chi-bot bot commented Apr 10, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-04-07 03:54:10.183475114 +0000 UTC m=+2055743.867711209: ☑️ agreed by Leavrth.
  • 2025-04-10 11:57:26.432526774 +0000 UTC m=+2343940.116762869: ☑️ agreed by D3Hunter.

@D3Hunter
Copy link
Contributor

/hold

feel free to unhold

@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 Apr 10, 2025
Signed-off-by: lance6716 <[email protected]>
@lance6716
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Apr 10, 2025
@lance6716
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 11, 2025

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

@kennytm
Copy link
Contributor

kennytm commented Apr 11, 2025

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Apr 11, 2025
@Benjamin2037 Benjamin2037 added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Apr 11, 2025
@Benjamin2037
Copy link
Collaborator

/retest

@kennytm
Copy link
Contributor

kennytm commented Apr 11, 2025

/retest

@ti-chi-bot ti-chi-bot bot merged commit 7424255 into pingcap:master Apr 11, 2025
31 checks passed
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 11, 2025
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #60502.
But this PR has conflicts, please resolve them!

@ti-chi-bot ti-chi-bot bot removed the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Apr 11, 2025
zeminzhou pushed a commit to zeminzhou/tidb that referenced this pull request May 6, 2025
@Benjamin2037 Benjamin2037 added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label May 14, 2025
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 14, 2025
@ti-chi-bot

This comment was marked as duplicate.

@Benjamin2037 Benjamin2037 added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Jun 23, 2025
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jun 23, 2025
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #61919.
But this PR has conflicts, please resolve them!

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-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 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.

Any GCS Storage operation authenticating using external account (workload identity federation) will fail with "context canceled"
6 participants