Skip to content
Permalink
Browse files

*: add config item for bind info lease (#10725)

  • Loading branch information...
lamxTyler authored and XuHuaiyu committed Jun 5, 2019
1 parent 1fb0e97 commit 54e48948d4024ddd3863512e74e4006697c1a340
Showing with 13 additions and 5 deletions.
  1. +3 −0 bindinfo/handle.go
  2. +2 −0 config/config.go
  3. +3 −0 config/config.toml.example
  4. +3 −5 domain/domain.go
  5. +2 −0 tidb-server/main.go
@@ -72,6 +72,9 @@ type BindHandle struct {
lastUpdateTime types.Time
}

// Lease influences the duration of loading bind info and handling invalid bind.
var Lease = 3 * time.Second

type invalidBindRecordMap struct {
bindRecord *BindRecord
droppedTime time.Time
@@ -187,6 +187,7 @@ type Performance struct {
QueryFeedbackLimit uint `toml:"query-feedback-limit" json:"query-feedback-limit"`
PseudoEstimateRatio float64 `toml:"pseudo-estimate-ratio" json:"pseudo-estimate-ratio"`
ForcePriority string `toml:"force-priority" json:"force-priority"`
BindInfoLease string `toml:"bind-info-lease" json:"bind-info-lease"`
}

// PlanCache is the PlanCache section of the config.
@@ -352,6 +353,7 @@ var defaultConf = Config{
QueryFeedbackLimit: 1024,
PseudoEstimateRatio: 0.8,
ForcePriority: "NO_PRIORITY",
BindInfoLease: "3s",
},
ProxyProtocol: ProxyProtocol{
Networks: "",
@@ -168,6 +168,9 @@ pseudo-estimate-ratio = 0.8
# The value could be "NO_PRIORITY", "LOW_PRIORITY", "HIGH_PRIORITY" or "DELAYED".
force-priority = "NO_PRIORITY"

# Bind info lease duration, which influences the duration of loading bind info and handling invalid bind.
bind-info-lease = "3s"

[proxy-protocol]
# PROXY protocol acceptable client networks.
# Empty string means disable PROXY protocol, * means all networks.
@@ -794,7 +794,7 @@ func (do *Domain) LoadBindInfoLoop(ctx sessionctx.Context) error {
ctx.GetSessionVars().InRestrictedSQL = true
do.bindHandle = bindinfo.NewBindHandle(ctx)
err := do.bindHandle.Update(true)
if err != nil {
if err != nil || bindinfo.Lease == 0 {
return err
}

@@ -804,7 +804,6 @@ func (do *Domain) LoadBindInfoLoop(ctx sessionctx.Context) error {
}

func (do *Domain) loadBindInfoLoop() {
duration := 3 * time.Second
do.wg.Add(1)
go func() {
defer do.wg.Done()
@@ -813,7 +812,7 @@ func (do *Domain) loadBindInfoLoop() {
select {
case <-do.exit:
return
case <-time.After(duration):
case <-time.After(bindinfo.Lease):
}
err := do.bindHandle.Update(false)
if err != nil {
@@ -824,7 +823,6 @@ func (do *Domain) loadBindInfoLoop() {
}

func (do *Domain) handleInvalidBindTaskLoop() {
handleInvalidTaskDuration := 3 * time.Second
do.wg.Add(1)
go func() {
defer do.wg.Done()
@@ -833,7 +831,7 @@ func (do *Domain) handleInvalidBindTaskLoop() {
select {
case <-do.exit:
return
case <-time.After(handleInvalidTaskDuration):
case <-time.After(bindinfo.Lease):
}
do.bindHandle.DropInvalidBindRecord()
}
@@ -30,6 +30,7 @@ import (
"github.com/pingcap/parser/terror"
"github.com/pingcap/pd/client"
pumpcli "github.com/pingcap/tidb-tools/tidb-binlog/pump_client"
"github.com/pingcap/tidb/bindinfo"
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/domain"
@@ -448,6 +449,7 @@ func setGlobalVars() {
runtime.GOMAXPROCS(int(cfg.Performance.MaxProcs))
statsLeaseDuration := parseDuration(cfg.Performance.StatsLease)
session.SetStatsLease(statsLeaseDuration)
bindinfo.Lease = parseDuration(cfg.Performance.BindInfoLease)
domain.RunAutoAnalyze = cfg.Performance.RunAutoAnalyze
statistics.FeedbackProbability.Store(cfg.Performance.FeedbackProbability)
handle.MaxQueryFeedbackCount.Store(int64(cfg.Performance.QueryFeedbackLimit))

0 comments on commit 54e4894

Please sign in to comment.
You can’t perform that action at this time.