Skip to content

Commit 8732f08

Browse files
Merge branch 'release-6.5' into cherry-pick-8632-to-release-6.5
2 parents 1a4fa89 + 4c786e6 commit 8732f08

File tree

9 files changed

+48
-17
lines changed

9 files changed

+48
-17
lines changed

Diff for: OWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ reviewers:
2222
- BusyJay
2323
- howardlau1999
2424
- Luffbee
25+
- okJiang
2526
- shafreeck
2627
- xhebox

Diff for: client/client.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,22 @@ func (c *client) handleDispatcher(
731731
if dc == globalDCLocation {
732732
go func() {
733733
var updateTicker = &time.Ticker{}
734-
setNewUpdateTicker := func(ticker *time.Ticker) {
734+
setNewUpdateTicker := func(interval time.Duration) {
735735
if updateTicker.C != nil {
736736
updateTicker.Stop()
737737
}
738-
updateTicker = ticker
738+
if interval == 0 {
739+
updateTicker = &time.Ticker{}
740+
} else {
741+
updateTicker = time.NewTicker(interval)
742+
}
743+
}
744+
// If the TSO Follower Proxy is enabled, set the update interval to the member update interval.
745+
if c.option.getEnableTSOFollowerProxy() {
746+
setNewUpdateTicker(memberUpdateInterval)
739747
}
740748
// Set to nil before returning to ensure that the existing ticker can be GC.
741-
defer setNewUpdateTicker(nil)
749+
defer setNewUpdateTicker(0)
742750

743751
for {
744752
select {
@@ -749,11 +757,11 @@ func (c *client) handleDispatcher(
749757
if enableTSOFollowerProxy && updateTicker.C == nil {
750758
// Because the TSO Follower Proxy is enabled,
751759
// the periodic check needs to be performed.
752-
setNewUpdateTicker(time.NewTicker(memberUpdateInterval))
760+
setNewUpdateTicker(memberUpdateInterval)
753761
} else if !enableTSOFollowerProxy && updateTicker.C != nil {
754762
// Because the TSO Follower Proxy is disabled,
755763
// the periodic check needs to be turned off.
756-
setNewUpdateTicker(&time.Ticker{})
764+
setNewUpdateTicker(0)
757765
} else {
758766
// The status of TSO Follower Proxy does not change, and updateConnectionCtxs is not triggered
759767
continue

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require (
3434
github.com/pingcap/kvproto v0.0.0-20230726063044-73d6d7f3756b
3535
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3
3636
github.com/pingcap/sysutil v0.0.0-20211208032423-041a72e5860d
37-
github.com/pingcap/tidb-dashboard v0.0.0-20240830072655-9d2b0ce603a1
37+
github.com/pingcap/tidb-dashboard v0.0.0-20241104063043-7d37156ca36a
3838
github.com/prometheus/client_golang v1.11.1
3939
github.com/prometheus/common v0.26.0
4040
github.com/sasha-s/go-deadlock v0.2.0

Diff for: go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8
396396
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
397397
github.com/pingcap/sysutil v0.0.0-20211208032423-041a72e5860d h1:k3/APKZjXOyJrFy8VyYwRlZhMelpD3qBLJNsw3bPl/g=
398398
github.com/pingcap/sysutil v0.0.0-20211208032423-041a72e5860d/go.mod h1:7j18ezaWTao2LHOyMlsc2Dg1vW+mDY9dEbPzVyOlaeM=
399-
github.com/pingcap/tidb-dashboard v0.0.0-20240830072655-9d2b0ce603a1 h1:otd51FMCCJiW7wagKABCeULfcZdMI+WCTH5N6emPGzY=
400-
github.com/pingcap/tidb-dashboard v0.0.0-20240830072655-9d2b0ce603a1/go.mod h1:ucZBRz52icb23T/5Z4CsuUHmarYiin7p2MeiVBe+o8c=
399+
github.com/pingcap/tidb-dashboard v0.0.0-20241104063043-7d37156ca36a h1:xgNUD3SRbZhR8+jWvslOfi6zHFJtI9QoS19awaftz9o=
400+
github.com/pingcap/tidb-dashboard v0.0.0-20241104063043-7d37156ca36a/go.mod h1:ucZBRz52icb23T/5Z4CsuUHmarYiin7p2MeiVBe+o8c=
401401
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e h1:FBaTXU8C3xgt/drM58VHxojHo/QoG1oPsgWTGvaSpO4=
402402
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
403403
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

Diff for: scripts/dashboard-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file is updated by running scripts/update-dashboard.sh
22
# Don't edit it manullay
3-
6.5.11-9d2b0ce6
3+
6.5.12-7d37156c

Diff for: server/grpc_service.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,18 @@ type tsoRequest struct {
227227
}
228228

229229
func (s *GrpcServer) dispatchTSORequest(ctx context.Context, request *tsoRequest, forwardedHost string, doneCh <-chan struct{}, errCh chan<- error) {
230-
tsoRequestChInterface, loaded := s.tsoDispatcher.LoadOrStore(forwardedHost, make(chan *tsoRequest, maxMergeTSORequests))
230+
val, loaded := s.tsoDispatcher.Load(forwardedHost)
231+
if !loaded {
232+
val = make(chan *tsoRequest, maxMergeTSORequests)
233+
val, loaded = s.tsoDispatcher.LoadOrStore(forwardedHost, val)
234+
}
235+
reqCh := val.(chan *tsoRequest)
231236
if !loaded {
232237
tsDeadlineCh := make(chan deadline, 1)
233-
go s.handleDispatcher(ctx, forwardedHost, tsoRequestChInterface.(chan *tsoRequest), tsDeadlineCh, doneCh, errCh)
238+
go s.handleDispatcher(ctx, forwardedHost, reqCh, tsDeadlineCh, doneCh, errCh)
234239
go watchTSDeadline(ctx, tsDeadlineCh)
235240
}
236-
tsoRequestChInterface.(chan *tsoRequest) <- request
241+
reqCh <- request
237242
}
238243

239244
func (s *GrpcServer) handleDispatcher(ctx context.Context, forwardedHost string, tsoRequestCh <-chan *tsoRequest, tsDeadlineCh chan<- deadline, doneCh <-chan struct{}, errCh chan<- error) {

Diff for: server/region_syncer/client.go

+19-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
const (
3939
keepaliveTime = 10 * time.Second
4040
keepaliveTimeout = 3 * time.Second
41+
retryInterval = time.Second
4142
)
4243

4344
// StopSyncWithLeader stop to sync the region with leader.
@@ -163,7 +164,15 @@ func (s *RegionSyncer) StartSyncWithLeader(addr string) {
163164
}
164165
}
165166
log.Error("server failed to establish sync stream with leader", zap.String("server", s.server.Name()), zap.String("leader", s.server.GetLeader().GetName()), errs.ZapError(err))
166-
time.Sleep(time.Second)
167+
timer := time.NewTimer(retryInterval)
168+
select {
169+
case <-ctx.Done():
170+
log.Info("stop synchronizing with leader due to context canceled")
171+
timer.Stop()
172+
return
173+
case <-timer.C:
174+
timer.Stop()
175+
}
167176
continue
168177
}
169178

@@ -175,7 +184,15 @@ func (s *RegionSyncer) StartSyncWithLeader(addr string) {
175184
if err = stream.CloseSend(); err != nil {
176185
log.Error("failed to terminate client stream", errs.ZapError(errs.ErrGRPCCloseSend, err))
177186
}
178-
time.Sleep(time.Second)
187+
timer := time.NewTimer(retryInterval)
188+
select {
189+
case <-ctx.Done():
190+
log.Info("stop synchronizing with leader due to context canceled")
191+
timer.Stop()
192+
return
193+
case <-timer.C:
194+
timer.Stop()
195+
}
179196
break
180197
}
181198
if s.history.GetNextIndex() != resp.GetStartIndex() {

Diff for: tests/client/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ require (
106106
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect
107107
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect
108108
github.com/pingcap/sysutil v0.0.0-20211208032423-041a72e5860d // indirect
109-
github.com/pingcap/tidb-dashboard v0.0.0-20240830072655-9d2b0ce603a1 // indirect
109+
github.com/pingcap/tidb-dashboard v0.0.0-20241104063043-7d37156ca36a // indirect
110110
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e // indirect
111111
github.com/pkg/errors v0.9.1 // indirect
112112
github.com/pmezard/go-difflib v1.0.0 // indirect

Diff for: tests/client/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8
349349
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
350350
github.com/pingcap/sysutil v0.0.0-20211208032423-041a72e5860d h1:k3/APKZjXOyJrFy8VyYwRlZhMelpD3qBLJNsw3bPl/g=
351351
github.com/pingcap/sysutil v0.0.0-20211208032423-041a72e5860d/go.mod h1:7j18ezaWTao2LHOyMlsc2Dg1vW+mDY9dEbPzVyOlaeM=
352-
github.com/pingcap/tidb-dashboard v0.0.0-20240830072655-9d2b0ce603a1 h1:otd51FMCCJiW7wagKABCeULfcZdMI+WCTH5N6emPGzY=
353-
github.com/pingcap/tidb-dashboard v0.0.0-20240830072655-9d2b0ce603a1/go.mod h1:ucZBRz52icb23T/5Z4CsuUHmarYiin7p2MeiVBe+o8c=
352+
github.com/pingcap/tidb-dashboard v0.0.0-20241104063043-7d37156ca36a h1:xgNUD3SRbZhR8+jWvslOfi6zHFJtI9QoS19awaftz9o=
353+
github.com/pingcap/tidb-dashboard v0.0.0-20241104063043-7d37156ca36a/go.mod h1:ucZBRz52icb23T/5Z4CsuUHmarYiin7p2MeiVBe+o8c=
354354
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e h1:FBaTXU8C3xgt/drM58VHxojHo/QoG1oPsgWTGvaSpO4=
355355
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
356356
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

0 commit comments

Comments
 (0)