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: 14 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 used to coordinate the shard DDL migration in optimism mode.

func NewOptimist

func NewOptimist(pLogger *log.Logger, cli *clientv3.Client, task, source string) *Optimist

NewOptimist creates a new Optimist instance.

func (*Optimist) AddTable

func (o *Optimist) AddTable(info optimism.Info) (int64, error)

AddTable adds the table for the info into source tables, this is often called for `CREATE TABLE`.

func (*Optimist) CheckPersistentData

func (o *Optimist) CheckPersistentData(source string, schemas map[string]string, tables map[string]map[string]string) error

CheckPersistentData check and fix the persistent data.

NOTE: currently this function is not used because user will meet error at early version if set unsupported case-sensitive.

func (*Optimist) ConstructInfo

func (o *Optimist) ConstructInfo(upSchema, upTable, downSchema, downTable string,
	ddls []string, tiBefore *model.TableInfo, tisAfter []*model.TableInfo,
) optimism.Info

ConstructInfo constructs a shard DDL info.

func (*Optimist) DoneOperation

func (o *Optimist) DoneOperation(op optimism.Operation) error

DoneOperation marks the shard DDL lock operation as done.

func (*Optimist) DoneRedirectOperation

func (o *Optimist) DoneRedirectOperation(targetTableID string)

DoneRedirectOperation marks the redirect shard DDL lock operation as done.

func (*Optimist) GetOperation

func (o *Optimist) GetOperation(ctx context.Context, info optimism.Info, rev int64) (optimism.Operation, error)

GetOperation gets the shard DDL lock operation relative to the shard DDL info.

func (*Optimist) GetRedirectOperation

func (o *Optimist) GetRedirectOperation(ctx context.Context, info optimism.Info, rev int64)

func (*Optimist) Init

func (o *Optimist) Init(sourceTables map[string]map[string]map[string]map[string]struct{}) error

Init initializes the optimist with source tables. NOTE: this will PUT the initial source tables into etcd (and overwrite any previous existing tables). NOTE: we do not remove source tables for `stop-task` now, may need to handle it for `remove-meta`.

func (*Optimist) PendingInfo

func (o *Optimist) PendingInfo() *optimism.Info

PendingInfo returns the shard DDL info which is pending to handle.

func (*Optimist) PendingOperation

func (o *Optimist) PendingOperation() *optimism.Operation

PendingOperation returns the shard DDL lock operation which is pending to handle.

func (*Optimist) PendingRedirectOperation

func (o *Optimist) PendingRedirectOperation() (*optimism.Operation, string)

PendingRedirectOperation returns the shard DDL lock redirect operation which is pending to handle.

func (*Optimist) PutInfo

func (o *Optimist) PutInfo(info optimism.Info) (int64, error)

PutInfo puts the shard DDL info into etcd and returns the revision.

func (*Optimist) RemoveTable

func (o *Optimist) RemoveTable(info optimism.Info) (int64, error)

RemoveTable removes the table for the info from source tables, this is often called for `DROP TABLE`.

func (*Optimist) Reset

func (o *Optimist) Reset()

Reset resets the internal state of the optimist.

func (*Optimist) Tables

func (o *Optimist) Tables() [][]filter.Table

Tables clone and return tables first one is sourceTable, second one is targetTable.

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, cli *clientv3.Client, task, source string) *Pessimist

NewPessimist creates a new Pessimist instance.

func (*Pessimist) ConstructInfo

func (p *Pessimist) ConstructInfo(schema, table string, ddls []string) pessimism.Info

ConstructInfo constructs a shard DDL info.

func (*Pessimist) DoneOperationDeleteInfo

func (p *Pessimist) DoneOperationDeleteInfo(op pessimism.Operation, info pessimism.Info) error

DoneOperationDeleteInfo marks the shard DDL lock operation as done and delete the shard DDL info.

func (*Pessimist) GetOperation

func (p *Pessimist) GetOperation(ctx context.Context, info pessimism.Info, rev int64) (pessimism.Operation, error)

GetOperation gets the shard DDL lock operation relative to the shard DDL info.

func (*Pessimist) PendingInfo

func (p *Pessimist) PendingInfo() *pessimism.Info

PendingInfo returns the shard DDL info which is pending to handle.

func (*Pessimist) PendingOperation

func (p *Pessimist) PendingOperation() *pessimism.Operation

PendingOperation returns the shard DDL lock operation which is pending to handle.

func (*Pessimist) PutInfo

func (p *Pessimist) PutInfo(ctx context.Context, info pessimism.Info) (int64, error)

PutInfo puts the shard DDL info into etcd and returns the revision.

func (*Pessimist) Reset

func (p *Pessimist) Reset()

Reset resets the internal state of the pessimist.

Jump to

Keyboard shortcuts

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