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

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

Merged
merged 1 commit into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions bindinfo/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -352,6 +353,7 @@ var defaultConf = Config{
QueryFeedbackLimit: 1024,
PseudoEstimateRatio: 0.8,
ForcePriority: "NO_PRIORITY",
BindInfoLease: "3s",
},
ProxyProtocol: ProxyProtocol{
Networks: "",
Expand Down
3 changes: 3 additions & 0 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 3 additions & 5 deletions domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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()
Expand All @@ -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 {
Expand All @@ -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()
Expand All @@ -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()
}
Expand Down
2 changes: 2 additions & 0 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
Expand Down