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

tikv: recheck kv status before invalidate region on sending fail (#16933) #16956

Merged
merged 4 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const (
DefPort = 4000
// DefStatusPort is the default status port of TiBD
DefStatusPort = 10080
// DefStoreLivenessTimeout is the default value for store liveness timeout.
DefStoreLivenessTimeout = "120s"
)

// Valid config maps
Expand Down Expand Up @@ -449,6 +451,8 @@ type TiKVClient struct {
// If a store has been up to the limit, it will return error for successive request to
// prevent the store occupying too much token in dispatching level.
StoreLimit int64 `toml:"store-limit" json:"store-limit"`
// StoreLivenessTimeout is the timeout for store liveness check request.
StoreLivenessTimeout string `toml:"store-liveness-timeout" json:"store-liveness-timeout"`

CoprCache CoprocessorCache `toml:"copr-cache" json:"copr-cache"`
}
Expand Down Expand Up @@ -627,8 +631,9 @@ var defaultConf = Config{

EnableChunkRPC: true,

RegionCacheTTL: 600,
StoreLimit: 0,
RegionCacheTTL: 600,
StoreLimit: 0,
StoreLivenessTimeout: DefStoreLivenessTimeout,

CoprCache: CoprocessorCache{
Enabled: true,
Expand Down
3 changes: 3 additions & 0 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ region-cache-ttl = 600
# default 0 means shutting off store limit.
store-limit = 0

# store-liveness-timeout is used to control timeout for store liveness after sending request failed.
store-liveness-timeout = "120s"

[tikv-client.copr-cache]
# Whether to enable the copr cache. The copr cache saves the result from TiKV Coprocessor in the memory and
# reuses the result when corresponding data in TiKV is unchanged, on a region basis.
Expand Down
2 changes: 2 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ func RegisterMetrics() {
prometheus.MustRegister(TotalCopProcHistogram)
prometheus.MustRegister(TotalCopWaitHistogram)
prometheus.MustRegister(TiKVPendingBatchRequests)
prometheus.MustRegister(TiKVStatusDuration)
prometheus.MustRegister(TiKVStatusCounter)
prometheus.MustRegister(TiKVBatchWaitDuration)
prometheus.MustRegister(TiKVBatchClientUnavailable)
prometheus.MustRegister(TiKVRangeTaskStats)
Expand Down
17 changes: 17 additions & 0 deletions metrics/tikvclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,23 @@ var (
Help: "Pending batch requests",
}, []string{"store"})

TiKVStatusDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "tikvclient",
Name: "kv_status_api_duration",
Help: "duration for kv status api.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 20), // 0.5ms ~ 262s
}, []string{"store"})

TiKVStatusCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "tikvclient",
Name: "kv_status_api_count",
Help: "Counter of access kv status api.",
}, []string{LblResult})

TiKVBatchWaitDuration = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Expand Down
Loading