Skip to content

Commit

Permalink
kv(ticdc): kv client should handle region congested error explicitly (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
3AceShowHand authored Sep 13, 2024
1 parent 5df797c commit e374334
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion cdc/kv/shared_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ var (
metricFeedRPCCtxUnavailable = eventFeedErrorCounter.WithLabelValues("RPCCtxUnavailable")
metricStoreSendRequestErr = eventFeedErrorCounter.WithLabelValues("SendRequestToStore")
metricKvIsBusyCounter = eventFeedErrorCounter.WithLabelValues("KvIsBusy")
metricKvCongestedCounter = eventFeedErrorCounter.WithLabelValues("KvCongested")
)

type eventError struct {
Expand Down Expand Up @@ -693,14 +694,19 @@ func (s *SharedClient) doHandleError(ctx context.Context, errInfo regionErrorInf
s.scheduleRangeRequest(ctx, errInfo.span, errInfo.subscribedTable)
return nil
}
if innerErr.GetCongested() != nil {
metricKvCongestedCounter.Inc()
s.scheduleRegionRequest(ctx, errInfo.regionInfo)
return nil
}
if innerErr.GetServerIsBusy() != nil {
metricKvIsBusyCounter.Inc()
s.scheduleRegionRequest(ctx, errInfo.regionInfo)
return nil
}
if duplicated := innerErr.GetDuplicateRequest(); duplicated != nil {
metricFeedDuplicateRequestCounter.Inc()
// TODO(qupeng): It's better to add a new machanism to deregister one region.
// TODO(qupeng): It's better to add a new mechanism to deregister one region.
return errors.New("duplicate request")
}
if compatibility := innerErr.GetCompatibility(); compatibility != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ require (
github.com/pingcap/check v0.0.0-20211026125417-57bd13f7b5f0
github.com/pingcap/errors v0.11.5-0.20240318064555-6bd07397691f
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
github.com/pingcap/kvproto v0.0.0-20240620063548-118a4cab53e4
github.com/pingcap/kvproto v0.0.0-20240911085438-1a933d30690a
github.com/pingcap/log v1.1.1-0.20240314023424-862ccc32f18d
github.com/pingcap/tidb v1.1.0-beta.0.20240722024203-504960d51b2a
github.com/pingcap/tidb-dashboard v0.0.0-20240326110213-9768844ff5d7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,8 @@ github.com/pingcap/fn v1.0.0/go.mod h1:u9WZ1ZiOD1RpNhcI42RucFh/lBuzTu6rw88a+oF2Z
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w=
github.com/pingcap/kvproto v0.0.0-20240620063548-118a4cab53e4 h1:6aIKNB2YGAec4IUDLw6G2eDECiGiufZcgEbZSCELBx0=
github.com/pingcap/kvproto v0.0.0-20240620063548-118a4cab53e4/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
github.com/pingcap/kvproto v0.0.0-20240911085438-1a933d30690a h1:idCAlcvP0yfaUsoY56HYstzoYDBLRmjMop78yz+WjXM=
github.com/pingcap/kvproto v0.0.0-20240911085438-1a933d30690a/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
Expand Down

0 comments on commit e374334

Please sign in to comment.