Documentation ¶
Index ¶
- Constants
- Variables
- func BindDomain(ctx sessionctx.Context, domain *Domain)
- type Domain
- func (do *Domain) BindHandle() *bindinfo.BindHandle
- func (do *Domain) Close()
- func (do *Domain) CreateStatsHandle(ctx sessionctx.Context)
- func (do *Domain) DDL() ddl.DDL
- func (do *Domain) ExpensiveQueryHandle() *expensivequery.Handle
- func (do *Domain) GetEtcdClient() *clientv3.Client
- func (do *Domain) GetGlobalVarsCache() *GlobalVariableCache
- func (do *Domain) GetScope(status string) variable.ScopeFlag
- func (do *Domain) GetSnapshotInfoSchema(snapshotTS uint64) (infoschema.InfoSchema, error)
- func (do *Domain) GetSnapshotMeta(startTS uint64) (*meta.Meta, error)
- func (do *Domain) InfoSchema() infoschema.InfoSchema
- func (do *Domain) InfoSyncer() *infosync.InfoSyncer
- func (do *Domain) Init(ddlLease time.Duration, sysFactory func(*Domain) (pools.Resource, error)) error
- func (do *Domain) InitExpensiveQueryHandle()
- func (do *Domain) LoadBindInfoLoop(ctxForHandle sessionctx.Context, ctxForEvolve sessionctx.Context) error
- func (do *Domain) LoadPrivilegeLoop(ctx sessionctx.Context) error
- func (do *Domain) LogSlowQuery(query *SlowQueryInfo)
- func (do *Domain) NotifyUpdatePrivilege(ctx sessionctx.Context)
- func (do *Domain) PrivilegeHandle() *privileges.Handle
- func (do *Domain) Reload() error
- func (do *Domain) SetStatsUpdating(val bool)
- func (do *Domain) ShowSlowQuery(showSlow *ast.ShowSlow) []*SlowQueryInfo
- func (do *Domain) StatsHandle() *handle.Handle
- func (do *Domain) StatsUpdating() bool
- func (do *Domain) Store() kv.Storage
- func (do *Domain) SysSessionPool() *sessionPool
- func (do *Domain) UpdateTableStatsLoop(ctx sessionctx.Context) error
- type GlobalVariableCache
- func (gvc *GlobalVariableCache) Disable()
- func (gvc *GlobalVariableCache) Get() (succ bool, rows []chunk.Row, fields []*ast.ResultField)
- func (gvc *GlobalVariableCache) LoadGlobalVariables(loadFn func() ([]chunk.Row, []*ast.ResultField, error)) ([]chunk.Row, []*ast.ResultField, error)
- func (gvc *GlobalVariableCache) Update(rows []chunk.Row, fields []*ast.ResultField)
- type SchemaChecker
- type SchemaValidator
- type SlowQueryInfo
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 )
Variables ¶
var ( // ErrInfoSchemaExpired returns the error that information schema is out of date. ErrInfoSchemaExpired = terror.ClassDomain.New(errno.ErrInfoSchemaExpired, errno.MySQLErrName[errno.ErrInfoSchemaExpired]) // ErrInfoSchemaChanged returns the error that information schema is changed. ErrInfoSchemaChanged = terror.ClassDomain.New(errno.ErrInfoSchemaChanged, errno.MySQLErrName[errno.ErrInfoSchemaChanged]+". "+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 RunAutoAnalyze = true
RunAutoAnalyze indicates if this TiDB server starts auto analyze worker and can run auto analyze job.
Functions ¶
func BindDomain ¶
func BindDomain(ctx sessionctx.Context, domain *Domain)
BindDomain binds domain to context.
Types ¶
type Domain ¶
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 NewDomain ¶
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 ¶
func (do *Domain) BindHandle() *bindinfo.BindHandle
BindHandle returns domain's bindHandle.
func (*Domain) CreateStatsHandle ¶
func (do *Domain) CreateStatsHandle(ctx sessionctx.Context)
CreateStatsHandle is used only for test.
func (*Domain) ExpensiveQueryHandle ¶
func (do *Domain) ExpensiveQueryHandle() *expensivequery.Handle
ExpensiveQueryHandle returns the expensive query handle.
func (*Domain) GetEtcdClient ¶
GetEtcdClient returns the etcd client.
func (*Domain) GetGlobalVarsCache ¶
func (do *Domain) GetGlobalVarsCache() *GlobalVariableCache
GetGlobalVarsCache gets the global variable cache.
func (*Domain) GetSnapshotInfoSchema ¶
func (do *Domain) GetSnapshotInfoSchema(snapshotTS uint64) (infoschema.InfoSchema, error)
GetSnapshotInfoSchema gets a snapshot information schema.
func (*Domain) GetSnapshotMeta ¶
GetSnapshotMeta gets a new snapshot meta at startTS.
func (*Domain) InfoSchema ¶
func (do *Domain) InfoSchema() infoschema.InfoSchema
InfoSchema gets information schema from domain.
func (*Domain) InfoSyncer ¶
func (do *Domain) InfoSyncer() *infosync.InfoSyncer
InfoSyncer gets infoSyncer from domain.
func (*Domain) Init ¶
func (do *Domain) Init(ddlLease time.Duration, sysFactory func(*Domain) (pools.Resource, error)) error
Init initializes a domain.
func (*Domain) InitExpensiveQueryHandle ¶
func (do *Domain) InitExpensiveQueryHandle()
InitExpensiveQueryHandle init the expensive query handler.
func (*Domain) LoadBindInfoLoop ¶
func (do *Domain) LoadBindInfoLoop(ctxForHandle sessionctx.Context, ctxForEvolve sessionctx.Context) error
LoadBindInfoLoop create a goroutine loads BindInfo in a loop, it should be called only once in BootstrapSession.
func (*Domain) LoadPrivilegeLoop ¶
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 ¶
func (do *Domain) LogSlowQuery(query *SlowQueryInfo)
LogSlowQuery keeps topN recent slow queries in domain.
func (*Domain) NotifyUpdatePrivilege ¶
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 ¶
func (do *Domain) PrivilegeHandle() *privileges.Handle
PrivilegeHandle returns the MySQLPrivilege.
func (*Domain) SetStatsUpdating ¶
SetStatsUpdating sets the value of stats updating.
func (*Domain) ShowSlowQuery ¶
func (do *Domain) ShowSlowQuery(showSlow *ast.ShowSlow) []*SlowQueryInfo
ShowSlowQuery returns the slow queries.
func (*Domain) StatsHandle ¶
StatsHandle returns the statistic handle.
func (*Domain) StatsUpdating ¶
StatsUpdating checks if the stats worker is updating.
func (*Domain) SysSessionPool ¶
func (do *Domain) SysSessionPool() *sessionPool
SysSessionPool returns the system session pool.
func (*Domain) UpdateTableStatsLoop ¶
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 ¶
type GlobalVariableCache struct { sync.RWMutex SingleFight singleflight.Group // contains filtered or unexported fields }
GlobalVariableCache caches global variables.
func (*GlobalVariableCache) Disable ¶
func (gvc *GlobalVariableCache) Disable()
Disable disables the global variable cache, used in test only.
func (*GlobalVariableCache) Get ¶
func (gvc *GlobalVariableCache) Get() (succ bool, rows []chunk.Row, fields []*ast.ResultField)
Get gets the global variables from cache.
func (*GlobalVariableCache) LoadGlobalVariables ¶
func (gvc *GlobalVariableCache) LoadGlobalVariables(loadFn func() ([]chunk.Row, []*ast.ResultField, error)) ([]chunk.Row, []*ast.ResultField, error)
LoadGlobalVariables will load from global cache first, loadFn will be executed if cache is not valid
func (*GlobalVariableCache) Update ¶
func (gvc *GlobalVariableCache) Update(rows []chunk.Row, fields []*ast.ResultField)
Update updates the global variable cache.
type SchemaChecker ¶
type SchemaChecker struct { SchemaValidator // contains filtered or unexported fields }
SchemaChecker is used for checking schema-validity.
func NewSchemaChecker ¶
func NewSchemaChecker(do *Domain, schemaVer int64, relatedTableIDs []int64) *SchemaChecker
NewSchemaChecker creates a new schema checker.
func (*SchemaChecker) Check ¶
func (s *SchemaChecker) Check(txnTS uint64) error
Check checks the validity of the schema version.
type SchemaValidator ¶
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, relatedPhysicalTableIDs []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 ¶
func NewSchemaValidator(lease time.Duration) SchemaValidator
NewSchemaValidator returns a SchemaValidator structure.
type SlowQueryInfo ¶
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.