domain

package
v1.1.0-beta.0...-9958228 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 115 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ExtractTaskType indicates type of extract task
	ExtractTaskType = "taskType"
	// ExtractPlanTaskSkipStats indicates skip stats for extract plan task
	ExtractPlanTaskSkipStats = "SkipStats"
)
View Source
const (
	// PlanReplayerSQLMetaFile indicates sql meta path for plan replayer
	PlanReplayerSQLMetaFile = "sql_meta.toml"
	// PlanReplayerConfigFile indicates config file path for plan replayer
	PlanReplayerConfigFile = "config.toml"
	// PlanReplayerMetaFile meta file path for plan replayer
	PlanReplayerMetaFile = "meta.txt"
	// PlanReplayerVariablesFile indicates for session variables file path for plan replayer
	PlanReplayerVariablesFile = "variables.toml"
	// PlanReplayerTiFlashReplicasFile indicates for table tiflash replica file path for plan replayer
	PlanReplayerTiFlashReplicasFile = "table_tiflash_replica.txt"
	// PlanReplayerSessionBindingFile indicates session binding file path for plan replayer
	PlanReplayerSessionBindingFile = "session_bindings.sql"
	// PlanReplayerGlobalBindingFile indicates global binding file path for plan replayer
	PlanReplayerGlobalBindingFile = "global_bindings.sql"
	// PlanReplayerSchemaMetaFile indicates the schema meta
	PlanReplayerSchemaMetaFile = "schema_meta.txt"
	// PlanReplayerErrorMessageFile is the file name for error messages
	PlanReplayerErrorMessageFile = "errors.txt"
)
View Source
const (
	// PlanReplayerSQLMetaStartTS indicates the startTS in plan replayer sql meta
	PlanReplayerSQLMetaStartTS = "startTS"
	// PlanReplayerTaskMetaIsCapture indicates whether this task is capture task
	PlanReplayerTaskMetaIsCapture = "isCapture"
	// PlanReplayerTaskMetaIsContinues indicates whether this task is continues task
	PlanReplayerTaskMetaIsContinues = "isContinues"
	// PlanReplayerTaskMetaSQLDigest indicates the sql digest of this task
	PlanReplayerTaskMetaSQLDigest = "sqlDigest"
	// PlanReplayerTaskMetaPlanDigest indicates the plan digest of this task
	PlanReplayerTaskMetaPlanDigest = "planDigest"
	// PlanReplayerTaskEnableHistoricalStats indicates whether the task is using historical stats
	PlanReplayerTaskEnableHistoricalStats = "enableHistoricalStats"
	// PlanReplayerHistoricalStatsTS indicates the expected TS of the historical stats if it's specified by the user.
	PlanReplayerHistoricalStatsTS = "historicalStatsTS"
)
View Source
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
)
View Source
const (
	// ExtractMetaFile indicates meta file for extract
	ExtractMetaFile = "extract_meta.txt"
)

Variables

View Source
var (

	// LoadSchemaDiffVersionGapThreshold is the threshold for version gap to reload domain by loading schema diffs
	LoadSchemaDiffVersionGapThreshold int64 = 10000

	// NewInstancePlanCache creates a new instance level plan cache, this function is designed to avoid cycle-import.
	NewInstancePlanCache func(softMemLimit, hardMemLimit int64) sessionctx.InstancePlanCache
)
View Source
var (
	// ErrInfoSchemaExpired returns the error that information schema is out of date.
	ErrInfoSchemaExpired = dbterror.ClassDomain.NewStd(errno.ErrInfoSchemaExpired)
	// ErrInfoSchemaChanged returns the error that information schema is changed.
	ErrInfoSchemaChanged = dbterror.ClassDomain.NewStdErr(errno.ErrInfoSchemaChanged,
		mysql.Message(errno.MySQLErrName[errno.ErrInfoSchemaChanged].Raw+". "+kv.TxnRetryableMark, nil))
)
View Source
var (
	// SchemaOutOfDateRetryInterval is the backoff time before retrying.
	SchemaOutOfDateRetryInterval = atomicutil.NewDuration(500 * time.Millisecond)
	// SchemaOutOfDateRetryTimes is the max retry count when the schema is out of date.
	SchemaOutOfDateRetryTimes = atomicutil.NewInt32(10)
)

Functions

func BindDomain

func BindDomain(ctx contextutil.ValueStoreContext, domain *Domain)

BindDomain binds domain to context.

func CheckPlanReplayerTaskExists

func CheckPlanReplayerTaskExists(ctx context.Context, sctx sessionctx.Context, sqlDigest, planDigest string) (bool, error)

CheckPlanReplayerTaskExists checks whether plan replayer capture task exists already

func DisableDumpHistoricalStats4Test

func DisableDumpHistoricalStats4Test()

DisableDumpHistoricalStats4Test disable historical dump worker for test

func DisablePlanReplayerBackgroundJob4Test

func DisablePlanReplayerBackgroundJob4Test()

DisablePlanReplayerBackgroundJob4Test disable plan replayer handle for test

func DumpPlanReplayerInfo

func DumpPlanReplayerInfo(ctx context.Context, sctx sessionctx.Context,
	task *PlanReplayerDumpTask) (err error)

DumpPlanReplayerInfo will dump the information about sqls. The files will be organized into the following format:

|-sql_meta.toml
|-meta.txt
|-schema
|	 |-schema_meta.txt
|	 |-db1.table1.schema.txt
|	 |-db2.table2.schema.txt
|	 |-....
|-view
| 	 |-db1.view1.view.txt
|	 |-db2.view2.view.txt
|	 |-....
|-stats
|   |-stats1.json
|   |-stats2.json
|   |-....
|-statsMem
|   |-stats1.txt
|   |-stats2.txt
|   |-....
|-config.toml
|-table_tiflash_replica.txt
|-variables.toml
|-bindings.sql
|-sql
|   |-sql1.sql
|   |-sql2.sql
|	 |-....
|-explain.txt

func GenerateExtractFile

func GenerateExtractFile() (*os.File, string, error)

GenerateExtractFile generates extract stmt file

func GetExtractTaskDirName

func GetExtractTaskDirName() string

GetExtractTaskDirName get extract dir name

func GetLastExpectedTime

func GetLastExpectedTime(now time.Time, interval time.Duration) time.Time

GetLastExpectedTime return the last written ru time. NOTE:

  • due to DST(daylight saving time), the actual duration for a specific time may be shorter or longer than the interval when DST happens.
  • All the tidb-server should be deployed in the same timezone to ensure the duration is calculated correctly.
  • The interval must not be longer than 24h.

func GetLastExpectedTimeTZ

func GetLastExpectedTimeTZ(now time.Time, interval time.Duration, tz *time.Location) time.Time

GetLastExpectedTimeTZ return the last written ru time under specifical timezone. make it public only for test.

func GetOptimizerTraceDirName

func GetOptimizerTraceDirName() string

GetOptimizerTraceDirName returns optimizer trace directory path. The path is related to the process id.

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 GetDomain

func GetDomain(ctx contextutil.ValueStoreContext) *Domain

GetDomain gets domain from context.

func NewDomain

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

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

func NewDomainWithEtcdClient

func NewDomainWithEtcdClient(store kv.Storage, schemaLease time.Duration, statsLease time.Duration, dumpFileGcLease time.Duration, factory pools.Factory, etcdClient *clientv3.Client) *Domain

NewDomainWithEtcdClient creates a new domain with etcd client. Should not create multiple domains for the same store.

func NewMockDomain

func NewMockDomain() *Domain

NewMockDomain is only used for test

func (*Domain) AutoIDClient

func (do *Domain) AutoIDClient() *autoid.ClientDiscover

AutoIDClient returns the autoid client.

func (*Domain) BindHandle

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

BindHandle returns domain's bindHandle.

func (*Domain) CheckAutoAnalyzeWindows

func (do *Domain) CheckAutoAnalyzeWindows()

CheckAutoAnalyzeWindows checks the auto analyze windows and kill the auto analyze process if it is not in the window.

func (*Domain) Close

func (do *Domain) Close()

Close closes the Domain and release its resource.

func (*Domain) CreateStatsHandle

func (do *Domain) CreateStatsHandle(ctx, initStatsCtx sessionctx.Context) error

CreateStatsHandle is used only for test.

func (*Domain) DDL

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

DDL gets DDL from domain.

func (*Domain) DDLExecutor

func (do *Domain) DDLExecutor() ddl.Executor

DDLExecutor gets the ddl executor from domain.

func (*Domain) DDLNotifier

func (do *Domain) DDLNotifier() *notifier.DDLNotifier

DDLNotifier returns the DDL notifier.

func (*Domain) DumpFileGcCheckerLoop

func (do *Domain) DumpFileGcCheckerLoop()

DumpFileGcCheckerLoop creates a goroutine that handles `exit` and `gc`.

func (*Domain) EtcdClient

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

EtcdClient export for test.

func (*Domain) ExpensiveQueryHandle

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

ExpensiveQueryHandle returns the expensive query handle.

func (*Domain) ExpiredTimeStamp4PC

func (do *Domain) ExpiredTimeStamp4PC() types.Time

ExpiredTimeStamp4PC gets expiredTimeStamp4PC from domain.

func (*Domain) FetchAllSchemasWithTables

func (do *Domain) FetchAllSchemasWithTables(m meta.Reader) ([]*model.DBInfo, error)

FetchAllSchemasWithTables calls the internal function. Only used in unit tests.

func (*Domain) GetDumpFileGCChecker

func (do *Domain) GetDumpFileGCChecker() *dumpFileGcChecker

GetDumpFileGCChecker returns dump file GC checker for plan replayer and plan trace

func (*Domain) GetEtcdClient

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

GetEtcdClient returns the etcd client.

func (*Domain) GetExtractHandle

func (do *Domain) GetExtractHandle() *ExtractHandle

GetExtractHandle returns extract handle

func (*Domain) GetGlobalConfigSyncer

func (do *Domain) GetGlobalConfigSyncer() *globalconfigsync.GlobalConfigSyncer

GetGlobalConfigSyncer exports for testing.

func (*Domain) GetGlobalVar

func (do *Domain) GetGlobalVar(name string) (string, error)

GetGlobalVar gets an individual global var from the sysvar cache.

func (*Domain) GetHistoricalStatsWorker

func (do *Domain) GetHistoricalStatsWorker() *HistoricalStatsWorker

GetHistoricalStatsWorker gets historical workers

func (*Domain) GetInstancePlanCache

func (do *Domain) GetInstancePlanCache() sessionctx.InstancePlanCache

GetInstancePlanCache returns the instance level plan cache in this Domain.

func (*Domain) GetPDClient

func (do *Domain) GetPDClient() pd.Client

GetPDClient returns the PD client.

func (*Domain) GetPDHTTPClient

func (do *Domain) GetPDHTTPClient() pdhttp.Client

GetPDHTTPClient returns the PD HTTP client.

func (*Domain) GetPlanReplayerHandle

func (do *Domain) GetPlanReplayerHandle() *planReplayerHandle

GetPlanReplayerHandle returns plan replayer handle

func (*Domain) GetSchemaLease

func (do *Domain) GetSchemaLease() time.Duration

GetSchemaLease return the schema lease.

func (*Domain) GetScope

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

GetScope gets the status variables scope.

func (*Domain) GetSessionCache

func (do *Domain) GetSessionCache() (map[string]string, error)

GetSessionCache gets a copy of the session sysvar cache. The intention is to copy it directly to the systems[] map on creating a new session.

func (*Domain) GetSnapshotInfoSchema

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

GetSnapshotInfoSchema gets a snapshot information schema.

func (*Domain) GetSnapshotMeta

func (do *Domain) GetSnapshotMeta(startTS uint64) meta.Reader

GetSnapshotMeta gets a new snapshot meta at startTS.

func (*Domain) InfoCache

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

InfoCache export for test.

func (*Domain) InfoSchema

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

InfoSchema gets the latest 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(
	sysExecutorFactory func(*Domain) (pools.Resource, error),
	ddlInjector func(ddl.DDL, ddl.Executor, *infoschema.InfoCache) *schematracker.Checker,
) error

Init initializes a domain. after return, session can be used to do DMLs but not DDLs which can be used after domain Start.

func (*Domain) InitBindingHandle

func (do *Domain) InitBindingHandle() error

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

func (*Domain) InitDistTaskLoop

func (do *Domain) InitDistTaskLoop() error

InitDistTaskLoop initializes the distributed task framework.

func (*Domain) InitInfo4Test

func (do *Domain) InitInfo4Test()

InitInfo4Test init infosync for distributed execution test.

func (*Domain) InitInstancePlanCache

func (do *Domain) InitInstancePlanCache()

InitInstancePlanCache initializes the instance level plan cache for this Domain.

func (*Domain) IsLeaseExpired

func (do *Domain) IsLeaseExpired() bool

IsLeaseExpired returns whether lease has expired

func (*Domain) IsLostConnectionToPD

func (do *Domain) IsLostConnectionToPD() bool

IsLostConnectionToPD indicates lost connection to PD or not.

func (*Domain) LoadAndUpdateStatsLoop

func (do *Domain) LoadAndUpdateStatsLoop(ctxs []sessionctx.Context, initStatsCtx sessionctx.Context) error

LoadAndUpdateStatsLoop loads and updates stats info.

func (*Domain) LoadPrivilegeLoop

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

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

func (*Domain) LoadSigningCertLoop

func (do *Domain) LoadSigningCertLoop(signingCert, signingKey string)

LoadSigningCertLoop loads the signing cert periodically to make sure it's fresh new.

func (*Domain) LoadSysVarCacheLoop

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

LoadSysVarCacheLoop create a goroutine loads sysvar cache 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) MemoryUsageAlarmHandle

func (do *Domain) MemoryUsageAlarmHandle() *memoryusagealarm.Handle

MemoryUsageAlarmHandle returns the memory usage alarm handle.

func (*Domain) MockInfoCacheAndLoadInfoSchema

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

MockInfoCacheAndLoadInfoSchema only used in unit tests.

func (*Domain) MustGetPartitionAt

func (do *Domain) MustGetPartitionAt(t *testing.T, dbName, tableName string, idx int) int64

MustGetPartitionAt returns the partition ID. Only used in unit tests.

func (*Domain) MustGetTableID

func (do *Domain) MustGetTableID(t *testing.T, dbName, tableName string) int64

MustGetTableID returns the table ID. Only used in unit tests.

func (*Domain) MustGetTableInfo

func (do *Domain) MustGetTableInfo(t *testing.T, dbName, tableName string) *model.TableInfo

MustGetTableInfo returns the table info. Only used in unit tests.

func (*Domain) NewOwnerManager

func (do *Domain) NewOwnerManager(prompt, ownerKey string) owner.Manager

NewOwnerManager returns the owner manager for use outside of the domain.

func (*Domain) NextConnID

func (do *Domain) NextConnID() uint64

NextConnID return next connection ID.

func (*Domain) NotifyGlobalConfigChange

func (do *Domain) NotifyGlobalConfigChange(name, value string)

NotifyGlobalConfigChange notify global config syncer to store the global config into PD.

func (*Domain) NotifyUpdateAllUsersPrivilege

func (do *Domain) NotifyUpdateAllUsersPrivilege() error

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

func (*Domain) NotifyUpdatePrivilege

func (do *Domain) NotifyUpdatePrivilege(userList []string) error

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

func (*Domain) NotifyUpdateSysVarCache

func (do *Domain) NotifyUpdateSysVarCache(updateLocal bool)

NotifyUpdateSysVarCache updates the sysvar cache key in etcd, which other TiDB clients are subscribed to for updates. For the caller, the cache is also built synchronously so that the effect is immediate.

func (*Domain) PrivilegeHandle

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

PrivilegeHandle returns the MySQLPrivilege.

func (*Domain) ReleaseConnID

func (do *Domain) ReleaseConnID(connID uint64)

ReleaseConnID releases connection ID.

func (*Domain) Reload

func (do *Domain) Reload() error

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

func (*Domain) ResourceGroupsController

func (do *Domain) ResourceGroupsController() *rmclient.ResourceGroupsController

ResourceGroupsController returns the resource groups controller.

func (*Domain) RunawayManager

func (do *Domain) RunawayManager() *runaway.Manager

RunawayManager returns the runaway manager.

func (*Domain) ServerID

func (do *Domain) ServerID() uint64

ServerID gets serverID.

func (*Domain) ServerMemoryLimitHandle

func (do *Domain) ServerMemoryLimitHandle() *servermemorylimit.Handle

ServerMemoryLimitHandle returns the expensive query handle.

func (*Domain) SetDDL

func (do *Domain) SetDDL(d ddl.DDL, executor ddl.Executor)

SetDDL sets DDL to domain, it's only used in tests.

func (*Domain) SetExpiredTimeStamp4PC

func (do *Domain) SetExpiredTimeStamp4PC(time types.Time)

SetExpiredTimeStamp4PC sets the expiredTimeStamp4PC from domain.

func (*Domain) SetOnClose

func (do *Domain) SetOnClose(onClose func())

SetOnClose used to set do.onClose func.

func (*Domain) SetResourceGroupsController

func (do *Domain) SetResourceGroupsController(controller *rmclient.ResourceGroupsController)

SetResourceGroupsController is only used in test.

func (*Domain) SetStatsUpdating

func (do *Domain) SetStatsUpdating(val bool)

SetStatsUpdating sets the value of stats updating.

func (*Domain) SetupDumpFileGCChecker

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

SetupDumpFileGCChecker setup sctx

func (*Domain) SetupExtractHandle

func (do *Domain) SetupExtractHandle(sctxs []sessionctx.Context)

SetupExtractHandle setups extract handler

func (*Domain) SetupHistoricalStatsWorker

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

SetupHistoricalStatsWorker setups worker

func (*Domain) SetupPlanReplayerHandle

func (do *Domain) SetupPlanReplayerHandle(collectorSctx sessionctx.Context, workersSctxs []sessionctx.Context)

SetupPlanReplayerHandle setup plan replayer handle

func (*Domain) SetupWorkloadBasedLearningWorker

func (do *Domain) SetupWorkloadBasedLearningWorker()

SetupWorkloadBasedLearningWorker sets up all of the workload based learning workers.

func (*Domain) ShowSlowQuery

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

ShowSlowQuery returns the slow queries.

func (*Domain) Start

func (do *Domain) Start(startMode ddl.StartMode) error

Start starts the domain. After start, DDLs can be executed using session, see Init also.

func (*Domain) StartHistoricalStatsWorker

func (do *Domain) StartHistoricalStatsWorker()

StartHistoricalStatsWorker start historical workers running

func (*Domain) StartLoadStatsSubWorkers

func (do *Domain) StartLoadStatsSubWorkers(ctxList []sessionctx.Context)

StartLoadStatsSubWorkers starts sub workers with new sessions to load stats concurrently.

func (*Domain) StartPlanReplayerHandle

func (do *Domain) StartPlanReplayerHandle()

StartPlanReplayerHandle start plan replayer handle job

func (*Domain) StartTTLJobManager

func (do *Domain) StartTTLJobManager()

StartTTLJobManager creates and starts the ttl job manager

func (*Domain) StatsHandle

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

StatsHandle returns the statistic handle.

func (*Domain) StatsUpdating

func (do *Domain) StatsUpdating() bool

StatsUpdating checks if the stats worker is updating.

func (*Domain) StopAutoAnalyze

func (do *Domain) StopAutoAnalyze()

StopAutoAnalyze stops (*Domain).autoAnalyzeWorker to launch new auto analyze jobs.

func (*Domain) Store

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

Store gets KV store from domain.

func (*Domain) SysProcTracker

func (do *Domain) SysProcTracker() sysproctrack.Tracker

SysProcTracker returns the system processes tracker.

func (*Domain) SysSessionPool

func (do *Domain) SysSessionPool() util.SessionPool

SysSessionPool returns the system session pool.

func (*Domain) TTLJobManager

func (do *Domain) TTLJobManager() *ttlworker.JobManager

TTLJobManager returns the ttl job manager on this domain

func (*Domain) UnprefixedEtcdCli

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

UnprefixedEtcdCli export for test.

func (*Domain) UpdateTableStatsLoop

func (do *Domain) UpdateTableStatsLoop(ctx, initStatsCtx 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.

func (*Domain) WatchTiFlashComputeNodeChange

func (do *Domain) WatchTiFlashComputeNodeChange() error

WatchTiFlashComputeNodeChange create a routine to watch if the topology of tiflash_compute node is changed. TODO: tiflashComputeNodeKey is not put to etcd yet(finish this when AutoScaler is done)

store cache will only be invalidated every n seconds.

type ExtractHandle

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

ExtractHandle handles the extractWorker to run extract the information task like Plan or any others. extractHandle will provide 2 mode for extractWorker: 1. submit a background extract task, the response will be returned after the task is started to be solved 2. submit a task and wait until the task is solved, the result will be returned to the response.

func (*ExtractHandle) ExtractTask

func (h *ExtractHandle) ExtractTask(ctx context.Context, task *ExtractTask) (string, error)

ExtractTask extract tasks

type ExtractTask

type ExtractTask struct {
	ExtractType     ExtractType
	IsBackgroundJob bool

	// Param for Extract Plan
	SkipStats      bool
	UseHistoryView bool

	// variables for plan task type
	Begin time.Time
	End   time.Time
}

ExtractTask indicates task

func NewExtractPlanTask

func NewExtractPlanTask(begin, end time.Time) *ExtractTask

NewExtractPlanTask returns extract plan task

type ExtractType

type ExtractType uint8

ExtractType indicates type

const (
	// ExtractPlanType indicates extract plan task
	ExtractPlanType ExtractType = iota
)

type HistoricalStatsWorker

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

HistoricalStatsWorker indicates for dump historical stats

func (*HistoricalStatsWorker) DumpHistoricalStats

func (w *HistoricalStatsWorker) DumpHistoricalStats(tableID int64, statsHandle *handle.Handle) error

DumpHistoricalStats dump stats by given tableID

func (*HistoricalStatsWorker) GetOneHistoricalStatsTable

func (w *HistoricalStatsWorker) GetOneHistoricalStatsTable() int64

GetOneHistoricalStatsTable gets one tableID from channel, only used for test

func (*HistoricalStatsWorker) SendTblToDumpHistoricalStats

func (w *HistoricalStatsWorker) SendTblToDumpHistoricalStats(tableID int64)

SendTblToDumpHistoricalStats send tableID to worker to dump historical stats

type PlanReplayerDumpTask

type PlanReplayerDumpTask struct {
	replayer.PlanReplayerTaskKey

	// tmp variables stored during the query
	TblStats map[int64]any

	// variables used to dump the plan
	StartTS           uint64
	SessionBindings   [][]*bindinfo.Binding
	EncodedPlan       string
	SessionVars       *variable.SessionVars
	ExecStmts         []ast.StmtNode
	Analyze           bool
	HistoricalStatsTS uint64
	DebugTrace        []any

	FileName string
	Zf       *os.File

	// IsCapture indicates whether the task is from capture
	IsCapture bool
	// IsContinuesCapture indicates whether the task is from continues capture
	IsContinuesCapture bool
}

PlanReplayerDumpTask wrap the params for plan replayer dump

type PlanReplayerStatusRecord

type PlanReplayerStatusRecord struct {
	SQLDigest    string
	PlanDigest   string
	OriginSQL    string
	Token        string
	FailedReason string
}

PlanReplayerStatusRecord indicates record in mysql.plan_replayer_status

type PrivilegeEvent

type PrivilegeEvent struct {
	All      bool
	UserList []string
}

PrivilegeEvent is the message definition for NotifyUpdatePrivilege(), encoded in json. TiDB old version do not use no such message.

type RUStatsWriter

type RUStatsWriter struct {
	// make some fields public for unit test.
	Interval  time.Duration
	RMClient  pd.ResourceManagerClient
	InfoCache *infoschema.InfoCache

	// current time, cache it here to make unit test easier.
	StartTime time.Time
	// contains filtered or unexported fields
}

RUStatsWriter represents a write to write ru historical data into mysql.request_unit_by_group.

func NewRUStatsWriter

func NewRUStatsWriter(do *Domain) *RUStatsWriter

NewRUStatsWriter build a RUStatsWriter from Domain.

func (*RUStatsWriter) DoWriteRUStatistics

func (r *RUStatsWriter) DoWriteRUStatistics(ctx context.Context) error

DoWriteRUStatistics write ru historical data into mysql.request_unit_by_group.

func (*RUStatsWriter) GCOutdatedRecords

func (r *RUStatsWriter) GCOutdatedRecords(lastEndTime time.Time) error

GCOutdatedRecords delete outdated records from target table.

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, needCheckSchema bool) *SchemaChecker

NewSchemaChecker creates a new schema checker.

func (*SchemaChecker) Check

Check checks the validity of the schema version.

func (*SchemaChecker) CheckBySchemaVer

func (s *SchemaChecker) CheckBySchemaVer(txnTS uint64, startSchemaVer tikv.SchemaVer) (*transaction.RelatedSchemaChange, error)

CheckBySchemaVer checks if the schema version valid or not at txnTS.

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, change *transaction.RelatedSchemaChange)
	// Check is it valid for a transaction to use schemaVer and related tables, at timestamp txnTS.
	Check(txnTS uint64, schemaVer int64, relatedPhysicalTableIDs []int64, needCheckSchema bool) (*transaction.RelatedSchemaChange, 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
	// IsLeaseExpired checks whether the current lease has expired
	IsLeaseExpired() bool
}

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

func NewSchemaValidator

func NewSchemaValidator(lease time.Duration, do *Domain) SchemaValidator

NewSchemaValidator returns a SchemaValidator structure.

type SlowQueryInfo

type SlowQueryInfo struct {
	SQL        string
	Start      time.Time
	Duration   time.Duration
	Detail     execdetails.ExecDetails
	ConnID     uint64
	SessAlias  string
	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.

type SysProcesses

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

SysProcesses holds the sys processes infos

func (*SysProcesses) GetSysProcessList

func (s *SysProcesses) GetSysProcessList() map[uint64]*util.ProcessInfo

GetSysProcessList gets list of system ProcessInfo

func (*SysProcesses) KillSysProcess

func (s *SysProcesses) KillSysProcess(id uint64)

KillSysProcess kills sys process with specified ID

func (*SysProcesses) Track

func (s *SysProcesses) Track(id uint64, proc sysproctrack.TrackProc) error

Track tracks the sys process into procMap

func (*SysProcesses) UnTrack

func (s *SysProcesses) UnTrack(id uint64)

UnTrack removes the sys process from procMap

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL