Documentation ¶
Overview ¶
Package wrangler contains the Wrangler object to manage complex topology actions.
Index ¶
- Constants
- Variables
- func ResetDebugVarsGetVersion()
- type CopyProgress
- type DiffMismatch
- type DiffReport
- type LogRecorder
- type ReplicationLocation
- type ReplicationStatus
- type ReplicationStatusResult
- type RowDiff
- type ShardReplicationStatus
- type TableCopyProgress
- type VDiffOutput
- type VReplicationWorkflow
- func (vrw *VReplicationWorkflow) CachedState() string
- func (vrw *VReplicationWorkflow) Cancel() error
- func (vrw *VReplicationWorkflow) Complete() (*[]string, error)
- func (vrw *VReplicationWorkflow) Create(ctx context.Context) error
- func (vrw *VReplicationWorkflow) CurrentState() string
- func (vrw *VReplicationWorkflow) Exists() bool
- func (vrw *VReplicationWorkflow) GetCopyProgress() (*CopyProgress, error)
- func (vrw *VReplicationWorkflow) GetStreamCount() (int64, int64, []*WorkflowError, error)
- func (vrw *VReplicationWorkflow) ReverseTraffic() (*[]string, error)
- func (vrw *VReplicationWorkflow) String() string
- func (vrw *VReplicationWorkflow) SwitchTraffic(direction workflow.TrafficSwitchDirection) (*[]string, error)
- type VReplicationWorkflowParams
- type VReplicationWorkflowType
- type WorkflowError
- type Wrangler
- func (wr *Wrangler) ChangeTabletType(ctx context.Context, tabletAlias *topodatapb.TabletAlias, ...) error
- func (wr *Wrangler) CopySchemaShard(ctx context.Context, sourceTabletAlias *topodatapb.TabletAlias, ...) error
- func (wr *Wrangler) CopySchemaShardFromShard(ctx context.Context, tables, excludeTables []string, includeViews bool, ...) error
- func (wr *Wrangler) CreateLookupVindex(ctx context.Context, keyspace string, specs *vschemapb.Keyspace, ...) error
- func (wr *Wrangler) DeleteShard(ctx context.Context, keyspace, shard string, recursive, evenIfServing bool) error
- func (wr *Wrangler) DeleteTablet(ctx context.Context, tabletAlias *topodatapb.TabletAlias, allowPrimary bool) (err error)
- func (wr *Wrangler) DropSources(ctx context.Context, targetKeyspace, workflowName string, ...) (*[]string, error)
- func (wr *Wrangler) DropTargets(ctx context.Context, targetKeyspace, workflow string, ...) (*[]string, error)
- func (wr *Wrangler) EmergencyReparentShard(ctx context.Context, keyspace, shard string, ...) (err error)
- func (wr *Wrangler) ExecuteFetchAsApp(ctx context.Context, tabletAlias *topodatapb.TabletAlias, usePool bool, ...) (*querypb.QueryResult, error)
- func (wr *Wrangler) ExecuteFetchAsDba(ctx context.Context, tabletAlias *topodatapb.TabletAlias, query string, ...) (*querypb.QueryResult, error)
- func (wr *Wrangler) ExternalizeVindex(ctx context.Context, qualifiedVindexName string) error
- func (wr *Wrangler) GetPermissions(ctx context.Context, tabletAlias *topodatapb.TabletAlias) (*tabletmanagerdatapb.Permissions, error)
- func (wr *Wrangler) GetVersion(ctx context.Context, tabletAlias *topodatapb.TabletAlias) (string, error)
- func (wr *Wrangler) InitShardPrimary(ctx context.Context, keyspace, shard string, ...) (err error)
- func (wr *Wrangler) ListActiveWorkflows(ctx context.Context, keyspace string) ([]string, error)
- func (wr *Wrangler) ListAllWorkflows(ctx context.Context, keyspace string, active bool) ([]string, error)
- func (wr *Wrangler) Logger() logutil.Logger
- func (wr *Wrangler) Materialize(ctx context.Context, ms *vtctldatapb.MaterializeSettings) error
- func (wr *Wrangler) MountExternalVitessCluster(ctx context.Context, clusterName, topoType, topoServer, topoRoot string) error
- func (wr *Wrangler) MoveTables(ctx context.Context, ...) error
- func (wr *Wrangler) NewVReplicationWorkflow(ctx context.Context, workflowType VReplicationWorkflowType, ...) (*VReplicationWorkflow, error)
- func (wr *Wrangler) PlannedReparentShard(ctx context.Context, keyspace, shard string, ...) (err error)
- func (wr *Wrangler) PreflightSchema(ctx context.Context, tabletAlias *topodatapb.TabletAlias, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)
- func (wr *Wrangler) QueryResultForRowsAffected(results map[*topo.TabletInfo]*sqltypes.Result) *sqltypes.Result
- func (wr *Wrangler) QueryResultForTabletResults(results map[*topo.TabletInfo]*sqltypes.Result) *sqltypes.Result
- func (wr *Wrangler) RefreshTabletState(ctx context.Context, tabletAlias *topodatapb.TabletAlias) error
- func (wr *Wrangler) ReparentTablet(ctx context.Context, tabletAlias *topodatapb.TabletAlias) error
- func (wr *Wrangler) Reshard(ctx context.Context, keyspace, workflow string, sources, targets []string, ...) error
- func (wr *Wrangler) SetLogger(logger logutil.Logger)
- func (wr *Wrangler) SetReplicationSource(ctx context.Context, tablet *topodatapb.Tablet) error
- func (wr *Wrangler) SetSourceShards(ctx context.Context, keyspace, shard string, sources []*topodatapb.TabletAlias, ...) error
- func (wr *Wrangler) ShowWorkflow(ctx context.Context, workflow, keyspace string) (*ReplicationStatusResult, error)
- func (wr *Wrangler) SourceShardAdd(ctx context.Context, keyspace, shard string, uid int32, ...) (err error)
- func (wr *Wrangler) SourceShardDelete(ctx context.Context, keyspace, shard string, uid int32) (err error)
- func (wr *Wrangler) StartReplication(ctx context.Context, tablet *topodatapb.Tablet) error
- func (wr *Wrangler) SwitchReads(ctx context.Context, targetKeyspace, workflowName string, ...) (*[]string, error)
- func (wr *Wrangler) SwitchWrites(ctx context.Context, targetKeyspace, workflowName string, ...) (journalID int64, dryRunResults *[]string, err error)
- func (wr *Wrangler) TabletExternallyReparented(ctx context.Context, newPrimaryAlias *topodatapb.TabletAlias) error
- func (wr *Wrangler) TabletManagerClient() tmclient.TabletManagerClient
- func (wr *Wrangler) TopoServer() *topo.Server
- func (wr *Wrangler) UnmountExternalVitessCluster(ctx context.Context, clusterName string) error
- func (wr *Wrangler) UpdateSrvKeyspacePartitions(ctx context.Context, keyspace, shard string, tabletType topodatapb.TabletType, ...) (err error)
- func (wr *Wrangler) VDiff(ctx context.Context, ...) (map[string]*DiffReport, error)
- func (wr *Wrangler) VDiff2(ctx context.Context, keyspace, workflowName string, action vdiff2.VDiffAction, ...) (*VDiffOutput, error)
- func (wr *Wrangler) VExec(ctx context.Context, workflow, keyspace, query string, dryRun bool) (map[*topo.TabletInfo]*sqltypes.Result, error)
- func (wr *Wrangler) VExecResult(ctx context.Context, workflow, keyspace, query string, dryRun bool) (qr *sqltypes.Result, err error)
- func (wr *Wrangler) VReplicationExec(ctx context.Context, tabletAlias *topodatapb.TabletAlias, query string) (*querypb.QueryResult, error)
- func (wr *Wrangler) Validate(ctx context.Context, pingTablets bool) error
- func (wr *Wrangler) ValidateKeyspace(ctx context.Context, keyspace string, pingTablets bool) error
- func (wr *Wrangler) ValidatePermissionsKeyspace(ctx context.Context, keyspace string) error
- func (wr *Wrangler) ValidatePermissionsShard(ctx context.Context, keyspace, shard string) error
- func (wr *Wrangler) ValidateSchemaKeyspace(ctx context.Context, keyspace string, excludeTables []string, ...) error
- func (wr *Wrangler) ValidateSchemaShard(ctx context.Context, keyspace, shard string, excludeTables []string, ...) error
- func (wr *Wrangler) ValidateShard(ctx context.Context, keyspace, shard string, pingTablets bool) error
- func (wr *Wrangler) ValidateVSchema(ctx context.Context, keyspace string, shards []string, excludeTables []string, ...) error
- func (wr *Wrangler) ValidateVersionKeyspace(ctx context.Context, keyspace string) error
- func (wr *Wrangler) ValidateVersionShard(ctx context.Context, keyspace, shard string) error
- func (wr *Wrangler) VtctldServer() vtctlservicepb.VtctldServer
- func (wr *Wrangler) WaitForFilteredReplication(ctx context.Context, keyspace, shard string, maxDelay time.Duration) error
- func (wr *Wrangler) WorkflowAction(ctx context.Context, workflow, keyspace, action string, dryRun bool, ...) (map[*topo.TabletInfo]*sqltypes.Result, error)
- func (wr *Wrangler) WorkflowTagAction(ctx context.Context, keyspace string, workflow string, tags string) (map[*topo.TabletInfo]*sqltypes.Result, error)
Constants ¶
const ( MoveTablesWorkflow = VReplicationWorkflowType(iota) ReshardWorkflow MigrateWorkflow )
VReplicationWorkflowType enums
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
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
const ( // DefaultFilteredReplicationWaitTime is the default value for argument filteredReplicationWaitTime. DefaultFilteredReplicationWaitTime = 30 * time.Second )
const ( // DefaultWaitForFilteredReplicationMaxDelay is the default maximum delay value used in WaitForFilteredReplication. DefaultWaitForFilteredReplicationMaxDelay = 30 * time.Second )
const ( // DefaultWaitReplicasTimeout is the default value for waitReplicasTimeout, which is used when calling method CopySchemaShardFromShard. DefaultWaitReplicasTimeout = 10 * time.Second )
Variables ¶
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 ¶
func ResetDebugVarsGetVersion ¶
func ResetDebugVarsGetVersion()
ResetDebugVarsGetVersion is used by tests to reset the getVersionFromTablet variable to the default one. That way we can run the unit tests in testlib/ even when another implementation of getVersionFromTablet is used.
Types ¶
type CopyProgress ¶ added in v0.9.0
type CopyProgress map[string]*TableCopyProgress
CopyProgress stores the TableCopyProgress for all tables still being copied
type DiffMismatch ¶ added in v0.11.0
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) 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 ¶ added in v0.8.0
ReplicationLocation represents a location that data is either replicating from, or replicating into.
type ReplicationStatus ¶ added in v0.8.0
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 ¶ added in v0.8.0
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 ShardReplicationStatus ¶ added in v0.8.0
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 ¶ added in v0.9.0
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 ¶ added in v0.14.0
type VDiffOutput struct { Request *tabletmanagerdata.VDiffRequest Responses map[string]*tabletmanagerdata.VDiffResponse Err error // contains filtered or unexported fields }
type VReplicationWorkflow ¶ added in v0.9.0
type VReplicationWorkflow struct {
// contains filtered or unexported fields
}
VReplicationWorkflow stores various internal objects for a workflow
func (*VReplicationWorkflow) CachedState ¶ added in v0.9.0
func (vrw *VReplicationWorkflow) CachedState() string
CachedState returns a human readable workflow state at the time the workflow was created
func (*VReplicationWorkflow) Cancel ¶ added in v0.9.0
func (vrw *VReplicationWorkflow) Cancel() error
Cancel deletes all artifacts from a workflow which has not yet been switched
func (*VReplicationWorkflow) Complete ¶ added in v0.9.0
func (vrw *VReplicationWorkflow) Complete() (*[]string, error)
Complete cleans up a successful workflow
func (*VReplicationWorkflow) Create ¶ added in v0.9.0
func (vrw *VReplicationWorkflow) Create(ctx context.Context) error
Create initiates a workflow
func (*VReplicationWorkflow) CurrentState ¶ added in v0.9.0
func (vrw *VReplicationWorkflow) CurrentState() string
CurrentState reloads and returns a human readable workflow state
func (*VReplicationWorkflow) Exists ¶ added in v0.9.0
func (vrw *VReplicationWorkflow) Exists() bool
Exists checks if the workflow has already been initiated
func (*VReplicationWorkflow) GetCopyProgress ¶ added in v0.9.0
func (vrw *VReplicationWorkflow) GetCopyProgress() (*CopyProgress, error)
GetCopyProgress returns the progress of all tables being copied in the workflow
func (*VReplicationWorkflow) GetStreamCount ¶ added in v0.9.0
func (vrw *VReplicationWorkflow) GetStreamCount() (int64, int64, []*WorkflowError, error)
GetStreamCount returns a count of total streams and of streams that have started processing
func (*VReplicationWorkflow) ReverseTraffic ¶ added in v0.9.0
func (vrw *VReplicationWorkflow) ReverseTraffic() (*[]string, error)
ReverseTraffic switches traffic backwards for tablet_types passed
func (*VReplicationWorkflow) String ¶ added in v0.9.0
func (vrw *VReplicationWorkflow) String() string
func (*VReplicationWorkflow) SwitchTraffic ¶ added in v0.9.0
func (vrw *VReplicationWorkflow) SwitchTraffic(direction workflow.TrafficSwitchDirection) (*[]string, error)
SwitchTraffic switches traffic in the direction passed for specified tablet_types
type VReplicationWorkflowParams ¶ added in v0.9.0
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 // Reshard specific SourceShards, TargetShards []string SkipSchemaCopy bool AutoStart, StopAfterCopy bool // MoveTables/Migrate and Reshard specific DeferSecondaryKeys bool // Migrate specific ExternalCluster string }
VReplicationWorkflowParams stores args and options passed to a VReplicationWorkflow command
type VReplicationWorkflowType ¶ added in v0.9.0
type VReplicationWorkflowType int
VReplicationWorkflowType specifies whether workflow is MoveTables or Reshard
type WorkflowError ¶ added in v0.9.0
WorkflowError has per stream errors if present in a workflow
func NewWorkflowError ¶ added in v0.9.0
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) // 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 NewTestWrangler ¶ added in v0.16.0
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, tabletTypes 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 ¶ added in v0.9.0
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, primaryElectTabletAlias *topodatapb.TabletAlias, waitReplicasTimeout time.Duration, ignoredTablets sets.Set[string], preventCrossCellPromotion bool) (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) ExternalizeVindex ¶
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 ¶ added in v0.12.0
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 ¶ added in v0.9.0
ListActiveWorkflows will return a list of all active workflows for the given keyspace.
func (*Wrangler) ListAllWorkflows ¶ added in v0.8.0
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) 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 ¶ added in v0.10.0
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, tabletTypes string, allTables bool, excludeTables string, autoStart, stopAfterCopy bool, externalCluster string, dropForeignKeys, deferSecondaryKeys bool, sourceTimeZone, onDDL string, sourceShards []string) error
MoveTables initiates moving table(s) over to another keyspace
func (*Wrangler) NewVReplicationWorkflow ¶ added in v0.9.0
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, primaryElectTabletAlias, avoidTabletAlias *topodatapb.TabletAlias, waitReplicasTimeout time.Duration) (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 ¶ added in v0.8.0
func (wr *Wrangler) QueryResultForRowsAffected(results map[*topo.TabletInfo]*sqltypes.Result) *sqltypes.Result
QueryResultForRowsAffected aggregates results into row-type results (fields + values)
func (*Wrangler) QueryResultForTabletResults ¶ added in v0.8.0
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) SetLogger ¶
SetLogger can be used to change the current logger. Not synchronized, no calls to this wrangler should be in progress.
func (*Wrangler) SetReplicationSource ¶ added in v0.13.0
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 ¶ added in v0.8.0
func (wr *Wrangler) ShowWorkflow(ctx context.Context, workflow, keyspace string) (*ReplicationStatusResult, error)
ShowWorkflow will return all of the relevant replication related information for the given workflow.
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 ¶ added in v0.13.0
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 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 ¶
TopoServer returns the topo.Server this wrangler is using.
func (*Wrangler) UnmountExternalVitessCluster ¶ added in v0.10.0
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 ¶ added in v0.14.0
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 ¶ added in v0.8.0
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) ValidateKeyspace ¶
ValidateKeyspace will validate a bunch of information in a keyspace is correct.
func (*Wrangler) ValidatePermissionsKeyspace ¶
ValidatePermissionsKeyspace validates all the permissions are the same in a keyspace
func (*Wrangler) ValidatePermissionsShard ¶
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 ¶ added in v0.11.0
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 ¶
ValidateVersionKeyspace validates all versions are the same in all tablets in a keyspace
func (*Wrangler) ValidateVersionShard ¶
ValidateVersionShard validates all versions are the same in all tablets in a shard
func (*Wrangler) VtctldServer ¶ added in v0.9.0
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) (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.
Source Files ¶
- external_cluster.go
- keyspace.go
- log_recorder.go
- materializer.go
- permissions.go
- reparent.go
- resharder.go
- schema.go
- shard.go
- split.go
- switcher.go
- switcher_dry_run.go
- switcher_interface.go
- tablet.go
- traffic_switcher.go
- validator.go
- vdiff.go
- vdiff2.go
- version.go
- vexec.go
- vexec_plan.go
- workflow.go
- wrangler.go
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. |