onlineddl

package
v0.0.0-...-3831271 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrExecutorNotWritableTablet is generated when executor is asked to run a migration 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")
)

Functions

This section is empty.

Types

type Executor

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

Executor is a state machine running migrations

func NewExecutor

func NewExecutor(env tabletenv.Env, tabletAlias *topodatapb.TabletAlias, ts *topo.Server,
	lagThrottler *throttle.Throttler,
	tabletTypeFunc func() topodatapb.TabletType,
	toggleBufferTableFunc func(cancelCtx context.Context, tableName string, timeout time.Duration, bufferQueries bool),
	requestGCChecksFunc func(),
	isPreparedPoolEmpty func(tableName string) bool,
) *Executor

NewExecutor creates a new executor.

func (*Executor) CancelMigration

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

CancelMigration attempts to abort a scheduled or a running migration

func (*Executor) CancelPendingMigrations

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

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

func (*Executor) CleanupAllMigrations

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

CleanupMigration sets migration is ready for artifact cleanup. Artifacts are not immediately deleted: all we do is set retain_artifacts_seconds to a very small number (it's actually a negative) so that the next iteration of gcArtifacts() picks up the migration's artifacts and schedules them for deletion

func (*Executor) CleanupMigration

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

CleanupMigration sets migration is ready for artifact cleanup. Artifacts are not immediately deleted: all we do is set retain_artifacts_seconds to a very small number (it's actually a negative) so that the next iteration of gcArtifacts() picks up the migration's artifacts and schedules them for deletion

func (*Executor) Close

func (e *Executor) Close()

Close frees resources

func (*Executor) CompleteMigration

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

CompleteMigration clears the postpone_completion flag for a given migration, assuming it was set in the first place

func (*Executor) CompletePendingMigrations

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

CompletePendingMigrations completes all pending migrations (that are expected to run or are running) for this keyspace

func (*Executor) ExecuteWithVReplication

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) ForceCutOverMigration

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

ForceCutOverMigration markes the given migration for forced cut-over. This has two implications:

  • No backoff for the given migration's cut-over (cut-over will be attempted at the next scheduler cycle, irrespective of how many cut-over attempts have been made and when these attempts have been made).
  • During the cut-over, Online DDL will try and temrinate all existing queries on the migrated table, and transactions (killing their connections) holding a lock on the migrated table. This is likely to cause the cut-over to succeed. Of course, it's not guaranteed, and it's possible that next cut-over will fail. The force_cutover flag, once set, remains set, and so all future cut-over attempts will again KILL interfering queries and connections.

func (*Executor) ForceCutOverPendingMigrations

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

ForceCutOverPendingMigrations sets force_cutover flag for all pending migrations

func (*Executor) InitDBConfig

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

InitDBConfig initializes keyspace

func (*Executor) LaunchMigration

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

LaunchMigration clears the postpone_launch flag for a given migration, assuming it was set in the first place

func (*Executor) LaunchMigrations

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

LaunchMigrations launches all launch-postponed queued migrations for this keyspace

func (*Executor) Open

func (e *Executor) Open() error

Open opens database pool and initializes the schema

func (*Executor) RetryMigration

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

RetryMigration marks given migration for retry

func (*Executor) SetMigrationCutOverThreshold

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

func (*Executor) ShowMigrationLogs

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) ShowMigrations

func (e *Executor) ShowMigrations(ctx context.Context, show *sqlparser.Show) (result *sqltypes.Result, err error)

ShowMigrations shows migrations, optionally filtered by a condition

func (*Executor) SubmitMigration

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

SubmitMigration inserts a new migration request

func (*Executor) TabletAliasString

func (e *Executor) TabletAliasString() string

TabletAliasString returns tablet alias as string (duh)

func (*Executor) ThrottleAllMigrations

func (e *Executor) ThrottleAllMigrations(ctx context.Context, expireString string, ratioLiteral *sqlparser.Literal) (result *sqltypes.Result, err error)

ThrottleAllMigrations

func (*Executor) ThrottleMigration

func (e *Executor) ThrottleMigration(ctx context.Context, uuid string, expireString string, ratioLiteral *sqlparser.Literal) (result *sqltypes.Result, err error)

ThrottleMigration

func (*Executor) UnthrottleAllMigrations

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

UnthrottleAllMigrations

func (*Executor) UnthrottleMigration

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

UnthrottleMigration

type SpecialAlterPlan

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

func NewSpecialAlterOperation

func NewSpecialAlterOperation(operation specialAlterOperation, alterTable *sqlparser.AlterTable, createTable *sqlparser.CreateTable) *SpecialAlterPlan

func (*SpecialAlterPlan) Detail

func (p *SpecialAlterPlan) Detail(key string) string

func (*SpecialAlterPlan) SetDetail

func (p *SpecialAlterPlan) SetDetail(key string, val string) *SpecialAlterPlan

func (*SpecialAlterPlan) String

func (p *SpecialAlterPlan) String() string

type VRepl

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

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

func NewVRepl

func NewVRepl(
	env *vtenv.Environment,
	workflow string,
	keyspace string,
	shard string,
	dbName string,
	sourceCreateTable *sqlparser.CreateTable,
	targetCreateTable *sqlparser.CreateTable,
	alterQuery *sqlparser.AlterTable,
	analyzeTable bool,
) (*VRepl, error)

NewVRepl creates a VReplication handler for Online DDL

type VReplStream

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

VReplStream represents a row in _vt.vreplication table

func (*VReplStream) Lag

func (s *VReplStream) Lag() time.Duration

Lag returns the vreplication lag, as determined by the higher of the transaction timestamp and the time updated.

Jump to

Keyboard shortcuts

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