tabletmanager

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2016 License: BSD-3-Clause Imports: 56 Imported by: 0

Documentation

Overview

Package tabletmanager exports the ActionAgent object. It keeps the local tablet state, starts / stops all associated services (query service, update stream, binlog players, ...), and handles tabletmanager RPCs to update the state.

The agent is responsible for maintaining the tablet record in the topology server. Only 'vtctl DeleteTablet' should be run by other processes, everything else should ask the tablet server to make the change.

Most RPC calls lock the actionMutex, except the easy read-only ones. RPC calls that change the tablet record will also call updateState.

See rpc_server.go for all cases, and which actions take the actionMutex, and which run changeCallback.

Index

Constants

View Source
const (
	// BpmStateRunning indicates BinlogPlayerMap is running.
	BpmStateRunning int64 = iota
	// BpmStateStopped indicates BinlogPlayerMap has stopped.
	BpmStateStopped
)

Variables

View Source
var RegisterQueryServices []RegisterQueryService

RegisterQueryServices is a list of functions to call when the delayed registration is triggered.

Functions

func ConfigHTML

func ConfigHTML() template.HTML

ConfigHTML returns a formatted summary of health checking config values.

func RegisterBinlogPlayerMap

func RegisterBinlogPlayerMap(blm *BinlogPlayerMap)

RegisterBinlogPlayerMap registers the varz for the players.

func SetReparentFlags

func SetReparentFlags(timeout time.Duration)

SetReparentFlags changes flag values. It should only be used in tests.

Types

type ActionAgent

type ActionAgent struct {
	// The following fields are set during creation
	QueryServiceControl tabletserver.Controller
	UpdateStream        binlog.UpdateStreamControl
	HealthReporter      health.Reporter
	TopoServer          topo.Server
	TabletAlias         *topodatapb.TabletAlias
	MysqlDaemon         mysqlctl.MysqlDaemon
	DBConfigs           dbconfigs.DBConfigs
	BinlogPlayerMap     *BinlogPlayerMap

	// History of the health checks, public so status
	// pages can display it
	History *history.History
	// contains filtered or unexported fields
}

ActionAgent is the main class for the agent.

func NewActionAgent

func NewActionAgent(
	batchCtx context.Context,
	mysqld mysqlctl.MysqlDaemon,
	queryServiceControl tabletserver.Controller,
	tabletAlias *topodatapb.TabletAlias,
	dbcfgs dbconfigs.DBConfigs,
	mycnf *mysqlctl.Mycnf,
	port, gRPCPort int32,
) (agent *ActionAgent, err error)

NewActionAgent creates a new ActionAgent and registers all the associated services.

batchCtx is the context that the agent will use for any background tasks it spawns.

func NewComboActionAgent

func NewComboActionAgent(batchCtx context.Context, ts topo.Server, tabletAlias *topodatapb.TabletAlias, vtPort, grpcPort int32, queryServiceControl tabletserver.Controller, dbcfgs dbconfigs.DBConfigs, mysqlDaemon mysqlctl.MysqlDaemon, keyspace, shard, dbname, tabletType string) *ActionAgent

NewComboActionAgent creates an agent tailored specifically to run within the vtcombo binary. It cannot be called concurrently, as it changes the flags.

func NewTestActionAgent

func NewTestActionAgent(batchCtx context.Context, ts topo.Server, tabletAlias *topodatapb.TabletAlias, vtPort, grpcPort int32, mysqlDaemon mysqlctl.MysqlDaemon, preStart func(*ActionAgent)) *ActionAgent

NewTestActionAgent creates an agent for test purposes. Only a subset of features are supported now, but we'll add more over time.

func (*ActionAgent) ApplySchema

ApplySchema will apply a schema change Should be called under RPCWrapLockAction.

func (*ActionAgent) Backup

func (agent *ActionAgent) Backup(ctx context.Context, concurrency int, logger logutil.Logger) error

Backup takes a db backup and sends it to the BackupStorage Should be called under RPCWrapLockAction.

func (*ActionAgent) BlacklistedTables

func (agent *ActionAgent) BlacklistedTables() []string

BlacklistedTables returns the list of currently blacklisted tables.

func (*ActionAgent) ChangeType

func (agent *ActionAgent) ChangeType(ctx context.Context, tabletType topodatapb.TabletType) error

ChangeType changes the tablet type Should be called under RPCWrapLockAction.

func (*ActionAgent) DemoteMaster

func (agent *ActionAgent) DemoteMaster(ctx context.Context) (string, error)

DemoteMaster marks the server read-only, wait until it is done with its current transactions, and returns its master position. Should be called under RPCWrapLockAction.

func (*ActionAgent) DisallowQueryService

func (agent *ActionAgent) DisallowQueryService() string

DisallowQueryService returns the reason the query service should be disabled, if any.

func (*ActionAgent) EnableUpdateStream

func (agent *ActionAgent) EnableUpdateStream() bool

EnableUpdateStream returns if we should enable update stream or not

func (*ActionAgent) ExecuteFetchAsApp

func (agent *ActionAgent) ExecuteFetchAsApp(ctx context.Context, query string, maxrows int) (*querypb.QueryResult, error)

ExecuteFetchAsApp will execute the given query, possibly disabling binlogs. Should be called under RPCWrap.

func (*ActionAgent) ExecuteFetchAsDba

func (agent *ActionAgent) ExecuteFetchAsDba(ctx context.Context, query string, dbName string, maxrows int, disableBinlogs bool, reloadSchema bool) (*querypb.QueryResult, error)

ExecuteFetchAsDba will execute the given query, possibly disabling binlogs and reload schema. Should be called under RPCWrap.

func (*ActionAgent) ExecuteHook

func (agent *ActionAgent) ExecuteHook(ctx context.Context, hk *hook.Hook) *hook.HookResult

ExecuteHook executes the provided hook locally, and returns the result. Should be called under RPCWrapLockAction.

func (*ActionAgent) GetPermissions

func (agent *ActionAgent) GetPermissions(ctx context.Context) (*tabletmanagerdatapb.Permissions, error)

GetPermissions returns the db permissions. Should be called under RPCWrap.

func (*ActionAgent) GetSchema

func (agent *ActionAgent) GetSchema(ctx context.Context, tables, excludeTables []string, includeViews bool) (*tabletmanagerdatapb.SchemaDefinition, error)

GetSchema returns the schema. Should be called under RPCWrap.

func (*ActionAgent) GetSlaves

func (agent *ActionAgent) GetSlaves(ctx context.Context) ([]string, error)

GetSlaves returns the address of all the slaves Should be called under RPCWrap.

func (*ActionAgent) Healthy

func (agent *ActionAgent) Healthy() (time.Duration, error)

Healthy reads the result of the latest healthcheck, protected by mutex. If that status is too old, it means healthcheck hasn't run for a while, and is probably stuck, this is not good, we're not healthy.

func (*ActionAgent) IgnoreHealthError

func (agent *ActionAgent) IgnoreHealthError(ctx context.Context, pattern string) error

IgnoreHealthError sets the regexp for health check errors to ignore. Should be called under RPCWrap.

func (*ActionAgent) InitMaster

func (agent *ActionAgent) InitMaster(ctx context.Context) (string, error)

InitMaster enables writes and returns the replication position.

func (*ActionAgent) InitSlave

func (agent *ActionAgent) InitSlave(ctx context.Context, parent *topodatapb.TabletAlias, position string, timeCreatedNS int64) error

InitSlave sets replication master and position, and waits for the reparent_journal table entry up to context timeout

func (*ActionAgent) InitTablet

func (agent *ActionAgent) InitTablet(port, gRPCPort int32) error

InitTablet initializes the tablet record if necessary.

func (*ActionAgent) MasterPosition

func (agent *ActionAgent) MasterPosition(ctx context.Context) (string, error)

MasterPosition returns the master position Should be called under RPCWrap.

func (*ActionAgent) Ping

func (agent *ActionAgent) Ping(ctx context.Context, args string) string

Ping makes sure RPCs work, and refreshes the tablet record. Should be called under RPCWrap.

func (*ActionAgent) PopulateReparentJournal

func (agent *ActionAgent) PopulateReparentJournal(ctx context.Context, timeCreatedNS int64, actionName string, masterAlias *topodatapb.TabletAlias, position string) error

PopulateReparentJournal adds an entry into the reparent_journal table.

func (*ActionAgent) PreflightSchema

func (agent *ActionAgent) PreflightSchema(ctx context.Context, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)

PreflightSchema will try out the schema changes in "changes". Should be called under RPCWrapLockAction.

func (*ActionAgent) PromoteSlave

func (agent *ActionAgent) PromoteSlave(ctx context.Context) (string, error)

PromoteSlave makes the current tablet the master

func (*ActionAgent) PromoteSlaveWhenCaughtUp

func (agent *ActionAgent) PromoteSlaveWhenCaughtUp(ctx context.Context, position string) (string, error)

PromoteSlaveWhenCaughtUp waits for this slave to be caught up on replication up to the provided point, and then makes the slave the shard master.

func (*ActionAgent) RPCWrap

func (agent *ActionAgent) RPCWrap(ctx context.Context, name TabletAction, args, reply interface{}, f func() error) error

RPCWrap is for read-only actions that can be executed concurrently. verbose is forced to false.

func (*ActionAgent) RPCWrapLock

func (agent *ActionAgent) RPCWrapLock(ctx context.Context, name TabletAction, args, reply interface{}, verbose bool, f func() error) error

RPCWrapLock is for actions that should not run concurrently with each other.

func (*ActionAgent) RPCWrapLockAction

func (agent *ActionAgent) RPCWrapLockAction(ctx context.Context, name TabletAction, args, reply interface{}, verbose bool, f func() error) error

RPCWrapLockAction is the same as RPCWrapLock, plus it will call refreshTablet after the action returns.

func (*ActionAgent) RefreshState

func (agent *ActionAgent) RefreshState(ctx context.Context)

RefreshState reload the tablet record from the topo server. Should be called under RPCWrapLockAction, so it actually works.

func (*ActionAgent) ReloadSchema

func (agent *ActionAgent) ReloadSchema(ctx context.Context, waitPosition string) error

ReloadSchema will reload the schema Should be called under RPCWrap. This doesn't need the action mutex because periodic schema reloads happen in the background anyway.

func (*ActionAgent) ResetReplication

func (agent *ActionAgent) ResetReplication(ctx context.Context) error

ResetReplication completely resets the replication on the host. All binary and relay logs are flushed. All replication positions are reset.

func (*ActionAgent) RestoreFromBackup

func (agent *ActionAgent) RestoreFromBackup(ctx context.Context) error

RestoreFromBackup is the main entry point for backup restore. It will either work, fail gracefully, or return an error in case of a non-recoverable error. It takes the action lock so no RPC interferes.

func (*ActionAgent) RunBlpUntil

func (agent *ActionAgent) RunBlpUntil(ctx context.Context, bpl []*tabletmanagerdatapb.BlpPosition, waitTime time.Duration) (string, error)

RunBlpUntil runs the binlog player server until the position is reached, and returns the current mysql master replication position.

func (*ActionAgent) RunHealthCheck

func (agent *ActionAgent) RunHealthCheck(ctx context.Context)

RunHealthCheck will manually run the health check on the tablet. Should be called under RPCWrap.

func (*ActionAgent) SetMaster

func (agent *ActionAgent) SetMaster(ctx context.Context, parentAlias *topodatapb.TabletAlias, timeCreatedNS int64, forceStartSlave bool) error

SetMaster sets replication master, and waits for the reparent_journal table entry up to context timeout Should be called under RPCWrapLockAction.

func (*ActionAgent) SetReadOnly

func (agent *ActionAgent) SetReadOnly(ctx context.Context, rdonly bool) error

SetReadOnly makes the mysql instance read-only or read-write Should be called under RPCWrapLockAction.

func (*ActionAgent) SlaveStatus

func (agent *ActionAgent) SlaveStatus(ctx context.Context) (*replicationdatapb.Status, error)

SlaveStatus returns the replication status Should be called under RPCWrap.

func (*ActionAgent) SlaveWasPromoted

func (agent *ActionAgent) SlaveWasPromoted(ctx context.Context) error

SlaveWasPromoted promotes a slave to master, no questions asked. Should be called under RPCWrapLockAction.

func (*ActionAgent) SlaveWasRestarted

func (agent *ActionAgent) SlaveWasRestarted(ctx context.Context, parent *topodatapb.TabletAlias) error

SlaveWasRestarted updates the parent record for a tablet. Should be called under RPCWrapLockAction.

func (*ActionAgent) Sleep

func (agent *ActionAgent) Sleep(ctx context.Context, duration time.Duration)

Sleep sleeps for the duration Should be called under RPCWrapLockAction.

func (*ActionAgent) Start

func (agent *ActionAgent) Start(ctx context.Context, mysqlPort, vtPort, gRPCPort int32, initUpdateStream bool) error

Start validates and updates the topology records for the tablet, and performs the initial state change callback to start tablet services. If initUpdateStream is set, update stream service will also be registered.

func (*ActionAgent) StartBlp

func (agent *ActionAgent) StartBlp(ctx context.Context) error

StartBlp starts the binlog players Should be called under RPCWrapLockAction.

func (*ActionAgent) StartSlave

func (agent *ActionAgent) StartSlave(ctx context.Context) error

StartSlave will start the replication. Works both when Vitess manages replication or not (using hook if not). Should be called under RPCWrapLock.

func (*ActionAgent) Stop

func (agent *ActionAgent) Stop()

Stop shuts down the agent. Normally this is not necessary, since we use servenv OnTerm and OnClose hooks to coordinate shutdown automatically, while taking lameduck into account. However, this may be useful for tests, when you want to clean up an agent immediately.

func (*ActionAgent) StopBlp

func (agent *ActionAgent) StopBlp(ctx context.Context) ([]*tabletmanagerdatapb.BlpPosition, error)

StopBlp stops the binlog players, and return their positions. Should be called under RPCWrapLockAction.

func (*ActionAgent) StopReplicationAndGetStatus

func (agent *ActionAgent) StopReplicationAndGetStatus(ctx context.Context) (*replicationdatapb.Status, error)

StopReplicationAndGetStatus stops MySQL replication, and returns the current status

func (*ActionAgent) StopSlave

func (agent *ActionAgent) StopSlave(ctx context.Context) error

StopSlave will stop the replication. Works both when Vitess manages replication or not (using hook if not). Should be called under RPCWrapLock.

func (*ActionAgent) StopSlaveMinimum

func (agent *ActionAgent) StopSlaveMinimum(ctx context.Context, position string, waitTime time.Duration) (string, error)

StopSlaveMinimum will stop the slave after it reaches at least the provided position. Works both when Vitess manages replication or not (using hook if not).

func (*ActionAgent) Tablet

func (agent *ActionAgent) Tablet() *topodatapb.Tablet

Tablet reads the stored Tablet from the agent, protected by mutex.

func (*ActionAgent) TabletExternallyReparented

func (agent *ActionAgent) TabletExternallyReparented(ctx context.Context, externalID string) error

TabletExternallyReparented updates all topo records so the current tablet is the new master for this shard. Should be called under RPCWrapLock.

func (*ActionAgent) WaitBlpPosition

func (agent *ActionAgent) WaitBlpPosition(ctx context.Context, blpPosition *tabletmanagerdatapb.BlpPosition, waitTime time.Duration) error

WaitBlpPosition waits until a specific filtered replication position is reached. Should be called under RPCWrapLock.

type BinlogPlayerController

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

BinlogPlayerController controls one player.

func (*BinlogPlayerController) BlpPosition

BlpPosition returns the current position for a controller, as read from the database.

func (*BinlogPlayerController) Close

func (bpc *BinlogPlayerController) Close() error

Close will stop and free any long running resources e.g. the healthcheck. Returns an error if BinlogPlayerController is not stopped (i.e. Start() was called but not Stop().)

func (*BinlogPlayerController) Iteration

func (bpc *BinlogPlayerController) Iteration() (err error)

Iteration is a single iteration for the player: get the current status, try to play, and plays until interrupted, or until an error occurs.

func (*BinlogPlayerController) Loop

func (bpc *BinlogPlayerController) Loop()

Loop runs the main player loop: try to play, and in case of error, sleep for 5 seconds and try again.

func (*BinlogPlayerController) Start

func (bpc *BinlogPlayerController) Start(ctx context.Context)

Start will start the player in the background and run forever.

func (*BinlogPlayerController) StartUntil

func (bpc *BinlogPlayerController) StartUntil(ctx context.Context, stopPos string) error

StartUntil will start the Player until we reach the given position.

func (*BinlogPlayerController) Stop

func (bpc *BinlogPlayerController) Stop()

Stop will ask the controller to stop playing, and wait until it is stopped.

func (*BinlogPlayerController) String

func (bpc *BinlogPlayerController) String() string

func (*BinlogPlayerController) WaitForStop

func (bpc *BinlogPlayerController) WaitForStop(waitTimeout time.Duration) error

WaitForStop will wait until the player is stopped. Use this after StartUntil.

type BinlogPlayerControllerStatus

type BinlogPlayerControllerStatus struct {
	// configuration values
	Index        uint32
	SourceShard  *topodatapb.Shard_SourceShard
	StopPosition string

	// stats and current values
	LastPosition        replication.Position
	SecondsBehindMaster int64
	Counts              map[string]int64
	Rates               map[string][]float64
	State               string
	SourceTablet        *topodatapb.TabletAlias
	LastError           string
}

BinlogPlayerControllerStatus is the status of an individual controller.

func (*BinlogPlayerControllerStatus) SourceShardAsHTML

func (bpcs *BinlogPlayerControllerStatus) SourceShardAsHTML() template.HTML

SourceShardAsHTML returns the SourceShard as HTML

func (*BinlogPlayerControllerStatus) SourceTabletAlias

func (bpcs *BinlogPlayerControllerStatus) SourceTabletAlias() string

SourceTabletAlias returns the string version of the SourceTablet alias, if set

type BinlogPlayerControllerStatusList

type BinlogPlayerControllerStatusList []*BinlogPlayerControllerStatus

BinlogPlayerControllerStatusList is the list of statuses.

func (BinlogPlayerControllerStatusList) Len

Len is part of sort.Interface.

func (BinlogPlayerControllerStatusList) Less

func (bpcsl BinlogPlayerControllerStatusList) Less(i, j int) bool

Less is part of sort.Interface.

func (BinlogPlayerControllerStatusList) Swap

func (bpcsl BinlogPlayerControllerStatusList) Swap(i, j int)

Swap is part of sort.Interface.

type BinlogPlayerMap

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

BinlogPlayerMap controls all the players. It can be stopped and restarted.

func NewBinlogPlayerMap

func NewBinlogPlayerMap(ts topo.Server, mysqld mysqlctl.MysqlDaemon, vtClientFactory func() binlogplayer.VtClient) *BinlogPlayerMap

NewBinlogPlayerMap creates a new map of players.

func (*BinlogPlayerMap) BlpPositionList

func (blm *BinlogPlayerMap) BlpPositionList() ([]*tabletmanagerdatapb.BlpPosition, error)

BlpPositionList returns the current position of all the players.

func (*BinlogPlayerMap) RefreshMap

func (blm *BinlogPlayerMap) RefreshMap(ctx context.Context, tablet *topodatapb.Tablet, shardInfo *topo.ShardInfo)

RefreshMap reads the right data from topo.Server and makes sure we're playing the right logs.

func (*BinlogPlayerMap) RunUntil

func (blm *BinlogPlayerMap) RunUntil(ctx context.Context, blpPositionList []*tabletmanagerdatapb.BlpPosition, waitTimeout time.Duration) error

RunUntil will run all the players until they reach the given position. Holds the map lock during that exercise, shouldn't take long at all.

func (*BinlogPlayerMap) Start

func (blm *BinlogPlayerMap) Start(ctx context.Context)

Start restarts the current players.

func (*BinlogPlayerMap) Status

func (blm *BinlogPlayerMap) Status() *BinlogPlayerMapStatus

Status returns the BinlogPlayerMapStatus for the BinlogPlayerMap. It is used to display the complete status in the webinterface.

func (*BinlogPlayerMap) StatusSummary

func (blm *BinlogPlayerMap) StatusSummary() (maxSecondsBehindMaster int64, binlogPlayersCount int32)

StatusSummary returns aggregated health information e.g. the maximum replication delay across all binlog players. It is used by the QueryService.StreamHealth RPC.

func (*BinlogPlayerMap) Stop

func (blm *BinlogPlayerMap) Stop()

Stop stops the current players, but does not remove them from the map. Call 'Start' to restart the playback.

func (*BinlogPlayerMap) StopAllPlayersAndReset

func (blm *BinlogPlayerMap) StopAllPlayersAndReset()

StopAllPlayersAndReset stops all the binlog players, and reset the map of players.

type BinlogPlayerMapStatus

type BinlogPlayerMapStatus struct {
	State       string
	Controllers BinlogPlayerControllerStatusList
}

BinlogPlayerMapStatus is the complete player status.

type HealthRecord

type HealthRecord struct {
	Time             time.Time
	Error            error
	IgnoredError     error
	IgnoreErrorExpr  string
	ReplicationDelay time.Duration
}

HealthRecord records one run of the health checker.

func (*HealthRecord) Class

func (r *HealthRecord) Class() string

Class returns a human-readable one word version of the health state.

func (*HealthRecord) Degraded

func (r *HealthRecord) Degraded() bool

Degraded returns true if the replication delay is beyond degradedThreshold.

func (*HealthRecord) ErrorString

func (r *HealthRecord) ErrorString() string

ErrorString returns Error as a string.

func (*HealthRecord) HTML

func (r *HealthRecord) HTML() template.HTML

HTML returns an HTML version to be displayed on UIs.

func (*HealthRecord) IgnoredErrorString

func (r *HealthRecord) IgnoredErrorString() string

IgnoredErrorString returns IgnoredError as a string.

func (*HealthRecord) IsDuplicate

func (r *HealthRecord) IsDuplicate(other interface{}) bool

IsDuplicate implements history.Deduplicable

type RPCAgent

type RPCAgent interface {
	Ping(ctx context.Context, args string) string

	GetSchema(ctx context.Context, tables, excludeTables []string, includeViews bool) (*tabletmanagerdatapb.SchemaDefinition, error)

	GetPermissions(ctx context.Context) (*tabletmanagerdatapb.Permissions, error)

	SetReadOnly(ctx context.Context, rdonly bool) error

	ChangeType(ctx context.Context, tabletType topodatapb.TabletType) error

	Sleep(ctx context.Context, duration time.Duration)

	ExecuteHook(ctx context.Context, hk *hook.Hook) *hook.HookResult

	RefreshState(ctx context.Context)

	RunHealthCheck(ctx context.Context)

	IgnoreHealthError(ctx context.Context, pattern string) error

	ReloadSchema(ctx context.Context, waitPosition string) error

	PreflightSchema(ctx context.Context, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)

	ApplySchema(ctx context.Context, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error)

	ExecuteFetchAsDba(ctx context.Context, query string, dbName string, maxrows int, disableBinlogs bool, reloadSchema bool) (*querypb.QueryResult, error)

	ExecuteFetchAsApp(ctx context.Context, query string, maxrows int) (*querypb.QueryResult, error)

	SlaveStatus(ctx context.Context) (*replicationdatapb.Status, error)

	MasterPosition(ctx context.Context) (string, error)

	StopSlave(ctx context.Context) error

	StopSlaveMinimum(ctx context.Context, position string, waitTime time.Duration) (string, error)

	StartSlave(ctx context.Context) error

	TabletExternallyReparented(ctx context.Context, externalID string) error

	GetSlaves(ctx context.Context) ([]string, error)

	WaitBlpPosition(ctx context.Context, blpPosition *tabletmanagerdatapb.BlpPosition, waitTime time.Duration) error

	StopBlp(ctx context.Context) ([]*tabletmanagerdatapb.BlpPosition, error)

	StartBlp(ctx context.Context) error

	RunBlpUntil(ctx context.Context, bpl []*tabletmanagerdatapb.BlpPosition, waitTime time.Duration) (string, error)

	ResetReplication(ctx context.Context) error

	InitMaster(ctx context.Context) (string, error)

	PopulateReparentJournal(ctx context.Context, timeCreatedNS int64, actionName string, masterAlias *topodatapb.TabletAlias, pos string) error

	InitSlave(ctx context.Context, parent *topodatapb.TabletAlias, replicationPosition string, timeCreatedNS int64) error

	DemoteMaster(ctx context.Context) (string, error)

	PromoteSlaveWhenCaughtUp(ctx context.Context, replicationPosition string) (string, error)

	SlaveWasPromoted(ctx context.Context) error

	SetMaster(ctx context.Context, parent *topodatapb.TabletAlias, timeCreatedNS int64, forceStartSlave bool) error

	SlaveWasRestarted(ctx context.Context, parent *topodatapb.TabletAlias) error

	StopReplicationAndGetStatus(ctx context.Context) (*replicationdatapb.Status, error)

	PromoteSlave(ctx context.Context) (string, error)

	Backup(ctx context.Context, concurrency int, logger logutil.Logger) error

	// RPC helpers
	RPCWrap(ctx context.Context, name TabletAction, args, reply interface{}, f func() error) error
	RPCWrapLock(ctx context.Context, name TabletAction, args, reply interface{}, verbose bool, f func() error) error
	RPCWrapLockAction(ctx context.Context, name TabletAction, args, reply interface{}, verbose bool, f func() error) error
}

RPCAgent defines the interface implemented by the Agent for RPCs. It is useful for RPC implementations to test their full stack.

type RegisterQueryService

type RegisterQueryService func(*ActionAgent)

RegisterQueryService is used to delay registration of RPC servers until we have all the objects.

type TabletAction

type TabletAction string

TabletAction is the name of an action. It is a string (and not an enum) so we can print it easily.

const (
	// TabletActionPing checks a tablet is alive
	TabletActionPing TabletAction = "Ping"

	// TabletActionSleep will sleep for a duration (used for tests)
	TabletActionSleep TabletAction = "Sleep"

	// TabletActionExecuteHook will execute the provided hook remotely
	TabletActionExecuteHook TabletAction = "ExecuteHook"

	// TabletActionSetReadOnly makes the mysql instance read-only
	TabletActionSetReadOnly TabletAction = "SetReadOnly"

	// TabletActionSetReadWrite makes the mysql instance read-write
	TabletActionSetReadWrite TabletAction = "SetReadWrite"

	// TabletActionChangeType changes the type of the tablet
	TabletActionChangeType TabletAction = "ChangeType"

	// TabletActionResetReplication tells the tablet it should
	// reset its replication state
	TabletActionResetReplication TabletAction = "ResetReplication"

	// TabletActionInitMaster tells the tablet it should make itself the new
	// master for the shard it's currently in.
	TabletActionInitMaster TabletAction = "InitMaster"

	// TabletActionPopulateReparentJournal inserts an entry in the
	// _vt.reparent_journal table
	TabletActionPopulateReparentJournal TabletAction = "PopulateReparentJournal"

	// TabletActionInitSlave tells the tablet it should make
	// itself a slave to the provided master at the given position.
	TabletActionInitSlave TabletAction = "InitSlave"

	// TabletActionDemoteMaster tells the current master it's
	// about to not be a master any more, and should go read-only.
	TabletActionDemoteMaster TabletAction = "DemoteMaster"

	// TabletActionPromoteSlaveWhenCaughtUp tells the tablet to wait
	// for a given replication point, and when it reaches it
	// switch to be a master.
	TabletActionPromoteSlaveWhenCaughtUp TabletAction = "PromoteSlaveWhenCaughtUp"

	// TabletActionSlaveWasPromoted tells a tablet this previously slave
	// tablet is now the master. The tablet will update its
	// own topology record.
	TabletActionSlaveWasPromoted TabletAction = "SlaveWasPromoted"

	// TabletActionSetMaster tells a tablet it has a new master.
	// The tablet will reparent to the new master, and wait for
	// the reparent_journal entry.
	TabletActionSetMaster TabletAction = "SetMaster"

	// TabletActionSlaveWasRestarted tells a tablet the mysql
	// master was changed.  The tablet will check it is indeed the
	// case, and update its own topology record.
	TabletActionSlaveWasRestarted TabletAction = "SlaveWasRestarted"

	// TabletActionStopReplicationAndGetStatus will stop replication,
	// and return the current replication status.
	TabletActionStopReplicationAndGetStatus TabletAction = "StopReplicationAndGetStatus"

	// TabletActionPromoteSlave will make this tablet the master
	TabletActionPromoteSlave TabletAction = "PromoteSlave"

	// TabletActionStopSlave will stop MySQL replication.
	TabletActionStopSlave TabletAction = "StopSlave"

	// TabletActionStopSlaveMinimum will stop MySQL replication
	// after it reaches a minimum point.
	TabletActionStopSlaveMinimum TabletAction = "StopSlaveMinimum"

	// TabletActionStartSlave will start MySQL replication.
	TabletActionStartSlave TabletAction = "StartSlave"

	// TabletActionExternallyReparented is sent directly to the new master
	// tablet when it becomes the master. It is functionnaly equivalent
	// to calling "ShardExternallyReparented" on the topology.
	TabletActionExternallyReparented TabletAction = "TabletExternallyReparented"

	// TabletActionMasterPosition returns the current master position
	TabletActionMasterPosition TabletAction = "MasterPosition"

	// TabletActionSlaveStatus returns the current slave status
	TabletActionSlaveStatus TabletAction = "SlaveStatus"

	// TabletActionWaitBLPPosition waits until the slave reaches a
	// replication position in filtered replication
	TabletActionWaitBLPPosition TabletAction = "WaitBlpPosition"

	// TabletActionStopBLP stops filtered replication
	TabletActionStopBLP TabletAction = "StopBlp"

	// TabletActionStartBLP starts filtered replication
	TabletActionStartBLP TabletAction = "StartBlp"

	// TabletActionRunBLPUntil will run filtered replication until
	// it reaches the provided stop position.
	TabletActionRunBLPUntil TabletAction = "RunBlpUntil"

	// TabletActionGetSchema returns the tablet current schema.
	TabletActionGetSchema TabletAction = "GetSchema"

	// TabletActionRefreshState tells the tablet to refresh its
	// tablet record from the topo server.
	TabletActionRefreshState TabletAction = "RefreshState"

	// TabletActionRunHealthCheck tells the tablet to run a health check.
	TabletActionRunHealthCheck TabletAction = "RunHealthCheck"

	// TabletActionIgnoreHealthError sets the regexp for health errors to ignore.
	TabletActionIgnoreHealthError TabletAction = "IgnoreHealthError"

	// TabletActionReloadSchema tells the tablet to reload its schema.
	TabletActionReloadSchema TabletAction = "ReloadSchema"

	// TabletActionPreflightSchema will check a schema change works
	TabletActionPreflightSchema TabletAction = "PreflightSchema"

	// TabletActionApplySchema will actually apply the schema change
	TabletActionApplySchema TabletAction = "ApplySchema"

	// TabletActionExecuteFetchAsDba uses the DBA connection to run queries.
	TabletActionExecuteFetchAsDba TabletAction = "ExecuteFetchAsDba"

	// TabletActionExecuteFetchAsApp uses the App connection to run queries.
	TabletActionExecuteFetchAsApp TabletAction = "ExecuteFetchAsApp"

	// TabletActionGetPermissions returns the mysql permissions set
	TabletActionGetPermissions TabletAction = "GetPermissions"

	// TabletActionGetSlaves returns the current set of mysql
	// replication slaves.
	TabletActionGetSlaves TabletAction = "GetSlaves"

	// TabletActionBackup takes a db backup and stores it into BackupStorage
	TabletActionBackup TabletAction = "Backup"
)

Directories

Path Synopsis
Package events contains event structs used by the tabletmanager package.
Package events contains event structs used by the tabletmanager package.

Jump to

Keyboard shortcuts

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