tidb: github.com/pingcap/tidb/domain Index | Files

package domain

import "github.com/pingcap/tidb/domain"

Index

Package Files

domain.go domainctx.go global_vars_cache.go info.go schema_checker.go schema_validator.go topn_slow_query.go

Constants

const (
    // ResultSucc means schemaValidator's check is passing.
    ResultSucc checkResult = iota
    // ResultFail means schemaValidator's check is fail.
    ResultFail
    // ResultUnknown means schemaValidator doesn't know the check would be success or fail.
    ResultUnknown
)
const (
    // ServerInformationPath store server information such as IP, port and so on.
    ServerInformationPath = "/tidb/server/info"
)

Variables

var (
    // ErrInfoSchemaExpired returns the error that information schema is out of date.
    ErrInfoSchemaExpired = terror.ClassDomain.New(codeInfoSchemaExpired, "Information schema is out of date.")
    // ErrInfoSchemaChanged returns the error that information schema is changed.
    ErrInfoSchemaChanged = terror.ClassDomain.New(codeInfoSchemaChanged,
        "Information schema is changed. "+kv.TxnRetryableMark)
)
var (
    // SchemaOutOfDateRetryInterval is the backoff time before retrying.
    SchemaOutOfDateRetryInterval = int64(500 * time.Millisecond)
    // SchemaOutOfDateRetryTimes is the max retry count when the schema is out of date.
    SchemaOutOfDateRetryTimes = int32(10)
)
var InfoSessionTTL = 1 * 60

InfoSessionTTL is the etcd session's TTL in seconds. It's exported for testing.

var RunAutoAnalyze = true

RunAutoAnalyze indicates if this TiDB server starts auto analyze worker and can run auto analyze job.

func BindDomain Uses

func BindDomain(ctx sessionctx.Context, domain *Domain)

BindDomain binds domain to context.

type Domain Uses

type Domain struct {
    SchemaValidator SchemaValidator
    // contains filtered or unexported fields
}

Domain represents a storage space. Different domains can use the same database name. Multiple domains can be used in parallel without synchronization.

func GetDomain Uses

func GetDomain(ctx sessionctx.Context) *Domain

GetDomain gets domain from context.

func NewDomain Uses

func NewDomain(store kv.Storage, ddlLease time.Duration, statsLease time.Duration, factory pools.Factory) *Domain

NewDomain creates a new domain. Should not create multiple domains for the same store.

func (*Domain) BindHandle Uses

func (do *Domain) BindHandle() *bindinfo.BindHandle

BindHandle returns domain's bindHandle.

func (*Domain) Close Uses

func (do *Domain) Close()

Close closes the Domain and release its resource.

func (*Domain) CreateStatsHandle Uses

func (do *Domain) CreateStatsHandle(ctx sessionctx.Context)

CreateStatsHandle is used only for test.

func (*Domain) DDL Uses

func (do *Domain) DDL() ddl.DDL

DDL gets DDL from domain.

func (*Domain) ExpensiveQueryHandle Uses

func (do *Domain) ExpensiveQueryHandle() *expensivequery.Handle

ExpensiveQueryHandle returns the expensive query handle.

func (*Domain) GetEtcdClient Uses

func (do *Domain) GetEtcdClient() *clientv3.Client

GetEtcdClient returns the etcd client.

func (*Domain) GetGlobalVarsCache Uses

func (do *Domain) GetGlobalVarsCache() *GlobalVariableCache

GetGlobalVarsCache gets the global variable cache.

func (*Domain) GetScope Uses

func (do *Domain) GetScope(status string) variable.ScopeFlag

GetScope gets the status variables scope.

func (*Domain) GetSnapshotInfoSchema Uses

func (do *Domain) GetSnapshotInfoSchema(snapshotTS uint64) (infoschema.InfoSchema, error)

GetSnapshotInfoSchema gets a snapshot information schema.

func (*Domain) GetSnapshotMeta Uses

func (do *Domain) GetSnapshotMeta(startTS uint64) (*meta.Meta, error)

GetSnapshotMeta gets a new snapshot meta at startTS.

func (*Domain) InfoSchema Uses

func (do *Domain) InfoSchema() infoschema.InfoSchema

InfoSchema gets information schema from domain.

func (*Domain) InfoSyncer Uses

func (do *Domain) InfoSyncer() *InfoSyncer

InfoSyncer gets infoSyncer from domain.

func (*Domain) Init Uses

func (do *Domain) Init(ddlLease time.Duration, sysFactory func(*Domain) (pools.Resource, error)) error

Init initializes a domain.

func (*Domain) InitExpensiveQueryHandle Uses

func (do *Domain) InitExpensiveQueryHandle()

InitExpensiveQueryHandle init the expensive query handler.

func (*Domain) LoadBindInfoLoop Uses

func (do *Domain) LoadBindInfoLoop(ctx sessionctx.Context) error

LoadBindInfoLoop create a goroutine loads BindInfo in a loop, it should be called only once in BootstrapSession.

func (*Domain) LoadPrivilegeLoop Uses

func (do *Domain) LoadPrivilegeLoop(ctx sessionctx.Context) error

LoadPrivilegeLoop create a goroutine loads privilege tables in a loop, it should be called only once in BootstrapSession.

func (*Domain) LogSlowQuery Uses

func (do *Domain) LogSlowQuery(query *SlowQueryInfo)

LogSlowQuery keeps topN recent slow queries in domain.

func (*Domain) NotifyUpdatePrivilege Uses

func (do *Domain) NotifyUpdatePrivilege(ctx sessionctx.Context)

NotifyUpdatePrivilege updates privilege key in etcd, TiDB client that watches the key will get notification.

func (*Domain) PrivilegeHandle Uses

func (do *Domain) PrivilegeHandle() *privileges.Handle

PrivilegeHandle returns the MySQLPrivilege.

func (*Domain) Reload Uses

func (do *Domain) Reload() error

Reload reloads InfoSchema. It's public in order to do the test.

func (*Domain) SetStatsUpdating Uses

func (do *Domain) SetStatsUpdating(val bool)

SetStatsUpdating sets the value of stats updating.

func (*Domain) ShowSlowQuery Uses

func (do *Domain) ShowSlowQuery(showSlow *ast.ShowSlow) []*SlowQueryInfo

ShowSlowQuery returns the slow queries.

func (*Domain) StatsHandle Uses

func (do *Domain) StatsHandle() *handle.Handle

StatsHandle returns the statistic handle.

func (*Domain) StatsUpdating Uses

func (do *Domain) StatsUpdating() bool

StatsUpdating checks if the stats worker is updating.

func (*Domain) Store Uses

func (do *Domain) Store() kv.Storage

Store gets KV store from domain.

func (*Domain) SysSessionPool Uses

func (do *Domain) SysSessionPool() *sessionPool

SysSessionPool returns the system session pool.

func (*Domain) UpdateTableStatsLoop Uses

func (do *Domain) UpdateTableStatsLoop(ctx sessionctx.Context) error

UpdateTableStatsLoop creates a goroutine loads stats info and updates stats info in a loop. It will also start a goroutine to analyze tables automatically. It should be called only once in BootstrapSession.

type GlobalVariableCache Uses

type GlobalVariableCache struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

GlobalVariableCache caches global variables.

func (*GlobalVariableCache) Disable Uses

func (gvc *GlobalVariableCache) Disable()

Disable disables the global variabe cache, used in test only.

func (*GlobalVariableCache) Get Uses

func (gvc *GlobalVariableCache) Get() (succ bool, rows []chunk.Row, fields []*ast.ResultField)

Get gets the global variables from cache.

func (*GlobalVariableCache) Update Uses

func (gvc *GlobalVariableCache) Update(rows []chunk.Row, fields []*ast.ResultField)

Update updates the global variable cache.

type InfoSyncer Uses

type InfoSyncer struct {
    // contains filtered or unexported fields
}

InfoSyncer stores server info to etcd when the tidb-server starts and delete when tidb-server shuts down.

func NewInfoSyncer Uses

func NewInfoSyncer(id string, etcdCli *clientv3.Client) *InfoSyncer

NewInfoSyncer return new InfoSyncer. It is exported for testing.

func (InfoSyncer) Done Uses

func (is InfoSyncer) Done() <-chan struct{}

Done returns a channel that closes when the info syncer is no longer being refreshed.

func (*InfoSyncer) GetAllServerInfo Uses

func (is *InfoSyncer) GetAllServerInfo(ctx context.Context) (map[string]*ServerInfo, error)

GetAllServerInfo gets all servers static information from etcd.

func (*InfoSyncer) GetServerInfo Uses

func (is *InfoSyncer) GetServerInfo() *ServerInfo

GetServerInfo gets self server static information.

func (*InfoSyncer) GetServerInfoByID Uses

func (is *InfoSyncer) GetServerInfoByID(ctx context.Context, id string) (*ServerInfo, error)

GetServerInfoByID gets server static information from etcd.

func (*InfoSyncer) Init Uses

func (is *InfoSyncer) Init(ctx context.Context) error

Init creates a new etcd session and stores server info to etcd.

func (*InfoSyncer) RemoveServerInfo Uses

func (is *InfoSyncer) RemoveServerInfo()

RemoveServerInfo remove self server static information from etcd.

func (*InfoSyncer) Restart Uses

func (is *InfoSyncer) Restart(ctx context.Context) error

Restart restart the info syncer with new session leaseID and store server info to etcd again.

type SchemaChecker Uses

type SchemaChecker struct {
    SchemaValidator
    // contains filtered or unexported fields
}

SchemaChecker is used for checking schema-validity.

func NewSchemaChecker Uses

func NewSchemaChecker(do *Domain, schemaVer int64, relatedTableIDs []int64) *SchemaChecker

NewSchemaChecker creates a new schema checker.

func (*SchemaChecker) Check Uses

func (s *SchemaChecker) Check(txnTS uint64) error

Check checks the validity of the schema version.

type SchemaValidator Uses

type SchemaValidator interface {
    // Update the schema validator, add a new item, delete the expired deltaSchemaInfos.
    // The latest schemaVer is valid within leaseGrantTime plus lease duration.
    // Add the changed table IDs to the new schema information,
    // which is produced when the oldSchemaVer is updated to the newSchemaVer.
    Update(leaseGrantTime uint64, oldSchemaVer, newSchemaVer int64, changedTableIDs []int64)
    // Check is it valid for a transaction to use schemaVer and related tables, at timestamp txnTS.
    Check(txnTS uint64, schemaVer int64, relatedTableIDs []int64) checkResult
    // Stop stops checking the valid of transaction.
    Stop()
    // Restart restarts the schema validator after it is stopped.
    Restart()
    // Reset resets SchemaValidator to initial state.
    Reset()
    // IsStarted indicates whether SchemaValidator is started.
    IsStarted() bool
}

SchemaValidator is the interface for checking the validity of schema version.

func NewSchemaValidator Uses

func NewSchemaValidator(lease time.Duration) SchemaValidator

NewSchemaValidator returns a SchemaValidator structure.

type ServerInfo Uses

type ServerInfo struct {
    ServerVersionInfo
    ID         string `json:"ddl_id"`
    IP         string `json:"ip"`
    Port       uint   `json:"listening_port"`
    StatusPort uint   `json:"status_port"`
    Lease      string `json:"lease"`
}

ServerInfo is server static information. It will not be updated when tidb-server running. So please only put static information in ServerInfo struct.

type ServerVersionInfo Uses

type ServerVersionInfo struct {
    Version string `json:"version"`
    GitHash string `json:"git_hash"`
}

ServerVersionInfo is the server version and git_hash.

type SlowQueryInfo Uses

type SlowQueryInfo struct {
    SQL        string
    Start      time.Time
    Duration   time.Duration
    Detail     execdetails.ExecDetails
    ConnID     uint64
    TxnTS      uint64
    User       string
    DB         string
    TableIDs   string
    IndexNames string
    Digest     string
    Internal   bool
    Succ       bool
}

SlowQueryInfo is a struct to record slow query info.

Package domain imports 48 packages (graph) and is imported by 120 packages. Updated 2019-09-16. Refresh now. Tools for package owners.