Documentation ¶
Index ¶
- Constants
- Variables
- func CompleteDeleteRange(sctx sessionctx.Context, dr DelRangeTask, needToRecordDone bool) error
- func DeleteDoneRecord(sctx sessionctx.Context, dr DelRangeTask) error
- func DeleteKeyFromEtcd(key string, etcdCli *clientv3.Client, retryCnt int, timeout time.Duration) error
- func EmulatorGCDisable()
- func EmulatorGCEnable()
- func FolderNotEmpty(path string) bool
- func GenKeyExistsErr(key, value []byte, idxInfo *model.IndexInfo, tblInfo *model.TableInfo) error
- func GetInternalResourceGroupTaggerForTopSQL() tikvrpc.ResourceGroupTagger
- func GetTimeZone(sctx sessionctx.Context) (string, int)
- func IsEmulatorGCEnable() bool
- func IsInternalResourceGroupTaggerForTopSQL(tag []byte) bool
- func IsRaftKv2(ctx context.Context, sctx sessionctx.Context) (bool, error)
- func LoadDDLReorgVars(ctx context.Context, sctx sessionctx.Context) error
- func LoadDDLVars(ctx sessionctx.Context) error
- func LoadGlobalVars(ctx context.Context, sctx sessionctx.Context, varNames []string) error
- func PutKVToEtcd(ctx context.Context, etcdCli *clientv3.Client, retryCnt int, key, val string, ...) error
- func PutKVToEtcdMono(ctx context.Context, etcdCli *clientv3.Client, retryCnt int, key, val string, ...) error
- func RemoveFromGCDeleteRange(sctx sessionctx.Context, jobID, elementID int64) error
- func RemoveMultiFromGCDeleteRange(ctx context.Context, sctx sessionctx.Context, jobID int64) error
- func UpdateDeleteRange(sctx sessionctx.Context, dr DelRangeTask, newStartKey, oldStartKey kv.Key) error
- func WrapKey2String(key []byte) string
- type DeadTableLockChecker
- type DelRangeTask
- type MockGlobalState
- type MockGlobalStateSelector
- type Watcher
Constants ¶
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. // /tidb/ddl/all_schema_by_job_versions/<job-id>/<tidb-id> ---> <schema-version> 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 ¶
var MockGlobalStateEntry = &MockGlobalState{ currentOwner: make(map[ownerKey]string), }
MockGlobalStateEntry is a mock global state entry.
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 FolderNotEmpty ¶
FolderNotEmpty returns true only when the folder is not empty.
func GenKeyExistsErr ¶
GenKeyExistsErr builds a ErrKeyExists error.
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 IsEmulatorGCEnable ¶
func IsEmulatorGCEnable() bool
IsEmulatorGCEnable indicates whether emulator GC enabled. It exports for testing.
func IsInternalResourceGroupTaggerForTopSQL ¶
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 ¶
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 PutKVToEtcdMono ¶
func PutKVToEtcdMono(ctx context.Context, etcdCli *clientv3.Client, retryCnt int, key, val string, opts ...clientv3.OpOption) error
PutKVToEtcdMono puts key value to etcd monotonously. 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 ¶
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.
func WrapKey2String ¶
WrapKey2String wraps the key to a string.
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, is infoschema.MetaOnlyInfoSchema) (map[model.SessionInfo][]model.TableLockTpInfo, error)
GetDeadLockedTables gets dead locked tables.
type DelRangeTask ¶
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.
type MockGlobalState ¶
type MockGlobalState struct {
// contains filtered or unexported fields
}
MockGlobalState is a mock global state.
func (*MockGlobalState) OwnerKey ¶
func (m *MockGlobalState) OwnerKey(storeID, tp string) *MockGlobalStateSelector
OwnerKey returns a mock global state selector with corresponding owner key.
type MockGlobalStateSelector ¶
type MockGlobalStateSelector struct {
// contains filtered or unexported fields
}
MockGlobalStateSelector is used to get info from global state.
func (*MockGlobalStateSelector) GetOwner ¶
func (t *MockGlobalStateSelector) GetOwner() string
GetOwner returns the owner.
func (*MockGlobalStateSelector) IsOwner ¶
func (t *MockGlobalStateSelector) IsOwner(owner string) bool
IsOwner returns whether it is the owner.
func (*MockGlobalStateSelector) SetOwner ¶
func (t *MockGlobalStateSelector) SetOwner(owner string) bool
SetOwner sets the owner if the owner is empty.
func (*MockGlobalStateSelector) UnsetOwner ¶
func (t *MockGlobalStateSelector) UnsetOwner(owner string) bool
UnsetOwner unsets the owner.
type Watcher ¶
type Watcher interface { // WatchChan returns the chan for watching etcd path. WatchChan() clientv3.WatchChan // Watch watches the etcd path. Watch(ctx context.Context, etcdCli *clientv3.Client, path string) // Rewatch rewatches the etcd path. Rewatch(ctx context.Context, etcdCli *clientv3.Client, path string) }
Watcher is responsible for watching the etcd path related operations.