shardddl

package
v0.0.0-...-be15534 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Optimist

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

Optimist is used to coordinate the shard DDL migration in optimism mode.

func NewOptimist

func NewOptimist(pLogger *log.Logger, getDownstreamMetaFunc func(string) (*dbconfig.DBConfig, string)) *Optimist

NewOptimist creates a new Optimist instance.

func (*Optimist) Close

func (o *Optimist) Close()

Close closes the Optimist instance.

func (*Optimist) Locks

func (o *Optimist) Locks() map[string]*optimism.Lock

Locks return all shard DDL locks current exist.

func (*Optimist) RemoveMetaDataWithTask

func (o *Optimist) RemoveMetaDataWithTask(task string) error

RemoveMetaDataWithTask removes meta data for a specified task NOTE: this function can only be used when the specified task is not running. This function only be used when --remove-meta or stop-task NOTE: For stop-task, we still delete drop columns in etcd though user may restart the task again later.

func (*Optimist) RemoveMetaDataWithTaskAndSources

func (o *Optimist) RemoveMetaDataWithTaskAndSources(task string, sources ...string) error

RemoveMetaDataWithTaskAndSources removes meta data for a specified task and sources NOTE: this function can only be used when the specified task for source is not running.

func (*Optimist) ShowLocks

func (o *Optimist) ShowLocks(task string, sources []string) ([]*pb.DDLLock, error)

ShowLocks is used by `show-ddl-locks` command.

func (*Optimist) Start

func (o *Optimist) Start(pCtx context.Context, etcdCli *clientv3.Client) error

Start starts the shard DDL coordination in optimism mode. NOTE: for logic errors, it should start without returning errors (but report via metrics or log) so that the user can fix them.

func (*Optimist) UnlockLock

func (o *Optimist) UnlockLock(ctx context.Context, id, source, upstreamSchema, upstreamTable string, action pb.UnlockDDLLockOp) error

UnlockLock unlocks a shard DDL lock manually only when using `unlock-ddl-lock` command. ID: the shard DDL lock ID. source, upstreamSchema, upstreamTable: reveal the upstream table's info which we need to skip/exec action: whether to skip/exec the blocking DDLs for the specified upstream table NOTE: this function has side effects, if it failed, some status can't revert anymore. NOTE: this function should not be called if the lock is still in automatic resolving.

type PessimismInfoSlice

type PessimismInfoSlice []pessimism.Info

PessimismInfoSlice attaches the methods of Interface to []pessimism.Info, sorting in increasing order according to `Source` field.

func (PessimismInfoSlice) Len

func (p PessimismInfoSlice) Len() int

Len implements Sorter.Len.

func (PessimismInfoSlice) Less

func (p PessimismInfoSlice) Less(i, j int) bool

Less implements Sorter.Less.

func (PessimismInfoSlice) Swap

func (p PessimismInfoSlice) Swap(i, j int)

Swap implements Sorter.Swap.

type Pessimist

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

Pessimist used to coordinate the shard DDL migration in pessimism mode.

func NewPessimist

func NewPessimist(pLogger *log.Logger, taskSources func(task string) []string) *Pessimist

NewPessimist creates a new Pessimist instance.

func (*Pessimist) Close

func (p *Pessimist) Close()

Close closes the Pessimist instance.

func (*Pessimist) Locks

func (p *Pessimist) Locks() map[string]*pessimism.Lock

Locks return all shard DDL locks current exist.

func (*Pessimist) RemoveMetaData

func (p *Pessimist) RemoveMetaData(task string) error

RemoveMetaData removes meta data for a specified task NOTE: this function can only be used when the specified task is not running.

func (*Pessimist) ShowLocks

func (p *Pessimist) ShowLocks(task string, sources []string) []*pb.DDLLock

ShowLocks is used by `show-ddl-locks` command.

func (*Pessimist) Start

func (p *Pessimist) Start(pCtx context.Context, etcdCli *clientv3.Client) error

Start starts the shard DDL coordination in pessimism mode. NOTE: for logic errors, it should start without returning errors (but report via metrics or log) so that the user can fix them.

func (*Pessimist) UnlockLock

func (p *Pessimist) UnlockLock(ctx context.Context, id, replaceOwner string, forceRemove bool) error

UnlockLock unlocks a shard DDL lock manually when using `unlock-ddl-lock` command. ID: the shard DDL lock ID. replaceOwner: the new owner used to replace the original DDL for executing DDL to downstream.

if the original owner is still exist, we should NOT specify any replaceOwner.

forceRemove: whether force to remove the DDL lock even fail to unlock it (for the owner).

if specified forceRemove and then fail to unlock, we may need to use `BreakLock` later.

NOTE: this function has side effects, if it failed, some status can't revert anymore. NOTE: this function should not be called if the lock is still in automatic resolving.

Jump to

Keyboard shortcuts

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