Documentation ¶
Index ¶
- Constants
- func CopyMapKeys(m interface{}, typeHint interface{}) interface{}
- func CopyMapValues(m interface{}, typeHint interface{}) interface{}
- func GetAllTablets(ts topo.Server, cell string) ([]*topo.TabletInfo, error)
- func GetAllTabletsAccrossCells(ts topo.Server) ([]*topo.TabletInfo, error)
- func GetTabletMap(ts topo.Server, tabletAliases []topo.TabletAlias) (map[topo.TabletAlias]*topo.TabletInfo, error)
- func GetTabletMapForShard(ts topo.Server, keyspace, shard string) (map[topo.TabletAlias]*topo.TabletInfo, error)
- func SignalInterrupt()
- func WriteAddr(zconn zk.Conn, zkPath string, addr *zkns.ZknsAddr) error
- func WriteAddrs(zconn zk.Conn, zkPath string, addrs *LegacyZknsAddrs) error
- type KeyspaceNodes
- type LegacyZknsAddrs
- type ShardNodes
- type TabletNode
- type TabletNodesByType
- type TabletStatus
- type Topology
- type Wrangler
- func (wr *Wrangler) ActionInitiator() *tm.ActionInitiator
- func (wr *Wrangler) ApplySchema(tabletAlias topo.TabletAlias, sc *mysqlctl.SchemaChange) (*mysqlctl.SchemaChangeResult, error)
- func (wr *Wrangler) ApplySchemaKeyspace(keyspace string, change string, simple, force bool) (*mysqlctl.SchemaChangeResult, error)
- func (wr *Wrangler) ApplySchemaShard(keyspace, shard, change string, newParentTabletAlias topo.TabletAlias, ...) (*mysqlctl.SchemaChangeResult, error)
- func (wr *Wrangler) ChangeType(tabletAlias topo.TabletAlias, dbType topo.TabletType, force bool) error
- func (wr *Wrangler) Clone(srcTabletAlias topo.TabletAlias, dstTabletAliases []topo.TabletAlias, ...) error
- func (wr *Wrangler) DbTopology() (*Topology, error)
- func (wr *Wrangler) ExecuteHook(tabletAlias topo.TabletAlias, hook *hk.Hook) (hookResult *hk.HookResult, err error)
- func (wr *Wrangler) ExecuteOptionalTabletInfoHook(ti *topo.TabletInfo, hook *hk.Hook) (err error)
- func (wr *Wrangler) ExecuteTabletInfoHook(ti *topo.TabletInfo, hook *hk.Hook) (hookResult *hk.HookResult, err error)
- func (wr *Wrangler) ExportZkns(cell string) error
- func (wr *Wrangler) ExportZknsForKeyspace(keyspace string) error
- func (wr *Wrangler) GetPermissions(tabletAlias topo.TabletAlias) (*mysqlctl.Permissions, error)
- func (wr *Wrangler) GetSchema(tabletAlias topo.TabletAlias, tables []string, includeViews bool) (*mysqlctl.SchemaDefinition, error)
- func (wr *Wrangler) GetSchemaTablet(tablet *topo.TabletInfo, tables []string, includeViews bool) (*mysqlctl.SchemaDefinition, error)
- func (wr *Wrangler) GetVersion(tabletAlias topo.TabletAlias) (string, error)
- func (wr *Wrangler) InitTablet(tabletAlias topo.TabletAlias, ...) error
- func (wr *Wrangler) MultiSnapshot(keyRanges []key.KeyRange, tabletAlias topo.TabletAlias, keyName string, ...) (manifests []string, parent topo.TabletAlias, err error)
- func (wr *Wrangler) PartialClone(srcTabletAlias, dstTabletAlias topo.TabletAlias, keyName string, ...) error
- func (wr *Wrangler) PartialRestore(srcTabletAlias topo.TabletAlias, srcFilePath string, ...) error
- func (wr *Wrangler) PartialSnapshot(tabletAlias topo.TabletAlias, keyName string, ...) (manifest string, parent topo.TabletAlias, err error)
- func (wr *Wrangler) PreflightSchema(tabletAlias topo.TabletAlias, change string) (*mysqlctl.SchemaChangeResult, error)
- func (wr *Wrangler) RebuildKeyspaceGraph(keyspace string, cells []string) error
- func (wr *Wrangler) RebuildReplicationGraph(cells []string, keyspaces []string) error
- func (wr *Wrangler) RebuildShardGraph(keyspace, shard string, cells []string) error
- func (wr *Wrangler) ReparentShard(keyspace, shard string, masterElectTabletAlias topo.TabletAlias, ...) error
- func (wr *Wrangler) ReparentTablet(tabletAlias topo.TabletAlias) error
- func (wr *Wrangler) ReserveForRestore(srcTabletAlias, dstTabletAlias topo.TabletAlias) (err error)
- func (wr *Wrangler) ResetActionTimeout(actionTimeout time.Duration)
- func (wr *Wrangler) Restore(srcTabletAlias topo.TabletAlias, srcFilePath string, ...) error
- func (wr *Wrangler) RestoreFromMultiSnapshot(dstTabletAlias topo.TabletAlias, sources []topo.TabletAlias, ...) error
- func (wr *Wrangler) Scrap(tabletAlias topo.TabletAlias, force, skipRebuild bool) (actionPath string, err error)
- func (wr *Wrangler) ShardExternallyReparented(keyspace, shard string, masterElectTabletAlias topo.TabletAlias, ...) error
- func (wr *Wrangler) ShardReplicationPositions(keyspace, shard string) ([]*topo.TabletInfo, []*mysqlctl.ReplicationPosition, error)
- func (wr *Wrangler) Snapshot(tabletAlias topo.TabletAlias, forceMasterSnapshot bool, ...) (manifest string, parent topo.TabletAlias, slaveStartRequired, readOnly bool, ...)
- func (wr *Wrangler) SnapshotSourceEnd(tabletAlias topo.TabletAlias, slaveStartRequired, readWrite bool, ...) (err error)
- func (wr *Wrangler) TopoServer() topo.Server
- func (wr *Wrangler) UnreserveForRestore(dstTabletAlias topo.TabletAlias) (err error)
- func (wr *Wrangler) UnreserveForRestoreMulti(dstTabletAliases []topo.TabletAlias)
- func (wr *Wrangler) Validate(pingTablets bool) error
- func (wr *Wrangler) ValidateKeyspace(keyspace string, pingTablets bool) error
- func (wr *Wrangler) ValidatePermissionsKeyspace(keyspace string) error
- func (wr *Wrangler) ValidatePermissionsShard(keyspace, shard string) error
- func (wr *Wrangler) ValidateSchemaKeyspace(keyspace string, includeViews bool) error
- func (wr *Wrangler) ValidateSchemaShard(keyspace, shard string, includeViews bool) error
- func (wr *Wrangler) ValidateShard(keyspace, shard string, pingTablets bool) error
- func (wr *Wrangler) ValidateVersionKeyspace(keyspace string) error
- func (wr *Wrangler) ValidateVersionShard(keyspace, shard string) error
Constants ¶
const ( DefaultActionTimeout = 30 * time.Second DefaultLockTimeout = 30 * time.Second )
const (
SLAVE_STATUS_DEADLINE = 10e9
)
Variables ¶
This section is empty.
Functions ¶
func CopyMapKeys ¶
func CopyMapKeys(m interface{}, typeHint interface{}) interface{}
Copy keys from from map m into a new slice with the type specified by typeHint. Reflection can't make a new slice type just based on the key type AFAICT.
func CopyMapValues ¶
func CopyMapValues(m interface{}, typeHint interface{}) interface{}
func GetAllTablets ¶
Return a sorted list of tablets.
func GetAllTabletsAccrossCells ¶
func GetAllTabletsAccrossCells(ts topo.Server) ([]*topo.TabletInfo, error)
GetAllTabletsAccrossCells returns all tablets from known cells.
func GetTabletMap ¶
func GetTabletMap(ts topo.Server, tabletAliases []topo.TabletAlias) (map[topo.TabletAlias]*topo.TabletInfo, error)
If error is not nil, the results in the dictionary are incomplete.
func GetTabletMapForShard ¶
func GetTabletMapForShard(ts topo.Server, keyspace, shard string) (map[topo.TabletAlias]*topo.TabletInfo, error)
If error is not nil, the results in the dictionary are incomplete.
func SignalInterrupt ¶
func SignalInterrupt()
func WriteAddrs ¶
func WriteAddrs(zconn zk.Conn, zkPath string, addrs *LegacyZknsAddrs) error
Types ¶
type KeyspaceNodes ¶
type KeyspaceNodes map[string]TabletNodesByType
KeyspaceNodes represents all tablet nodes in a keyspace.
func (KeyspaceNodes) HasType ¶
func (ks KeyspaceNodes) HasType(name string) bool
HasType returns true if ks has any tablets with the named type.
func (KeyspaceNodes) ShardNodes ¶
func (ks KeyspaceNodes) ShardNodes() []*ShardNodes
ShardNodes returns all the shard nodes, in a reasonable order.
func (KeyspaceNodes) TabletTypes ¶
func (ks KeyspaceNodes) TabletTypes() []string
TabletTypes returns a slice of tablet type names this ks contains.
type LegacyZknsAddrs ¶
type LegacyZknsAddrs struct {
Endpoints []string `json:"endpoints"`
}
type ShardNodes ¶
type ShardNodes struct { TabletNodes TabletNodesByType Name string }
ShardNodes represents all tablet nodes for a shard. The keys are string representations of tablet types.
type TabletNode ¶
type TabletNode struct {
*topo.TabletInfo
}
TabletNode is the representation of a tablet in the db topology.
func (*TabletNode) ShortName ¶
func (t *TabletNode) ShortName() string
type TabletNodesByType ¶
type TabletNodesByType map[string][]*TabletNode
TabletNodesByType maps tablet types to slices of tablet nodes.
type TabletStatus ¶
type TabletStatus struct {
// contains filtered or unexported fields
}
local structure used to keep track of what we're doing
type Topology ¶
type Topology struct { Assigned map[string]KeyspaceNodes Idle []*TabletNode Scrap []*TabletNode }
func NewTopology ¶
func NewTopology() *Topology
type Wrangler ¶
type Wrangler struct {
// contains filtered or unexported fields
}
func New ¶
actionTimeout: how long should we wait for an action to complete? lockTimeout: how long should we wait for the initial lock to start a complex action?
This is distinct from actionTimeout because most of the time, we want to immediately know that out action will fail. However, automated action will need some time to arbitrate the locks.
func (*Wrangler) ActionInitiator ¶
func (wr *Wrangler) ActionInitiator() *tm.ActionInitiator
func (*Wrangler) ApplySchema ¶
func (wr *Wrangler) ApplySchema(tabletAlias topo.TabletAlias, sc *mysqlctl.SchemaChange) (*mysqlctl.SchemaChangeResult, error)
func (*Wrangler) ApplySchemaKeyspace ¶
func (wr *Wrangler) ApplySchemaKeyspace(keyspace string, change string, simple, force bool) (*mysqlctl.SchemaChangeResult, error)
apply a schema change to an entire keyspace. take a keyspace lock to do this. first we will validate the Preflight works the same on all shard masters and fail if not (unless force is specified) if simple, we just do it on all masters. if complex, we do the shell game in parallel on all shards
func (*Wrangler) ApplySchemaShard ¶
func (wr *Wrangler) ApplySchemaShard(keyspace, shard, change string, newParentTabletAlias topo.TabletAlias, simple, force bool) (*mysqlctl.SchemaChangeResult, error)
Note for 'complex' mode (the 'simple' mode is easy enough that we don't need to handle recovery that much): this method is able to recover if interrupted in the middle, because it knows which server has the schema change already applied, and will just pass through them very quickly.
func (*Wrangler) ChangeType ¶
func (wr *Wrangler) ChangeType(tabletAlias topo.TabletAlias, dbType topo.TabletType, force bool) error
Change the type of tablet and recompute all necessary derived paths in the serving graph. force: Bypass the vtaction system and make the data change directly, and do not run the remote hooks
func (*Wrangler) Clone ¶
func (wr *Wrangler) Clone(srcTabletAlias topo.TabletAlias, dstTabletAliases []topo.TabletAlias, forceMasterSnapshot bool, snapshotConcurrency, fetchConcurrency, fetchRetryCount int, serverMode bool) error
func (*Wrangler) DbTopology ¶
func (*Wrangler) ExecuteHook ¶
func (wr *Wrangler) ExecuteHook(tabletAlias topo.TabletAlias, hook *hk.Hook) (hookResult *hk.HookResult, err error)
func (*Wrangler) ExecuteOptionalTabletInfoHook ¶
Execute a hook and returns an error only if the hook failed, not if the hook doesn't exist.
func (*Wrangler) ExecuteTabletInfoHook ¶
func (wr *Wrangler) ExecuteTabletInfoHook(ti *topo.TabletInfo, hook *hk.Hook) (hookResult *hk.HookResult, err error)
func (*Wrangler) ExportZkns ¶
Export addresses from the VT serving graph to a legacy zkns server. Note these functions only work with a zktopo.
func (*Wrangler) ExportZknsForKeyspace ¶
Export addresses from the VT serving graph to a legacy zkns server.
func (*Wrangler) GetPermissions ¶
func (wr *Wrangler) GetPermissions(tabletAlias topo.TabletAlias) (*mysqlctl.Permissions, error)
func (*Wrangler) GetSchema ¶
func (wr *Wrangler) GetSchema(tabletAlias topo.TabletAlias, tables []string, includeViews bool) (*mysqlctl.SchemaDefinition, error)
func (*Wrangler) GetSchemaTablet ¶
func (wr *Wrangler) GetSchemaTablet(tablet *topo.TabletInfo, tables []string, includeViews bool) (*mysqlctl.SchemaDefinition, error)
func (*Wrangler) GetVersion ¶
func (wr *Wrangler) GetVersion(tabletAlias topo.TabletAlias) (string, error)
func (*Wrangler) InitTablet ¶
func (wr *Wrangler) InitTablet(tabletAlias topo.TabletAlias, hostname, mysqlPort, port, keyspace, shardId, tabletType string, parentAlias topo.TabletAlias, dbNameOverride string, force, update bool) error
InitTablet will create or update a tablet. If not parent is specified, and the tablet created is a slave type, we will find the appropriate parent.
func (*Wrangler) MultiSnapshot ¶
func (*Wrangler) PartialClone ¶
func (wr *Wrangler) PartialClone(srcTabletAlias, dstTabletAlias topo.TabletAlias, keyName string, startKey, endKey key.HexKeyspaceId, forceMasterSnapshot bool, concurrency, fetchConcurrency, fetchRetryCount int) error
func (*Wrangler) PartialRestore ¶
func (wr *Wrangler) PartialRestore(srcTabletAlias topo.TabletAlias, srcFilePath string, dstTabletAlias, parentAlias topo.TabletAlias, fetchConcurrency, fetchRetryCount int) error
func (*Wrangler) PartialSnapshot ¶
func (wr *Wrangler) PartialSnapshot(tabletAlias topo.TabletAlias, keyName string, startKey, endKey key.HexKeyspaceId, forceMasterSnapshot bool, concurrency int) (manifest string, parent topo.TabletAlias, err error)
forceMasterSnapshot: Normally a master is not a viable tablet to snapshot. However, there are degenerate cases where you need to override this, for instance the initial clone of a new master.
func (*Wrangler) PreflightSchema ¶
func (wr *Wrangler) PreflightSchema(tabletAlias topo.TabletAlias, change string) (*mysqlctl.SchemaChangeResult, error)
func (*Wrangler) RebuildKeyspaceGraph ¶
Rebuild the serving graph data while locking out other changes.
func (*Wrangler) RebuildReplicationGraph ¶
This is a quick and dirty tool to resurrect the TopologyServer data from the canonical data stored in the tablet nodes.
cells: local vt cells to scan for all tablets keyspaces: list of keyspaces to rebuild
func (*Wrangler) RebuildShardGraph ¶
Rebuild the serving and replication rollup data data while locking out other changes.
func (*Wrangler) ReparentShard ¶
func (wr *Wrangler) ReparentShard(keyspace, shard string, masterElectTabletAlias topo.TabletAlias, leaveMasterReadOnly, forceReparentToCurrentMaster bool) error
Create the reparenting action and launch a goroutine to coordinate the procedure.
leaveMasterReadOnly: leave the master in read-only mode, even
though all the other necessary updates have been made.
forceReparentToCurrentMaster: mostly for test setups, this can
cause data loss.
func (*Wrangler) ReparentTablet ¶
func (wr *Wrangler) ReparentTablet(tabletAlias topo.TabletAlias) error
Attempt to reparent this tablet to the current master, based on the current replication position. If there is no match, it will fail.
func (*Wrangler) ReserveForRestore ¶
func (wr *Wrangler) ReserveForRestore(srcTabletAlias, dstTabletAlias topo.TabletAlias) (err error)
func (*Wrangler) ResetActionTimeout ¶
ResetActionTimeout should be used before every action on a wrangler object that is going to be re-used: - vtctl will not call this, as it does one action - vtctld will call this, as it re-uses the same wrangler for actions
func (*Wrangler) Restore ¶
func (wr *Wrangler) Restore(srcTabletAlias topo.TabletAlias, srcFilePath string, dstTabletAlias, parentAlias topo.TabletAlias, fetchConcurrency, fetchRetryCount int, wasReserved, dontWaitForSlaveStart bool) error
func (*Wrangler) RestoreFromMultiSnapshot ¶
func (wr *Wrangler) RestoreFromMultiSnapshot(dstTabletAlias topo.TabletAlias, sources []topo.TabletAlias, concurrency, fetchConcurrency, insertTableConcurrency, fetchRetryCount int, strategy string) error
func (*Wrangler) Scrap ¶
func (wr *Wrangler) Scrap(tabletAlias topo.TabletAlias, force, skipRebuild bool) (actionPath string, err error)
Scrap a tablet. If force is used, we write to topo.Server directly and don't remote-execute the command.
func (*Wrangler) ShardExternallyReparented ¶
func (*Wrangler) ShardReplicationPositions ¶
func (wr *Wrangler) ShardReplicationPositions(keyspace, shard string) ([]*topo.TabletInfo, []*mysqlctl.ReplicationPosition, error)
func (*Wrangler) Snapshot ¶
func (wr *Wrangler) Snapshot(tabletAlias topo.TabletAlias, forceMasterSnapshot bool, snapshotConcurrency int, serverMode bool) (manifest string, parent topo.TabletAlias, slaveStartRequired, readOnly bool, originalType topo.TabletType, err error)
forceMasterSnapshot: Normally a master is not a viable tablet to snapshot. However, there are degenerate cases where you need to override this, for instance the initial clone of a new master.
func (*Wrangler) SnapshotSourceEnd ¶
func (wr *Wrangler) SnapshotSourceEnd(tabletAlias topo.TabletAlias, slaveStartRequired, readWrite bool, originalType topo.TabletType) (err error)
func (*Wrangler) TopoServer ¶
func (*Wrangler) UnreserveForRestore ¶
func (wr *Wrangler) UnreserveForRestore(dstTabletAlias topo.TabletAlias) (err error)
func (*Wrangler) UnreserveForRestoreMulti ¶
func (wr *Wrangler) UnreserveForRestoreMulti(dstTabletAliases []topo.TabletAlias)