onlineddl

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrExecutorNotWritableTablet  is generated when executor is asked to run gh-ost on a read-only server
	ErrExecutorNotWritableTablet = errors.New("cannot run migration on non-writable tablet")
	// ErrExecutorMigrationAlreadyRunning is generated when an attempt is made to run an operation that conflicts with a running migration
	ErrExecutorMigrationAlreadyRunning = errors.New("cannot run migration since a migration is already running")
	// ErrMigrationNotFound is returned by readMigration when given UUI cannot be found
	ErrMigrationNotFound = errors.New("migration not found")
)
View Source
var ApplyDDL = []string{
	sqlCreateSidecarDB,
	sqlCreateSchemaMigrationsTable,
	alterSchemaMigrationsTableRetries,
	alterSchemaMigrationsTableTablet,
	alterSchemaMigrationsTableArtifacts,
	alterSchemaMigrationsTableTabletFailure,
	alterSchemaMigrationsTableTabletFailureIndex,
	alterSchemaMigrationsTableProgress,
	alterSchemaMigrationsTableContext,
	alterSchemaMigrationsTableDDLAction,
	alterSchemaMigrationsTableMessage,
	alterSchemaMigrationsTableTableCompleteIndex,
	alterSchemaMigrationsTableETASeconds,
	alterSchemaMigrationsTableRowsCopied,
	alterSchemaMigrationsTableTableRows,
	alterSchemaMigrationsTableLogFile,
}

ApplyDDL ddls to be applied at the start

Functions

func GhostBinaryFileName

func GhostBinaryFileName() (fileName string, isOverride bool)

GhostBinaryFileName returns the full path+name of the gh-ost binary

func PTOSCFileName

func PTOSCFileName() (fileName string, isOverride bool)

PTOSCFileName returns the full path+name of the pt-online-schema-change binary Note that vttablet does not include pt-online-schema-change

func RandomHash

func RandomHash() string

RandomHash returns a 64 hex character random string

func ReadableTimestamp

func ReadableTimestamp() string

ReadableTimestamp returns a timestamp, in seconds resolution, that is human readable (as opposed to unix timestamp which is just a number), and which corresponds to the time now. Example: for Aug 25 2020, 16:04:25 we return "20200825160425"

func ToReadableTimestamp

func ToReadableTimestamp(t time.Time) string

ToReadableTimestamp returns a timestamp, in seconds resolution, that is human readable (as opposed to unix timestamp which is just a number) Example: for Aug 25 2020, 16:04:25 we return "20200825160425"

Types

type Executor

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

Executor wraps and manages the execution of a gh-ost migration.

func NewExecutor

func NewExecutor(env tabletenv.Env, tabletAlias *topodatapb.TabletAlias, ts *topo.Server, tabletTypeFunc func() topodatapb.TabletType) *Executor

NewExecutor creates a new gh-ost executor.

func (*Executor) CancelMigration added in v0.10.0

func (e *Executor) CancelMigration(ctx context.Context, uuid string, terminateRunningMigration bool, message string) (result *sqltypes.Result, err error)

CancelMigration attempts to abort a scheduled or a running migration

func (*Executor) CancelPendingMigrations added in v0.10.0

func (e *Executor) CancelPendingMigrations(ctx context.Context, message string) (result *sqltypes.Result, err error)

CancelPendingMigrations cancels all pending migrations (that are expected to run or are running) for this keyspace

func (*Executor) Close

func (e *Executor) Close()

Close frees resources

func (*Executor) ExecuteWithGhost

func (e *Executor) ExecuteWithGhost(ctx context.Context, onlineDDL *schema.OnlineDDL) error

ExecuteWithGhost validates and runs a gh-ost process. Validation included testing the backend MySQL server and the gh-ost binary itself Execution runs first a dry run, then an actual migration

func (*Executor) ExecuteWithPTOSC

func (e *Executor) ExecuteWithPTOSC(ctx context.Context, onlineDDL *schema.OnlineDDL) error

ExecuteWithPTOSC validates and runs a pt-online-schema-change process. Validation included testing the backend MySQL server and the pt-online-schema-change binary itself Execution runs first a dry run, then an actual migration

func (*Executor) ExecuteWithVReplication added in v0.10.0

func (e *Executor) ExecuteWithVReplication(ctx context.Context, onlineDDL *schema.OnlineDDL, revertMigration *schema.OnlineDDL) error

ExecuteWithVReplication sets up the grounds for a vreplication schema migration

func (*Executor) InitDBConfig

func (e *Executor) InitDBConfig(keyspace, shard, dbName string)

InitDBConfig initializes keysapce

func (*Executor) OnSchemaMigrationStatus

func (e *Executor) OnSchemaMigrationStatus(ctx context.Context,
	uuidParam, statusParam, dryrunParam, progressParam, etaParam, rowsCopiedParam string) (err error)

OnSchemaMigrationStatus is called by TabletServer's API, which is invoked by a running gh-ost migration's hooks.

func (*Executor) Open

func (e *Executor) Open() error

Open opens database pool and initializes the schema

func (*Executor) RetryMigration added in v0.10.0

func (e *Executor) RetryMigration(ctx context.Context, uuid string) (result *sqltypes.Result, err error)

RetryMigration marks given migration for retry

func (*Executor) ShowMigrationLogs added in v0.11.0

func (e *Executor) ShowMigrationLogs(ctx context.Context, stmt *sqlparser.ShowMigrationLogs) (result *sqltypes.Result, err error)

ShowMigrationLogs reads the migration log for a given migration

func (*Executor) SubmitMigration added in v0.11.0

func (e *Executor) SubmitMigration(
	ctx context.Context,
	stmt sqlparser.Statement,
) (result *sqltypes.Result, err error)

SubmitMigration inserts a new migration request

func (*Executor) TabletAliasString added in v0.9.0

func (e *Executor) TabletAliasString() string

TabletAliasString returns tablet alias as string (duh)

func (*Executor) VExec

func (e *Executor) VExec(ctx context.Context, vx *vexec.TabletVExec) (qr *querypb.QueryResult, err error)

VExec is called by a VExec invocation Implements vitess.io/vitess/go/vt/vttablet/vexec.Executor interface

type VRepl added in v0.10.0

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

VRepl is an online DDL helper for VReplication based migrations (ddl_strategy="online")

func NewVRepl added in v0.10.0

func NewVRepl(workflow, keyspace, shard, dbName, sourceTable, targetTable, alterOptions string) *VRepl

NewVRepl creates a VReplication handler for Online DDL

type VReplStream added in v0.10.0

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

VReplStream represents a row in _vt.vreplication table

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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