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

client/router: implement the query region gRPC client #8939

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JmPotato
Copy link
Member

What problem does this PR solve?

Issue Number: ref #8690.

What is changed and how does it work?

Implement the router stream update logic.

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

@JmPotato JmPotato added the component/client Client logic. label Dec 19, 2024
Copy link
Contributor

ti-chi-bot bot commented Dec 19, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@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. release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. labels Dec 19, 2024
Copy link
Contributor

ti-chi-bot bot commented Dec 19, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from jmpotato, ensuring that each of them provides their approval before proceeding. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 19, 2024
@JmPotato JmPotato force-pushed the query_region branch 2 times, most recently from 8e258ea to 292cdf2 Compare January 8, 2025 05:26
@JmPotato JmPotato changed the title client/router: implement the stream update logic client/router: implement the query region gRPC client Jan 8, 2025
@JmPotato JmPotato marked this pull request as ready for review January 8, 2025 05:27
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 8, 2025
@JmPotato JmPotato force-pushed the query_region branch 3 times, most recently from 59c7dbe to 48ff881 Compare January 22, 2025 03:50
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 61.82796% with 142 lines in your changes missing coverage. Please review.

Project coverage is 76.21%. Comparing base (6cadbe7) to head (a84d793).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8939      +/-   ##
==========================================
- Coverage   76.25%   76.21%   -0.05%     
==========================================
  Files         466      468       +2     
  Lines       70733    71087     +354     
==========================================
+ Hits        53938    54176     +238     
- Misses      13437    13525      +88     
- Partials     3358     3386      +28     
Flag Coverage Δ
unittests 76.21% <61.82%> (-0.05%) ⬇️

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

@JmPotato JmPotato force-pushed the query_region branch 2 times, most recently from 4b253eb to 46fd376 Compare January 22, 2025 07:36
option: option,
conCtxMgr: cctx.NewManager[pdpb.PD_QueryRegionClient](),
updateConnectionCh: make(chan struct{}, 1),
bo: retry.InitialBackoffer(
Copy link
Member

Choose a reason for hiding this comment

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

need to update

// Before Go 1.23, the only safe way to use Reset was to call Timer.Stop and explicitly drain the timer first.
// We need be careful here, see more details in the comments of Timer.Reset.
// https://pkg.go.dev/time@master#Timer.Reset
func SafeResetTimer(t *time.Timer, d time.Duration) {
Copy link
Member

Choose a reason for hiding this comment

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

We no longer need it.

leaderURL atomic.Value
// conCtxMgr is used to store the context of the router stream connection(s).
conCtxMgr *cctx.Manager[pdpb.PD_QueryRegionClient]
// updateConnectionCh is used to trigger the connection update actively.
Copy link
Member

Choose a reason for hiding this comment

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

Should updateConnectionCh be part of conCtxMgr?

@@ -36,6 +36,7 @@ import (
"github.com/stretchr/testify/suite"
clientv3 "go.etcd.io/etcd/client/v3"
"go.uber.org/goleak"
"golang.org/x/exp/rand"
Copy link
Member

Choose a reason for hiding this comment

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

Shall we use math/rand?

requestCtx context.Context
clientCtx context.Context

key []byte
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to add some comments here, since the three fields represent three different requests? They cannot have values for a single request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/client Client logic. dco-signoff: yes Indicates the PR's author has signed the dco. 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.

2 participants