handle

package
v1.1.0-beta.0...-3735ed5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// StatsOwnerKey is the stats owner path that is saved to etcd.
	StatsOwnerKey = "/tidb/stats/owner"
	// StatsPrompt is the prompt for stats owner manager.
	StatsPrompt = "stats"
)

Variables

View Source
var IsFullCacheFunc func(cache statstypes.StatsCache, total uint64) bool = isFullCache

IsFullCacheFunc is whether the cache is full or not. but we can only change it when to test

Functions

func GetMaxTidRecordForTest

func GetMaxTidRecordForTest() int64

GetMaxTidRecordForTest gets the max tid record for test.

Types

type Handle

type Handle struct {
	// Pool is used to get a session or a goroutine to execute stats updating.
	util.Pool

	// AutoAnalyzeProcIDGenerator is used to generate auto analyze proc ID.
	util.AutoAnalyzeProcIDGenerator

	// LeaseGetter is used to get stats lease.
	util.LeaseGetter

	// TableInfoGetter is used to fetch table meta info.
	util.TableInfoGetter

	// StatsGC is used to GC stats.
	types.StatsGC

	// StatsUsage is used to track the usage of column / index statistics.
	types.StatsUsage

	// StatsHistory is used to manage historical stats.
	types.StatsHistory

	// StatsAnalyze is used to handle auto-analyze and manage analyze jobs.
	types.StatsAnalyze

	// StatsSyncLoad is used to load stats syncly.
	types.StatsSyncLoad

	// StatsReadWriter is used to read/write stats from/to storage.
	types.StatsReadWriter

	// StatsLock is used to manage locked stats.
	types.StatsLock

	// StatsGlobal is used to manage global stats.
	types.StatsGlobal

	// DDL is used to handle ddl events.
	types.DDL

	InitStatsDone chan struct{}

	// StatsCache ...
	types.StatsCache
	// contains filtered or unexported fields
}

Handle can update stats info periodically.

func NewHandle

func NewHandle(
	_,
	initStatsCtx sessionctx.Context,
	lease time.Duration,
	is infoschema.InfoSchema,
	pool pkgutil.SessionPool,
	tracker sysproctrack.Tracker,
	ddlNotifier *notifier.DDLNotifier,
	autoAnalyzeProcIDGetter func() uint64,
	releaseAutoAnalyzeProcID func(uint64),
) (*Handle, error)

NewHandle creates a Handle for update stats.

func (*Handle) Clear

func (h *Handle) Clear()

Clear the statsCache, only for test.

func (*Handle) Close

func (h *Handle) Close()

Close stops the background

func (*Handle) FlushStats

func (h *Handle) FlushStats()

FlushStats flushes the cached stats update into store.

func (*Handle) GetPartitionStats

func (h *Handle) GetPartitionStats(tblInfo *model.TableInfo, pid int64) *statistics.Table

GetPartitionStats retrieves the partition stats from cache. TODO: remove GetTableStats later on.

func (*Handle) GetPartitionStatsForAutoAnalyze

func (h *Handle) GetPartitionStatsForAutoAnalyze(tblInfo *model.TableInfo, pid int64) *statistics.Table

GetPartitionStatsForAutoAnalyze is to get partition stats but it will not return pseudo stats.

func (*Handle) GetTableStats

func (h *Handle) GetTableStats(tblInfo *model.TableInfo) *statistics.Table

GetTableStats retrieves the statistics table from cache, and the cache will be updated by a goroutine. TODO: remove GetTableStats later on.

func (*Handle) GetTableStatsForAutoAnalyze

func (h *Handle) GetTableStatsForAutoAnalyze(tblInfo *model.TableInfo) *statistics.Table

GetTableStatsForAutoAnalyze is to get table stats but it will not return pseudo stats.

func (*Handle) InitStats

func (h *Handle) InitStats(ctx context.Context, is infoschema.InfoSchema) (err error)

InitStats initiates the stats cache. 1. Basic stats meta data is loaded.(count, modify count, etc.) 2. Index stats are fully loaded. (histogram, topn, buckets) 2. Column stats are marked as existing or not by initializing the table.ColAndIdxExistenceMap, based on data from mysql.stats_histograms) To work with auto-analyze's needs, we need to read all stats meta info into memory. The sync/async load of the stats or other process haven't done a full initialization of the table.ColAndIdxExistenceMap. So we need to it here.

func (*Handle) InitStatsLite

func (h *Handle) InitStatsLite(ctx context.Context) (err error)

InitStatsLite initiates the stats cache. The function is liter and faster than InitStats. 1. Basic stats meta data is loaded.(count, modify count, etc.) 2. Column/index stats are marked as existing or not by initializing the table.ColAndIdxExistenceMap, based on data from mysql.stats_histograms) 3. TopN, Bucket, FMSketch are not loaded. And to work with auto analyze's needs, we need to read all the tables' stats meta into memory. The sync/async load of the stats or other process haven't done a full initialization of the table.ColAndIdxExistenceMap. So we need to it here.

func (*Handle) StartWorker

func (h *Handle) StartWorker()

StartWorker starts the background collector worker inside

type MaxTidRecord

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

MaxTidRecord is to record the max tid.

Jump to

Keyboard shortcuts

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