util

package
v0.0.0-...-503c688 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// KeyOpDefaultTimeout is the default timeout for each key operation.
	KeyOpDefaultTimeout = 2 * time.Second
	// KeyOpRetryInterval is the interval between two key operations.
	KeyOpRetryInterval = 30 * time.Millisecond
	// DDLAllSchemaVersions is the path on etcd that is used to store all servers current schema versions.
	DDLAllSchemaVersions = "/tidb/ddl/all_schema_versions"
	// DDLAllSchemaVersionsByJob is the path on etcd that is used to store all servers current schema versions.
	DDLAllSchemaVersionsByJob = "/tidb/ddl/all_schema_by_job_versions"
	// DDLGlobalSchemaVersion is the path on etcd that is used to store the latest schema versions.
	DDLGlobalSchemaVersion = "/tidb/ddl/global_schema_version"
	// ServerGlobalState is the path on etcd that is used to store the server global state.
	ServerGlobalState = "/tidb/server/global_state"
	// SessionTTL is the etcd session's TTL in seconds.
	SessionTTL = 90
)

Variables

This section is empty.

Functions

func CompleteDeleteRange

func CompleteDeleteRange(sctx sessionctx.Context, dr DelRangeTask, needToRecordDone bool) error

CompleteDeleteRange moves a record from gc_delete_range table to gc_delete_range_done table.

func DeleteDoneRecord

func DeleteDoneRecord(sctx sessionctx.Context, dr DelRangeTask) error

DeleteDoneRecord removes a record from gc_delete_range_done table.

func DeleteKeyFromEtcd

func DeleteKeyFromEtcd(key string, etcdCli *clientv3.Client, retryCnt int, timeout time.Duration) error

DeleteKeyFromEtcd deletes key value from etcd.

func EmulatorGCDisable

func EmulatorGCDisable()

EmulatorGCDisable disables emulator gc. It exports for testing.

func EmulatorGCEnable

func EmulatorGCEnable()

EmulatorGCEnable enables emulator gc. It exports for testing.

func GetInternalResourceGroupTaggerForTopSQL

func GetInternalResourceGroupTaggerForTopSQL() tikvrpc.ResourceGroupTagger

GetInternalResourceGroupTaggerForTopSQL only use for testing.

func GetTimeZone

func GetTimeZone(sctx sessionctx.Context) (string, int)

GetTimeZone gets the session location's zone name and offset.

func IsContextDone

func IsContextDone(ctx context.Context) bool

IsContextDone checks if context is done.

func IsEmulatorGCEnable

func IsEmulatorGCEnable() bool

IsEmulatorGCEnable indicates whether emulator GC enabled. It exports for testing.

func IsInternalResourceGroupTaggerForTopSQL

func IsInternalResourceGroupTaggerForTopSQL(tag []byte) bool

IsInternalResourceGroupTaggerForTopSQL use for testing.

func LoadDDLReorgVars

func LoadDDLReorgVars(ctx context.Context, sctx sessionctx.Context) error

LoadDDLReorgVars loads ddl reorg variable from mysql.global_variables.

func LoadDDLVars

func LoadDDLVars(ctx sessionctx.Context) error

LoadDDLVars loads ddl variable from mysql.global_variables.

func LoadGlobalVars

func LoadGlobalVars(ctx context.Context, sctx sessionctx.Context, varNames []string) error

LoadGlobalVars loads global variable from mysql.global_variables.

func PutKVToEtcd

func PutKVToEtcd(ctx context.Context, etcdCli *clientv3.Client, retryCnt int, key, val string,
	opts ...clientv3.OpOption) error

PutKVToEtcd puts key value to etcd. etcdCli is client of etcd. retryCnt is retry time when an error occurs. opts are configures of etcd Operations.

func RemoveFromGCDeleteRange

func RemoveFromGCDeleteRange(sctx sessionctx.Context, jobID, elementID int64) error

RemoveFromGCDeleteRange is exported for ddl pkg to use.

func RemoveMultiFromGCDeleteRange

func RemoveMultiFromGCDeleteRange(ctx context.Context, sctx sessionctx.Context, jobID int64) error

RemoveMultiFromGCDeleteRange is exported for ddl pkg to use.

func UpdateDeleteRange

func UpdateDeleteRange(sctx sessionctx.Context, dr DelRangeTask, newStartKey, oldStartKey kv.Key) error

UpdateDeleteRange is only for emulator.

Types

type DeadTableLockChecker

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

DeadTableLockChecker uses to check dead table locks. If tidb-server panic or killed by others, the table locks hold by the killed tidb-server maybe doesn't released.

func NewDeadTableLockChecker

func NewDeadTableLockChecker(etcdCli *clientv3.Client) DeadTableLockChecker

NewDeadTableLockChecker creates new DeadLockChecker.

func (*DeadTableLockChecker) GetDeadLockedTables

func (d *DeadTableLockChecker) GetDeadLockedTables(ctx context.Context, schemas []*model.DBInfo) (map[model.SessionInfo][]model.TableLockTpInfo, error)

GetDeadLockedTables gets dead locked tables.

type DelRangeTask

type DelRangeTask struct {
	StartKey  kv.Key
	EndKey    kv.Key
	JobID     int64
	ElementID int64
}

DelRangeTask is for run delete-range command in gc_worker.

func LoadDeleteRanges

func LoadDeleteRanges(ctx context.Context, sctx sessionctx.Context, safePoint uint64) (ranges []DelRangeTask, _ error)

LoadDeleteRanges loads delete range tasks from gc_delete_range table.

func LoadDoneDeleteRanges

func LoadDoneDeleteRanges(ctx context.Context, sctx sessionctx.Context, safePoint uint64) (ranges []DelRangeTask, _ error)

LoadDoneDeleteRanges loads deleted ranges from gc_delete_range_done table.

func (DelRangeTask) Range

func (t DelRangeTask) Range() (kv.Key, kv.Key)

Range returns the range [start, end) to delete.

type Event

type Event struct {
	TableInfo   *model.TableInfo
	PartInfo    *model.PartitionInfo
	IndexInfo   *model.IndexInfo
	ColumnInfos []*model.ColumnInfo
	Tp          model.ActionType
}

Event is an event that a ddl operation happened.

func (*Event) String

func (e *Event) String() string

String implements fmt.Stringer interface.

Jump to

Keyboard shortcuts

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