tidb: github.com/pingcap/tidb/ddl/util Index | Files

package util

import "github.com/pingcap/tidb/ddl/util"

Index

Package Files

event.go syncer.go util.go

Constants

const (
    // DDLAllSchemaVersions is the path on etcd that is used to store all servers current schema versions.
    // It's exported for testing.
    DDLAllSchemaVersions = "/tidb/ddl/all_schema_versions"
    // DDLGlobalSchemaVersion is the path on etcd that is used to store the latest schema versions.
    // It's exported for testing.
    DDLGlobalSchemaVersion = "/tidb/ddl/global_schema_version"
    // InitialVersion is the initial schema version for every server.
    // It's exported for testing.
    InitialVersion = "0"
)

Variables

var (
    // CheckVersFirstWaitTime is a waitting time before the owner checks all the servers of the schema version,
    // and it's an exported variable for testing.
    CheckVersFirstWaitTime = 50 * time.Millisecond
    // SyncerSessionTTL is the etcd session's TTL in seconds.
    // and it's an exported variable for testing.
    SyncerSessionTTL = 90
)
var NeededCleanTTL = int64(-60)

NeededCleanTTL is exported for testing.

func CompleteDeleteRange Uses

func CompleteDeleteRange(ctx sessionctx.Context, dr DelRangeTask) error

CompleteDeleteRange moves a record from gc_delete_range table to gc_delete_range_done table. NOTE: This function WILL NOT start and run in a new transaction internally.

func DeleteDoneRecord Uses

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

DeleteDoneRecord removes a record from gc_delete_range_done table.

func DeleteKeyFromEtcd Uses

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

DeleteKeyFromEtcd deletes key value from etcd.

func LoadDDLReorgVars Uses

func LoadDDLReorgVars(ctx sessionctx.Context) error

LoadDDLReorgVars loads ddl reorg variable from mysql.global_variables.

func LoadDDLVars Uses

func LoadDDLVars(ctx sessionctx.Context) error

LoadDDLVars loads ddl variable from mysql.global_variables.

func LoadGlobalVars Uses

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

LoadGlobalVars loads global variable from mysql.global_variables.

func PutKVToEtcd Uses

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 is configures of etcd Operations.

func RemoveFromGCDeleteRange Uses

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

RemoveFromGCDeleteRange is exported for ddl pkg to use.

func UpdateDeleteRange Uses

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

UpdateDeleteRange is only for emulator.

type DelRangeTask Uses

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

DelRangeTask is for run delete-range command in gc_worker.

func LoadDeleteRanges Uses

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

LoadDeleteRanges loads delete range tasks from gc_delete_range table.

func LoadDoneDeleteRanges Uses

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

LoadDoneDeleteRanges loads deleted ranges from gc_delete_range_done table.

func (DelRangeTask) Range Uses

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

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

type Event Uses

type Event struct {
    Tp         model.ActionType
    TableInfo  *model.TableInfo
    ColumnInfo *model.ColumnInfo
    IndexInfo  *model.IndexInfo
}

Event is an event that a ddl operation happened.

func (*Event) String Uses

func (e *Event) String() string

String implements fmt.Stringer interface.

type SchemaSyncer Uses

type SchemaSyncer interface {
    // Init sets the global schema version path to etcd if it isn't exist,
    // then watch this path, and initializes the self schema version to etcd.
    Init(ctx context.Context) error
    // UpdateSelfVersion updates the current version to the self path on etcd.
    UpdateSelfVersion(ctx context.Context, version int64) error
    // RemoveSelfVersionPath remove the self path from etcd.
    RemoveSelfVersionPath() error
    // OwnerUpdateGlobalVersion updates the latest version to the global path on etcd until updating is successful or the ctx is done.
    OwnerUpdateGlobalVersion(ctx context.Context, version int64) error
    // GlobalVersionCh gets the chan for watching global version.
    GlobalVersionCh() clientv3.WatchChan
    // WatchGlobalSchemaVer watches the global schema version.
    WatchGlobalSchemaVer(ctx context.Context)
    // MustGetGlobalVersion gets the global version. The only reason it fails is that ctx is done.
    MustGetGlobalVersion(ctx context.Context) (int64, error)
    // Done returns a channel that closes when the syncer is no longer being refreshed.
    Done() <-chan struct{}
    // Restart restarts the syncer when it's on longer being refreshed.
    Restart(ctx context.Context) error
    // OwnerCheckAllVersions checks whether all followers' schema version are equal to
    // the latest schema version. If the result is false, wait for a while and check again util the processing time reach 2 * lease.
    // It returns until all servers' versions are equal to the latest version or the ctx is done.
    OwnerCheckAllVersions(ctx context.Context, latestVer int64) error
    // NotifyCleanExpiredPaths informs to clean up expired paths.
    // The returned value is used for testing.
    NotifyCleanExpiredPaths() bool
    // StartCleanWork starts to clean up tasks.
    StartCleanWork()
    // CloseCleanWork ends cleanup tasks.
    CloseCleanWork()
}

SchemaSyncer is used to synchronize schema version between the DDL worker leader and followers through etcd.

func NewSchemaSyncer Uses

func NewSchemaSyncer(etcdCli *clientv3.Client, id string, oc ownerChecker) SchemaSyncer

NewSchemaSyncer creates a new SchemaSyncer.

Package util imports 25 packages (graph) and is imported by 27 packages. Updated 2019-09-03. Refresh now. Tools for package owners.