wrangler

package
v0.15.10 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 69 Imported by: 0

Documentation

Overview

Package wrangler contains the Wrangler object to manage complex topology actions.

Index

Constants

View Source
const (
	MoveTablesWorkflow = VReplicationWorkflowType(iota)
	ReshardWorkflow
	MigrateWorkflow
)

VReplicationWorkflowType enums

View Source
const (
	WorkflowStateNotCreated     = "Not Created"
	WorkflowStateNotSwitched    = "Reads Not Switched. Writes Not Switched"
	WorkflowStateReadsSwitched  = "All Reads Switched. Writes Not Switched"
	WorkflowStateWritesSwitched = "Reads Not Switched. Writes Switched"
	WorkflowStateAllSwitched    = "All Reads Switched. Writes Switched"
)

Workflow state display strings

View Source
const (
	ErrWorkflowNotFullySwitched  = "cannot complete workflow because you have not yet switched all read and write traffic"
	ErrWorkflowPartiallySwitched = "cannot cancel workflow because you have already switched some or all read and write traffic"
)

Workflow errors

View Source
const (
	// DefaultFilteredReplicationWaitTime is the default value for argument filteredReplicationWaitTime.
	DefaultFilteredReplicationWaitTime = 30 * time.Second
)
View Source
const (
	// DefaultWaitForFilteredReplicationMaxDelay is the default maximum delay value used in WaitForFilteredReplication.
	DefaultWaitForFilteredReplicationMaxDelay = 30 * time.Second
)

Variables

View Source
var (
	// DefaultActionTimeout is a good default for interactive
	// remote actions. We usually take a lock then do an action,
	// lock actions use RemoteOperationTimeout,
	// so basing this to be greater than RemoteOperationTimeout is good.
	// Use this as the default value for Context that need a deadline.
	DefaultActionTimeout = topo.RemoteOperationTimeout * 4
)

Functions

This section is empty.

Types

type CopyProgress

type CopyProgress map[string]*TableCopyProgress

CopyProgress stores the TableCopyProgress for all tables still being copied

type DiffMismatch

type DiffMismatch struct {
	Source *RowDiff
	Target *RowDiff
}

DiffMismatch is a sample of row diffs between source and target.

type DiffReport

type DiffReport struct {
	ProcessedRows        int
	MatchingRows         int
	MismatchedRows       int
	ExtraRowsSource      int
	ExtraRowsSourceDiffs []*RowDiff
	ExtraRowsTarget      int
	ExtraRowsTargetDiffs []*RowDiff
	MismatchedRowsSample []*DiffMismatch
	TableName            string
}

DiffReport is the summary of differences for one table.

type LogRecorder

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

LogRecorder is used to collect logs for a specific purpose. Not thread-safe since it is expected to be generated in repeatable sequence

func NewLogRecorder

func NewLogRecorder() *LogRecorder

NewLogRecorder creates a new instance of LogRecorder

func (*LogRecorder) GetLogs

func (lr *LogRecorder) GetLogs() []string

GetLogs returns all recorded logs in sequence

func (*LogRecorder) Log

func (lr *LogRecorder) Log(log string)

Log records a new log message

func (*LogRecorder) LogSlice

func (lr *LogRecorder) LogSlice(logs []string)

LogSlice sorts a given slice using natural sort, so that the result is predictable. Useful when logging arrays or maps where order of objects can vary

type ReplicationLocation

type ReplicationLocation struct {
	Keyspace string
	Shards   []string
}

ReplicationLocation represents a location that data is either replicating from, or replicating into.

type ReplicationStatus

type ReplicationStatus struct {
	// Shard represents the relevant shard name.
	Shard string
	// Tablet is the tablet alias that the ReplicationStatus came from.
	Tablet string
	// ID represents the id column from the _vt.vreplication table.
	ID int32
	// Bls represents the BinlogSource.
	Bls *binlogdatapb.BinlogSource
	// Pos represents the pos column from the _vt.vreplication table.
	Pos string
	// StopPos represents the stop_pos column from the _vt.vreplication table.
	StopPos string
	// State represents the state column from the _vt.vreplication table.
	State string
	// DbName represents the db_name column from the _vt.vreplication table.
	DBName string
	// TransactionTimestamp represents the transaction_timestamp column from the _vt.vreplication table.
	TransactionTimestamp int64
	// TimeUpdated represents the time_updated column from the _vt.vreplication table.
	TimeUpdated int64
	// TimeHeartbeat represents the time_heartbeat column from the _vt.vreplication table.
	TimeHeartbeat int64
	// TimeThrottled represents the time_throttled column from the _vt.vreplication table.
	TimeThrottled int64
	// ComponentThrottled represents the component_throttled column from the _vt.vreplication table.
	ComponentThrottled string
	// Message represents the message column from the _vt.vreplication table.
	Message string
	// Tags contain the tags specified for this stream
	Tags            string
	WorkflowType    string
	WorkflowSubType string
	// CopyState represents the rows from the _vt.copy_state table.
	CopyState []copyState
	// RowsCopied shows the number of rows copied per stream, only valid when workflow state is "Copying"
	RowsCopied int64
	// contains filtered or unexported fields
}

ReplicationStatus includes data from the _vt.vreplication table, along with other useful relevant data.

type ReplicationStatusResult

type ReplicationStatusResult struct {
	// Workflow represents the name of the workflow relevant to the related replication statuses.
	Workflow string
	// SourceLocation represents the keyspace and shards that we are vreplicating from.
	SourceLocation ReplicationLocation
	// TargetLocation represents the keyspace and shards that we are vreplicating into.
	TargetLocation ReplicationLocation
	// MaxVReplicationLag represents the lag between the current time and the last time an event was seen from the
	// source shards. This defines the "liveness" of the source streams. This will be high only if one of the source streams
	// is no longer running (say, due to a network partition , primary not being available, or a vstreamer failure)
	// MaxVReplicationTransactionLag (see below) represents the "mysql" replication lag, i.e. how far behind we are in
	// terms of data replication from the source to the target.
	MaxVReplicationLag int64
	// MaxVReplicationTransactionLag represents the lag across all shards, between the current time and the timestamp
	// of the last transaction OR heartbeat timestamp (if there have been no writes to replicate from the source).
	MaxVReplicationTransactionLag int64
	// Frozen is true if this workflow has been deemed complete and is in a limbo "frozen" state (Message=="FROZEN")
	Frozen bool
	// Statuses is a map of <shard>/<primary tablet alias> : ShardReplicationStatus (for the given shard).
	ShardStatuses map[string]*ShardReplicationStatus
	// SourceTimeZone represents the time zone provided to the workflow, only set if not UTC
	SourceTimeZone string
	// TargetTimeZone is set to the original SourceTimeZone, in reverse streams, if it was provided to the workflow
	TargetTimeZone string
	// OnDDL specifies the action to be taken when a DDL is encountered.
	OnDDL string `json:"OnDDL,omitempty"`
	// DeferSecondaryKeys specifies whether to defer the creation of secondary keys.
	DeferSecondaryKeys bool `json:"DeferSecondaryKeys,omitempty"`
}

ReplicationStatusResult represents the result of trying to get the replication status for a given workflow.

type RowDiff

type RowDiff struct {
	Row   map[string]sqltypes.Value
	Query string
}

RowDiff is a row that didn't match as part of the comparison.

type ShardReplicationStatus

type ShardReplicationStatus struct {
	// PrimaryReplicationStatuses represents all of the replication statuses for the primary tablets in the given shard.
	PrimaryReplicationStatuses []*ReplicationStatus
	// TabletControls represents the tablet controls for the tablets in the shard.
	TabletControls []*topodatapb.Shard_TabletControl
	// PrimaryIsServing indicates whether the primary tablet of the given shard is currently serving write traffic.
	PrimaryIsServing bool
}

ShardReplicationStatus holds relevant vreplication related info for the given shard.

type TableCopyProgress

type TableCopyProgress struct {
	TargetRowCount, TargetTableSize int64
	SourceRowCount, SourceTableSize int64
}

TableCopyProgress stores the row counts and disk sizes of the source and target tables

type VDiffOutput

type VDiffOutput struct {
	Request   *tabletmanagerdata.VDiffRequest
	Responses map[string]*tabletmanagerdata.VDiffResponse
	Err       error
	// contains filtered or unexported fields
}

type VReplicationWorkflow

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

VReplicationWorkflow stores various internal objects for a workflow

func (*VReplicationWorkflow) CachedState

func (vrw *VReplicationWorkflow) CachedState() string

CachedState returns a human readable workflow state at the time the workflow was created

func (*VReplicationWorkflow) Cancel

func (vrw *VReplicationWorkflow) Cancel() error

Cancel deletes all artifacts from a workflow which has not yet been switched

func (*VReplicationWorkflow) Complete

func (vrw *VReplicationWorkflow) Complete() (*[]string, error)

Complete cleans up a successful workflow

func (*VReplicationWorkflow) Create

func (vrw *VReplicationWorkflow) Create(ctx context.Context) error

Create initiates a workflow

func (*VReplicationWorkflow) CurrentState

func (vrw *VReplicationWorkflow) CurrentState() string

CurrentState reloads and returns a human readable workflow state

func (*VReplicationWorkflow) Exists

func (vrw *VReplicationWorkflow) Exists() bool

Exists checks if the workflow has already been initiated

func (*VReplicationWorkflow) GetCopyProgress

func (vrw *VReplicationWorkflow) GetCopyProgress() (*CopyProgress, error)

GetCopyProgress returns the progress of all tables being copied in the workflow

func (*VReplicationWorkflow) GetStreamCount

func (vrw *VReplicationWorkflow) GetStreamCount(shards []string) (int64, int64, []*WorkflowError, error)

GetStreamCount returns a count of total streams and of streams that have started processing

func (*VReplicationWorkflow) IsPartialMigration

func (vrw *VReplicationWorkflow) IsPartialMigration() bool

func (*VReplicationWorkflow) ReverseTraffic

func (vrw *VReplicationWorkflow) ReverseTraffic() (*[]string, error)

ReverseTraffic switches traffic backwards for tablet_types passed

func (*VReplicationWorkflow) String

func (vrw *VReplicationWorkflow) String() string

func (*VReplicationWorkflow) SwitchTraffic

func (vrw *VReplicationWorkflow) SwitchTraffic(direction workflow.TrafficSwitchDirection) (*[]string, error)

SwitchTraffic switches traffic in the direction passed for specified tablet_types

type VReplicationWorkflowParams

type VReplicationWorkflowParams struct {
	WorkflowType                      VReplicationWorkflowType
	Workflow, TargetKeyspace          string
	Cells, TabletTypes, ExcludeTables string
	EnableReverseReplication, DryRun  bool
	KeepData                          bool
	KeepRoutingRules                  bool
	Timeout                           time.Duration
	Direction                         workflow.TrafficSwitchDirection
	MaxAllowedTransactionLagSeconds   int64
	OnDDL                             string

	// MoveTables/Migrate specific
	SourceKeyspace, Tables    string
	AllTables, RenameTables   bool
	SourceTimeZone            string
	DropForeignKeys           bool
	InitializeTargetSequences bool
	AtomicCopy                bool

	// Reshard specific
	SourceShards, TargetShards []string
	SkipSchemaCopy             bool
	AutoStart, StopAfterCopy   bool

	// MoveTables/Migrate and Reshard specific
	DeferSecondaryKeys bool

	// Migrate specific
	ExternalCluster string

	// MoveTables only
	NoRoutingRules bool

	// Only these shards will be expected to participate in the workflow. Expects user to know what they are doing
	// and provide the correct set of shards associated with the workflow. This is for reducing latency for workflows
	// that only use a small set of shards in a keyspace with a large number of shards.
	ShardSubset []string
}

VReplicationWorkflowParams stores args and options passed to a VReplicationWorkflow command

type VReplicationWorkflowType

type VReplicationWorkflowType int

VReplicationWorkflowType specifies whether workflow is MoveTables or Reshard

type WorkflowError

type WorkflowError struct {
	Tablet      string
	ID          int32
	Description string
}

WorkflowError has per stream errors if present in a workflow

func NewWorkflowError

func NewWorkflowError(tablet string, id int32, description string) *WorkflowError

NewWorkflowError returns a new WorkflowError object

type Wrangler

type Wrangler struct {

	// VExecFunc is a test-only fixture that allows us to short circuit vexec commands.
	// DO NOT USE in production code.
	VExecFunc func(ctx context.Context, workflow, keyspace, query string, dryRun bool) (map[*topo.TabletInfo]*sqltypes.Result, error)

	WorkflowParams *VReplicationWorkflowParams
	// contains filtered or unexported fields
}

Wrangler manages complex actions on the topology, like reparents, backups, resharding, ...

Multiple go routines can use the same Wrangler at the same time, provided they want to share the same logger / topo server / lock timeout.

func New

New creates a new Wrangler object.

func NewTestWrangler

func NewTestWrangler(logger logutil.Logger, ts *topo.Server, tmc tmclient.TabletManagerClient) *Wrangler

NewTestWrangler creates a new Wrangler object for use in tests. This should NOT be used in production.

func (*Wrangler) ChangeTabletType

func (wr *Wrangler) ChangeTabletType(ctx context.Context, tabletAlias *topodatapb.TabletAlias, tabletType topodatapb.TabletType) error

ChangeTabletType changes the type of tablet and recomputes all necessary derived paths in the serving graph, if necessary.

Note we don't update the primary record in the Shard here, as we can't ChangeType from and out of primary anyway.

func (*Wrangler) CopySchemaShard

func (wr *Wrangler) CopySchemaShard(ctx context.Context, sourceTabletAlias *topodatapb.TabletAlias, tables, excludeTables []string, includeViews bool, destKeyspace, destShard string, waitReplicasTimeout time.Duration, skipVerify bool) error

CopySchemaShard copies the schema from a source tablet to the specified shard. The schema is applied directly on the primary of the destination shard, and is propagated to the replicas through binlogs.

func (*Wrangler) CopySchemaShardFromShard

func (wr *Wrangler) CopySchemaShardFromShard(ctx context.Context, tables, excludeTables []string, includeViews bool, sourceKeyspace, sourceShard, destKeyspace, destShard string, waitReplicasTimeout time.Duration, skipVerify bool) error

CopySchemaShardFromShard copies the schema from a source shard to the specified destination shard. For both source and destination it picks the primary tablet. See also CopySchemaShard.

func (*Wrangler) CreateLookupVindex

func (wr *Wrangler) CreateLookupVindex(ctx context.Context, keyspace string, specs *vschemapb.Keyspace, cell, tabletTypesStr string, continueAfterCopyWithOwner bool) error

CreateLookupVindex creates a lookup vindex and sets up the backfill.

func (*Wrangler) DeleteShard

func (wr *Wrangler) DeleteShard(ctx context.Context, keyspace, shard string, recursive, evenIfServing bool) error

DeleteShard will do all the necessary changes in the topology server to entirely remove a shard.

func (*Wrangler) DeleteTablet

func (wr *Wrangler) DeleteTablet(ctx context.Context, tabletAlias *topodatapb.TabletAlias, allowPrimary bool) (err error)

DeleteTablet removes a tablet from a shard. - if allowPrimary is set, we can Delete a primary tablet (and clear its record from the Shard record if it was the primary).

func (*Wrangler) DropSources

func (wr *Wrangler) DropSources(ctx context.Context, targetKeyspace, workflowName string, removalType workflow.TableRemovalType, keepData, keepRoutingRules, force, dryRun bool) (*[]string, error)

DropSources cleans up source tables, shards and denied tables after a MoveTables/Reshard is completed.

func (*Wrangler) DropTargets

func (wr *Wrangler) DropTargets(ctx context.Context, targetKeyspace, workflow string, keepData, keepRoutingRules, dryRun bool) (*[]string, error)

DropTargets cleans up target tables, shards and denied tables if a MoveTables/Reshard is cancelled.

func (*Wrangler) EmergencyReparentShard

func (wr *Wrangler) EmergencyReparentShard(ctx context.Context, keyspace, shard string, opts reparentutil.EmergencyReparentOptions) (err error)

EmergencyReparentShard will make the provided tablet the primary for the shard, when the old primary is completely unreachable.

func (*Wrangler) ExecuteFetchAsApp

func (wr *Wrangler) ExecuteFetchAsApp(ctx context.Context, tabletAlias *topodatapb.TabletAlias, usePool bool, query string, maxRows int) (*querypb.QueryResult, error)

ExecuteFetchAsApp executes a query remotely using the App pool

func (*Wrangler) ExecuteFetchAsDba

func (wr *Wrangler) ExecuteFetchAsDba(ctx context.Context, tabletAlias *topodatapb.TabletAlias, query string, maxRows int, disableBinlogs bool, reloadSchema bool) (*querypb.QueryResult, error)

ExecuteFetchAsDba executes a query remotely using the DBA pool

func (*Wrangler) ExecuteMultiFetchAsDba

func (wr *Wrangler) ExecuteMultiFetchAsDba(ctx context.Context, tabletAlias *topodatapb.TabletAlias, sql string, maxRows int, disableBinlogs bool, reloadSchema bool) ([]*querypb.QueryResult, error)

ExecuteMultiFetchAsDba executes one or more queries remotely using the DBA pool

func (*Wrangler) ExternalizeVindex

func (wr *Wrangler) ExternalizeVindex(ctx context.Context, qualifiedVindexName string) error

ExternalizeVindex externalizes a lookup vindex that's finished backfilling or has caught up.

func (*Wrangler) GetPermissions

func (wr *Wrangler) GetPermissions(ctx context.Context, tabletAlias *topodatapb.TabletAlias) (*tabletmanagerdatapb.Permissions, error)

GetPermissions returns the permissions set on a remote tablet

func (*Wrangler) GetVersion

func (wr *Wrangler) GetVersion(ctx context.Context, tabletAlias *topodatapb.TabletAlias) (string, error)

GetVersion returns the version string from a tablet

func (*Wrangler) InitShardPrimary

func (wr *Wrangler) InitShardPrimary(ctx context.Context, keyspace, shard string, primaryElectTabletAlias *topodatapb.TabletAlias, force bool, waitReplicasTimeout time.Duration) (err error)

InitShardPrimary will make the provided tablet the primary for the shard.

func (*Wrangler) ListActiveWorkflows

func (wr *Wrangler) ListActiveWorkflows(ctx context.Context, keyspace string) ([]string, error)

ListActiveWorkflows will return a list of all active workflows for the given keyspace.

func (*Wrangler) ListAllWorkflows

func (wr *Wrangler) ListAllWorkflows(ctx context.Context, keyspace string, active bool) ([]string, error)

ListAllWorkflows will return a list of all workflows (Running and Stopped) for the given keyspace.

func (*Wrangler) Logger

func (wr *Wrangler) Logger() logutil.Logger

Logger returns the logger associated with this wrangler.

func (*Wrangler) Materialize

func (wr *Wrangler) Materialize(ctx context.Context, ms *vtctldatapb.MaterializeSettings) error

Materialize performs the steps needed to materialize a list of tables based on the materialization specs.

func (*Wrangler) MountExternalVitessCluster

func (wr *Wrangler) MountExternalVitessCluster(ctx context.Context, clusterName, topoType, topoServer, topoRoot string) error

MountExternalVitessCluster adds a topo record for cluster with specified parameters so that it is available to a Migrate command

func (*Wrangler) MoveTables

func (wr *Wrangler) MoveTables(ctx context.Context, workflow, sourceKeyspace, targetKeyspace, tableSpecs,
	cell, tabletTypesStr string, allTables bool, excludeTables string, autoStart, stopAfterCopy bool,
	externalCluster string, dropForeignKeys, deferSecondaryKeys bool, sourceTimeZone, onDDL string,
	sourceShards []string, noRoutingRules bool, atomicCopy bool) (err error)

MoveTables initiates moving table(s) over to another keyspace

func (*Wrangler) NewVReplicationWorkflow

func (wr *Wrangler) NewVReplicationWorkflow(ctx context.Context, workflowType VReplicationWorkflowType,
	params *VReplicationWorkflowParams) (*VReplicationWorkflow, error)

NewVReplicationWorkflow sets up a MoveTables or Reshard workflow based on options provided, deduces the state of the workflow from the persistent state stored in the vreplication table and the topo

func (*Wrangler) PlannedReparentShard

func (wr *Wrangler) PlannedReparentShard(
	ctx context.Context,
	keyspace, shard string,
	opts reparentutil.PlannedReparentOptions,
) (err error)

PlannedReparentShard will make the provided tablet the primary for the shard, when both the current and new primary are reachable and in good shape.

func (*Wrangler) PreflightSchema

func (wr *Wrangler) PreflightSchema(ctx context.Context, tabletAlias *topodatapb.TabletAlias, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)

PreflightSchema will try a schema change on the remote tablet.

func (*Wrangler) QueryResultForRowsAffected

func (wr *Wrangler) QueryResultForRowsAffected(results map[*topo.TabletInfo]*sqltypes.Result) *sqltypes.Result

QueryResultForRowsAffected aggregates results into row-type results (fields + values)

func (*Wrangler) QueryResultForTabletResults

func (wr *Wrangler) QueryResultForTabletResults(results map[*topo.TabletInfo]*sqltypes.Result) *sqltypes.Result

QueryResultForTabletResults aggregates given results into a "rows-affected" type result (no row data)

func (*Wrangler) RefreshTabletState

func (wr *Wrangler) RefreshTabletState(ctx context.Context, tabletAlias *topodatapb.TabletAlias) error

RefreshTabletState refreshes tablet state

func (*Wrangler) ReparentTablet

func (wr *Wrangler) ReparentTablet(ctx context.Context, tabletAlias *topodatapb.TabletAlias) error

ReparentTablet tells a tablet to reparent this tablet to the current primary, based on the current replication position. If there is no match, it will fail.

func (*Wrangler) Reshard

func (wr *Wrangler) Reshard(ctx context.Context, keyspace, workflow string, sources, targets []string,
	skipSchemaCopy bool, cell, tabletTypes, onDDL string, autoStart, stopAfterCopy, deferSecondaryKeys bool) error

Reshard initiates a resharding workflow.

func (*Wrangler) SQLParser

func (wr *Wrangler) SQLParser() *sqlparser.Parser

SQLParser returns the parser this wrangler is using.

func (*Wrangler) SetLogger

func (wr *Wrangler) SetLogger(logger logutil.Logger)

SetLogger can be used to change the current logger. Not synchronized, no calls to this wrangler should be in progress.

func (*Wrangler) SetReplicationSource

func (wr *Wrangler) SetReplicationSource(ctx context.Context, tablet *topodatapb.Tablet) error

SetReplicationSource is used to set the replication source on the specified tablet to the current shard primary (if available). It also figures out if the tablet should be sending semi-sync ACKs or not and passes that to the tabletmanager RPC. It does not start the replication forcefully. If we are unable to find the shard primary of the tablet from the topo server we exit out without any error.

func (*Wrangler) SetSourceShards

func (wr *Wrangler) SetSourceShards(ctx context.Context, keyspace, shard string, sources []*topodatapb.TabletAlias, tables []string) error

SetSourceShards is a utility function to override the SourceShards fields on a Shard.

func (*Wrangler) ShowWorkflow

func (wr *Wrangler) ShowWorkflow(ctx context.Context, workflow, keyspace string, shardSubset []string) (*ReplicationStatusResult, error)

ShowWorkflow will return all of the relevant replication related information for the given workflow. If shardSubset is nil, then all shards will be queried.

func (*Wrangler) SourceShardAdd

func (wr *Wrangler) SourceShardAdd(ctx context.Context, keyspace, shard string, uid int32, skeyspace, sshard string, keyRange *topodatapb.KeyRange, tables []string) (err error)

SourceShardAdd will add a new SourceShard inside a shard.

func (*Wrangler) SourceShardDelete

func (wr *Wrangler) SourceShardDelete(ctx context.Context, keyspace, shard string, uid int32) (err error)

SourceShardDelete will delete a SourceShard inside a shard, by index.

This takes the keyspace lock as not to interfere with resharding operations.

func (*Wrangler) StartReplication

func (wr *Wrangler) StartReplication(ctx context.Context, tablet *topodatapb.Tablet) error

StartReplication is used to start replication on the specified tablet It also finds out if the tablet should be sending semi-sync ACKs or not.

func (*Wrangler) SwitchReads

func (wr *Wrangler) SwitchReads(ctx context.Context, targetKeyspace, workflowName string, servedTypes []topodatapb.TabletType,
	cells []string, direction workflow.TrafficSwitchDirection, dryRun bool) (*[]string, error)

SwitchReads is a generic way of switching read traffic for a resharding workflow.

func (*Wrangler) SwitchWrites

func (wr *Wrangler) SwitchWrites(ctx context.Context, targetKeyspace, workflowName string, timeout time.Duration,
	cancel, reverse, reverseReplication bool, dryRun, initializeTargetSequences bool) (journalID int64, dryRunResults *[]string, err error)

SwitchWrites is a generic way of migrating write traffic for a resharding workflow.

func (*Wrangler) TabletExternallyReparented

func (wr *Wrangler) TabletExternallyReparented(ctx context.Context, newPrimaryAlias *topodatapb.TabletAlias) error

TabletExternallyReparented changes the type of new primary for this shard to PRIMARY and updates it's tablet record in the topo. Updating the shard record is handled by the new primary tablet

func (*Wrangler) TabletManagerClient

func (wr *Wrangler) TabletManagerClient() tmclient.TabletManagerClient

TabletManagerClient returns the tmclient.TabletManagerClient this wrangler is using.

func (*Wrangler) TopoServer

func (wr *Wrangler) TopoServer() *topo.Server

TopoServer returns the topo.Server this wrangler is using.

func (*Wrangler) UnmountExternalVitessCluster

func (wr *Wrangler) UnmountExternalVitessCluster(ctx context.Context, clusterName string) error

UnmountExternalVitessCluster deletes a mounted cluster from the topo

func (*Wrangler) UpdateSrvKeyspacePartitions

func (wr *Wrangler) UpdateSrvKeyspacePartitions(ctx context.Context, keyspace, shard string, tabletType topodatapb.TabletType, cells []string, remove bool) (err error)

UpdateSrvKeyspacePartitions changes the SrvKeyspaceGraph for a shard. It updates serving graph

This takes the keyspace lock as to not interfere with resharding operations.

func (*Wrangler) VDiff

func (wr *Wrangler) VDiff(ctx context.Context, targetKeyspace, workflowName, sourceCell, targetCell, tabletTypesStr string,
	filteredReplicationWaitTime time.Duration, format string, maxRows int64, tables string, debug, onlyPks bool,
	maxExtraRowsToCompare int) (map[string]*DiffReport, error)

VDiff reports differences between the sources and targets of a vreplication workflow.

func (*Wrangler) VDiff2

func (wr *Wrangler) VDiff2(ctx context.Context, keyspace, workflowName string, action vdiff2.VDiffAction, actionArg, uuid string,
	options *tabletmanagerdata.VDiffOptions) (*VDiffOutput, error)

func (*Wrangler) VExec

func (wr *Wrangler) VExec(ctx context.Context, workflow, keyspace, query string, dryRun bool) (map[*topo.TabletInfo]*sqltypes.Result, error)

VExec executes queries on a table on all primaries in the target keyspace of the workflow

func (*Wrangler) VExecResult

func (wr *Wrangler) VExecResult(ctx context.Context, workflow, keyspace, query string, dryRun bool) (qr *sqltypes.Result, err error)

VExecResult runs VExec and the naggregates the results into a single *sqltypes.Result

func (*Wrangler) VReplicationExec

func (wr *Wrangler) VReplicationExec(ctx context.Context, tabletAlias *topodatapb.TabletAlias, query string) (*querypb.QueryResult, error)

VReplicationExec executes a query remotely using the DBA pool

func (*Wrangler) Validate

func (wr *Wrangler) Validate(ctx context.Context, pingTablets bool) error

Validate a whole TopologyServer tree

func (*Wrangler) ValidateKeyspace

func (wr *Wrangler) ValidateKeyspace(ctx context.Context, keyspace string, pingTablets bool) error

ValidateKeyspace will validate a bunch of information in a keyspace is correct.

func (*Wrangler) ValidatePermissionsKeyspace

func (wr *Wrangler) ValidatePermissionsKeyspace(ctx context.Context, keyspace string) error

ValidatePermissionsKeyspace validates all the permissions are the same in a keyspace

func (*Wrangler) ValidatePermissionsShard

func (wr *Wrangler) ValidatePermissionsShard(ctx context.Context, keyspace, shard string) error

ValidatePermissionsShard validates all the permissions are the same in a shard

func (*Wrangler) ValidateSchemaKeyspace

func (wr *Wrangler) ValidateSchemaKeyspace(ctx context.Context, keyspace string, excludeTables []string, includeViews, skipNoPrimary bool, includeVSchema bool) error

ValidateSchemaKeyspace will diff the schema from all the tablets in the keyspace.

func (*Wrangler) ValidateSchemaShard

func (wr *Wrangler) ValidateSchemaShard(ctx context.Context, keyspace, shard string, excludeTables []string, includeViews bool, includeVSchema bool) error

ValidateSchemaShard will diff the schema from all the tablets in the shard.

func (*Wrangler) ValidateShard

func (wr *Wrangler) ValidateShard(ctx context.Context, keyspace, shard string, pingTablets bool) error

ValidateShard will validate a bunch of information in a shard is correct.

func (*Wrangler) ValidateVSchema

func (wr *Wrangler) ValidateVSchema(ctx context.Context, keyspace string, shards []string, excludeTables []string, includeViews bool) error

ValidateVSchema compares the schema of each primary tablet in "keyspace/shards..." to the vschema and errs if there are differences

func (*Wrangler) ValidateVersionKeyspace

func (wr *Wrangler) ValidateVersionKeyspace(ctx context.Context, keyspace string) error

ValidateVersionKeyspace validates all versions are the same in all tablets in a keyspace

func (*Wrangler) ValidateVersionShard

func (wr *Wrangler) ValidateVersionShard(ctx context.Context, keyspace, shard string) error

ValidateVersionShard validates all versions are the same in all tablets in a shard

func (*Wrangler) VtctldServer

func (wr *Wrangler) VtctldServer() vtctlservicepb.VtctldServer

VtctldServer returns the vtctlservicepb.VtctldServer implementation this wrangler is using.

func (*Wrangler) WaitForFilteredReplication

func (wr *Wrangler) WaitForFilteredReplication(ctx context.Context, keyspace, shard string, maxDelay time.Duration) error

WaitForFilteredReplication will wait until the Filtered Replication process has finished.

func (*Wrangler) WorkflowAction

func (wr *Wrangler) WorkflowAction(ctx context.Context, workflow, keyspace, action string, dryRun bool, rpcReq any,
	shards []string) (map[*topo.TabletInfo]*sqltypes.Result, error)

WorkflowAction can start/stop/update/delete or list streams in _vt.vreplication on all primaries in the target keyspace of the workflow. rpcReq is an optional argument for any actions that use the new RPC path. Today that is only the update action. When using the SQL interface this is ignored and you can pass nil.

func (*Wrangler) WorkflowTagAction

func (wr *Wrangler) WorkflowTagAction(ctx context.Context, keyspace string, workflow string, tags string) (map[*topo.TabletInfo]*sqltypes.Result, error)

WorkflowTagAction sets or clears the tags for a workflow in a keyspace.

Directories

Path Synopsis
Package testlib contains utility methods to include in unit tests to deal with topology common tasks, like fake tablets and action loops.
Package testlib contains utility methods to include in unit tests to deal with topology common tasks, like fake tablets and action loops.

Jump to

Keyboard shortcuts

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