Documentation ¶
Overview ¶
Package tabletmanager exports the TabletManager 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 tm 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 obtain the actionSema, 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 actionSema, and which run changeCallback.
Index ¶
- Constants
- Variables
- func BuildTabletFromInput(alias *topodatapb.TabletAlias, port, grpcPort int32, db *dbconfigs.DBConfigs, ...) (*topodatapb.Tablet, error)
- type DBAction
- type RPCTM
- type RegisterTabletManager
- type SemiSyncAction
- type StopReplicationAndGetStatusResponse
- type TabletManager
- func (tm *TabletManager) ApplySchema(ctx context.Context, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error)
- func (tm *TabletManager) Backup(ctx context.Context, logger logutil.Logger, ...) error
- func (tm *TabletManager) ChangeType(ctx context.Context, tabletType topodatapb.TabletType, semiSync bool) error
- func (tm *TabletManager) CheckThrottler(ctx context.Context, req *tabletmanagerdatapb.CheckThrottlerRequest) (*tabletmanagerdatapb.CheckThrottlerResponse, error)
- func (tm *TabletManager) Close()
- func (tm *TabletManager) CreateVReplicationWorkflow(ctx context.Context, ...) (*tabletmanagerdatapb.CreateVReplicationWorkflowResponse, error)
- func (tm *TabletManager) DeleteVReplicationWorkflow(ctx context.Context, ...) (*tabletmanagerdatapb.DeleteVReplicationWorkflowResponse, error)
- func (tm *TabletManager) DemotePrimary(ctx context.Context) (*replicationdatapb.PrimaryStatus, error)
- func (tm *TabletManager) DeniedTables() []string
- func (tm *TabletManager) ExecuteFetchAsAllPrivs(ctx context.Context, req *tabletmanagerdatapb.ExecuteFetchAsAllPrivsRequest) (*querypb.QueryResult, error)
- func (tm *TabletManager) ExecuteFetchAsApp(ctx context.Context, req *tabletmanagerdatapb.ExecuteFetchAsAppRequest) (*querypb.QueryResult, error)
- func (tm *TabletManager) ExecuteFetchAsDba(ctx context.Context, req *tabletmanagerdatapb.ExecuteFetchAsDbaRequest) (*querypb.QueryResult, error)
- func (tm *TabletManager) ExecuteHook(ctx context.Context, hk *hook.Hook) *hook.HookResult
- func (tm *TabletManager) ExecuteMultiFetchAsDba(ctx context.Context, req *tabletmanagerdatapb.ExecuteMultiFetchAsDbaRequest) ([]*querypb.QueryResult, error)
- func (tm *TabletManager) ExecuteQuery(ctx context.Context, req *tabletmanagerdatapb.ExecuteQueryRequest) (*querypb.QueryResult, error)
- func (tm *TabletManager) FullStatus(ctx context.Context) (*replicationdatapb.FullStatus, error)
- func (tm *TabletManager) GetGlobalStatusVars(ctx context.Context, variables []string) (map[string]string, error)
- func (tm *TabletManager) GetPermissions(ctx context.Context) (*tabletmanagerdatapb.Permissions, error)
- func (tm *TabletManager) GetReplicas(ctx context.Context) ([]string, error)
- func (tm *TabletManager) GetSchema(ctx context.Context, request *tabletmanagerdatapb.GetSchemaRequest) (*tabletmanagerdatapb.SchemaDefinition, error)
- func (tm *TabletManager) HandleRPCPanic(ctx context.Context, name string, args, reply any, verbose bool, err *error)
- func (tm *TabletManager) HasVReplicationWorkflows(ctx context.Context, req *tabletmanagerdatapb.HasVReplicationWorkflowsRequest) (*tabletmanagerdatapb.HasVReplicationWorkflowsResponse, error)
- func (tm *TabletManager) InitPrimary(ctx context.Context, semiSync bool) (string, error)
- func (tm *TabletManager) InitReplica(ctx context.Context, parent *topodatapb.TabletAlias, position string, ...) error
- func (tm *TabletManager) LockTables(ctx context.Context) error
- func (tm *TabletManager) Ping(ctx context.Context, args string) string
- func (tm *TabletManager) PopulateReparentJournal(ctx context.Context, timeCreatedNS int64, actionName string, ...) error
- func (tm *TabletManager) PreflightSchema(ctx context.Context, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)
- func (tm *TabletManager) PrimaryPosition(ctx context.Context) (string, error)
- func (tm *TabletManager) PrimaryStatus(ctx context.Context) (*replicationdatapb.PrimaryStatus, error)
- func (tm *TabletManager) PromoteReplica(ctx context.Context, semiSync bool) (string, error)
- func (tm *TabletManager) ReadVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.ReadVReplicationWorkflowRequest) (*tabletmanagerdatapb.ReadVReplicationWorkflowResponse, error)
- func (tm *TabletManager) ReadVReplicationWorkflows(ctx context.Context, req *tabletmanagerdatapb.ReadVReplicationWorkflowsRequest) (*tabletmanagerdatapb.ReadVReplicationWorkflowsResponse, error)
- func (tm *TabletManager) RefreshState(ctx context.Context) error
- func (tm *TabletManager) ReloadSchema(ctx context.Context, waitPosition string) error
- func (tm *TabletManager) ReplicaWasPromoted(ctx context.Context) error
- func (tm *TabletManager) ReplicaWasRestarted(ctx context.Context, parent *topodatapb.TabletAlias) error
- func (tm *TabletManager) ReplicationStatus(ctx context.Context) (*replicationdatapb.Status, error)
- func (tm *TabletManager) ResetReplication(ctx context.Context) error
- func (tm *TabletManager) ResetReplicationParameters(ctx context.Context) error
- func (tm *TabletManager) ResetSequences(ctx context.Context, tables []string) error
- func (tm *TabletManager) RestoreData(ctx context.Context, logger logutil.Logger, ...) error
- func (tm *TabletManager) RestoreFromBackup(ctx context.Context, logger logutil.Logger, ...) error
- func (tm *TabletManager) RunHealthCheck(ctx context.Context)
- func (tm *TabletManager) SetReadOnly(ctx context.Context, rdonly bool) error
- func (tm *TabletManager) SetReplicationSource(ctx context.Context, parentAlias *topodatapb.TabletAlias, timeCreatedNS int64, ...) error
- func (tm *TabletManager) Sleep(ctx context.Context, duration time.Duration)
- func (tm *TabletManager) Start(tablet *topodatapb.Tablet, config *tabletenv.TabletConfig) error
- func (tm *TabletManager) StartReplication(ctx context.Context, semiSync bool) error
- func (tm *TabletManager) StartReplicationUntilAfter(ctx context.Context, position string, waitTime time.Duration) error
- func (tm *TabletManager) Stop()
- func (tm *TabletManager) StopReplication(ctx context.Context) error
- func (tm *TabletManager) StopReplicationAndGetStatus(ctx context.Context, stopReplicationMode replicationdatapb.StopReplicationMode) (StopReplicationAndGetStatusResponse, error)
- func (tm *TabletManager) StopReplicationMinimum(ctx context.Context, position string, waitTime time.Duration) (string, error)
- func (tm *TabletManager) Tablet() *topodatapb.Tablet
- func (tm *TabletManager) UndoDemotePrimary(ctx context.Context, semiSync bool) error
- func (tm *TabletManager) UnlockTables(ctx context.Context) error
- func (tm *TabletManager) UpdateVReplicationWorkflow(ctx context.Context, ...) (*tabletmanagerdatapb.UpdateVReplicationWorkflowResponse, error)
- func (tm *TabletManager) UpdateVReplicationWorkflows(ctx context.Context, ...) (*tabletmanagerdatapb.UpdateVReplicationWorkflowsResponse, error)
- func (tm *TabletManager) VDiff(ctx context.Context, req *tabletmanagerdatapb.VDiffRequest) (*tabletmanagerdatapb.VDiffResponse, error)
- func (tm *TabletManager) VReplicationExec(ctx context.Context, query string) (*querypb.QueryResult, error)
- func (tm *TabletManager) VReplicationWaitForPos(ctx context.Context, id int32, pos string) error
- func (tm *TabletManager) WaitForPosition(ctx context.Context, pos string) error
Constants ¶
const ( DBActionNone = DBAction(iota) DBActionSetReadWrite )
Allowed values for DBAction
const ( SemiSyncActionNone = SemiSyncAction(iota) SemiSyncActionSet SemiSyncActionUnset )
Allowed values for SemiSyncAction
Variables ¶
var RegisterTabletManagers []RegisterTabletManager
RegisterTabletManagers is a list of functions to call when the delayed registration is triggered.
Functions ¶
func BuildTabletFromInput ¶
func BuildTabletFromInput(alias *topodatapb.TabletAlias, port, grpcPort int32, db *dbconfigs.DBConfigs, collationEnv *collations.Environment) (*topodatapb.Tablet, error)
BuildTabletFromInput builds a tablet record from input parameters.
Types ¶
type DBAction ¶ added in v0.8.0
type DBAction int
DBAction is used to tell ChangeTabletType whether to call SetReadOnly on change to PRIMARY tablet type
type RPCTM ¶
type RPCTM interface { Ping(ctx context.Context, args string) string GetSchema(ctx context.Context, request *tabletmanagerdatapb.GetSchemaRequest) (*tabletmanagerdatapb.SchemaDefinition, error) GetPermissions(ctx context.Context) (*tabletmanagerdatapb.Permissions, error) // GetGlobalStatusVars returns the server's global status variables asked for. // An empty/nil variable name parameter slice means you want all of them. GetGlobalStatusVars(ctx context.Context, variables []string) (map[string]string, error) SetReadOnly(ctx context.Context, rdonly bool) error ChangeType(ctx context.Context, tabletType topodatapb.TabletType, semiSync bool) error Sleep(ctx context.Context, duration time.Duration) ExecuteHook(ctx context.Context, hk *hook.Hook) *hook.HookResult RefreshState(ctx context.Context) error RunHealthCheck(ctx context.Context) 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) ResetSequences(ctx context.Context, tables []string) error LockTables(ctx context.Context) error UnlockTables(ctx context.Context) error ExecuteQuery(ctx context.Context, req *tabletmanagerdatapb.ExecuteQueryRequest) (*querypb.QueryResult, error) ExecuteFetchAsDba(ctx context.Context, req *tabletmanagerdatapb.ExecuteFetchAsDbaRequest) (*querypb.QueryResult, error) ExecuteMultiFetchAsDba(ctx context.Context, req *tabletmanagerdatapb.ExecuteMultiFetchAsDbaRequest) ([]*querypb.QueryResult, error) ExecuteFetchAsAllPrivs(ctx context.Context, req *tabletmanagerdatapb.ExecuteFetchAsAllPrivsRequest) (*querypb.QueryResult, error) ExecuteFetchAsApp(ctx context.Context, req *tabletmanagerdatapb.ExecuteFetchAsAppRequest) (*querypb.QueryResult, error) // Replication related methods PrimaryStatus(ctx context.Context) (*replicationdatapb.PrimaryStatus, error) ReplicationStatus(ctx context.Context) (*replicationdatapb.Status, error) FullStatus(ctx context.Context) (*replicationdatapb.FullStatus, error) StopReplication(ctx context.Context) error StopReplicationMinimum(ctx context.Context, position string, waitTime time.Duration) (string, error) StartReplication(ctx context.Context, semiSync bool) error StartReplicationUntilAfter(ctx context.Context, position string, waitTime time.Duration) error GetReplicas(ctx context.Context) ([]string, error) PrimaryPosition(ctx context.Context) (string, error) WaitForPosition(ctx context.Context, pos string) error // VReplication API CreateVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.CreateVReplicationWorkflowRequest) (*tabletmanagerdatapb.CreateVReplicationWorkflowResponse, error) DeleteVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.DeleteVReplicationWorkflowRequest) (*tabletmanagerdatapb.DeleteVReplicationWorkflowResponse, error) HasVReplicationWorkflows(ctx context.Context, req *tabletmanagerdatapb.HasVReplicationWorkflowsRequest) (*tabletmanagerdatapb.HasVReplicationWorkflowsResponse, error) ReadVReplicationWorkflows(ctx context.Context, req *tabletmanagerdatapb.ReadVReplicationWorkflowsRequest) (*tabletmanagerdatapb.ReadVReplicationWorkflowsResponse, error) ReadVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.ReadVReplicationWorkflowRequest) (*tabletmanagerdatapb.ReadVReplicationWorkflowResponse, error) VReplicationExec(ctx context.Context, query string) (*querypb.QueryResult, error) VReplicationWaitForPos(ctx context.Context, id int32, pos string) error UpdateVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.UpdateVReplicationWorkflowRequest) (*tabletmanagerdatapb.UpdateVReplicationWorkflowResponse, error) UpdateVReplicationWorkflows(ctx context.Context, req *tabletmanagerdatapb.UpdateVReplicationWorkflowsRequest) (*tabletmanagerdatapb.UpdateVReplicationWorkflowsResponse, error) // VDiff API VDiff(ctx context.Context, req *tabletmanagerdatapb.VDiffRequest) (*tabletmanagerdatapb.VDiffResponse, error) ResetReplication(ctx context.Context) error InitPrimary(ctx context.Context, semiSync bool) (string, error) PopulateReparentJournal(ctx context.Context, timeCreatedNS int64, actionName string, tabletAlias *topodatapb.TabletAlias, pos string) error InitReplica(ctx context.Context, parent *topodatapb.TabletAlias, replicationPosition string, timeCreatedNS int64, semiSync bool) error DemotePrimary(ctx context.Context) (*replicationdatapb.PrimaryStatus, error) UndoDemotePrimary(ctx context.Context, semiSync bool) error ReplicaWasPromoted(ctx context.Context) error ResetReplicationParameters(ctx context.Context) error SetReplicationSource(ctx context.Context, parent *topodatapb.TabletAlias, timeCreatedNS int64, waitPosition string, forceStartReplication bool, semiSync bool, heartbeatInterval float64) error StopReplicationAndGetStatus(ctx context.Context, stopReplicationMode replicationdatapb.StopReplicationMode) (StopReplicationAndGetStatusResponse, error) ReplicaWasRestarted(ctx context.Context, parent *topodatapb.TabletAlias) error PromoteReplica(ctx context.Context, semiSync bool) (string, error) Backup(ctx context.Context, logger logutil.Logger, request *tabletmanagerdatapb.BackupRequest) error RestoreFromBackup(ctx context.Context, logger logutil.Logger, request *tabletmanagerdatapb.RestoreFromBackupRequest) error // HandleRPCPanic is to be called in a defer statement in each // RPC input point. HandleRPCPanic(ctx context.Context, name string, args, reply any, verbose bool, err *error) // Throttler CheckThrottler(ctx context.Context, request *tabletmanagerdatapb.CheckThrottlerRequest) (*tabletmanagerdatapb.CheckThrottlerResponse, error) }
RPCTM defines the interface implemented by the TM for RPCs. It is useful for RPC implementations to test their full stack.
type RegisterTabletManager ¶
type RegisterTabletManager func(*TabletManager)
RegisterTabletManager is used to delay registration of RPC servers until we have all the objects.
type SemiSyncAction ¶ added in v0.13.0
type SemiSyncAction int
SemiSyncAction is used to tell fixSemiSync whether to change the semi-sync settings or not.
type StopReplicationAndGetStatusResponse ¶
type StopReplicationAndGetStatusResponse struct { // Status represents the replication status call right before, and right after telling the replica to stop. Status *replicationdatapb.StopReplicationStatus }
StopReplicationAndGetStatusResponse holds the original hybrid Status struct, as well as a new Status field, which hold the result of show replica status called before stopping replication, and after stopping replication.
type TabletManager ¶
type TabletManager struct { // The following fields are set during creation BatchCtx context.Context TopoServer *topo.Server Cnf *mysqlctl.Mycnf MysqlDaemon mysqlctl.MysqlDaemon DBConfigs *dbconfigs.DBConfigs QueryServiceControl tabletserver.Controller UpdateStream binlog.UpdateStreamControl VREngine *vreplication.Engine VDiffEngine *vdiff.Engine Env *vtenv.Environment // contains filtered or unexported fields }
TabletManager is the main class for the tablet manager.
func (*TabletManager) ApplySchema ¶
func (tm *TabletManager) ApplySchema(ctx context.Context, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error)
ApplySchema will apply a schema change
func (*TabletManager) Backup ¶
func (tm *TabletManager) Backup(ctx context.Context, logger logutil.Logger, req *tabletmanagerdatapb.BackupRequest) error
Backup takes a db backup and sends it to the BackupStorage.
func (*TabletManager) ChangeType ¶
func (tm *TabletManager) ChangeType(ctx context.Context, tabletType topodatapb.TabletType, semiSync bool) error
ChangeType changes the tablet type
func (*TabletManager) CheckThrottler ¶ added in v0.18.0
func (tm *TabletManager) CheckThrottler(ctx context.Context, req *tabletmanagerdatapb.CheckThrottlerRequest) (*tabletmanagerdatapb.CheckThrottlerResponse, error)
CheckThrottler executes a throttler check
func (*TabletManager) Close ¶
func (tm *TabletManager) Close()
Close prepares a tablet for shutdown. First we check our tablet ownership and then prune the tablet topology entry of all post-init fields. This prevents stale identifiers from hanging around in topology.
func (*TabletManager) CreateVReplicationWorkflow ¶ added in v0.18.0
func (tm *TabletManager) CreateVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.CreateVReplicationWorkflowRequest) (*tabletmanagerdatapb.CreateVReplicationWorkflowResponse, error)
func (*TabletManager) DeleteVReplicationWorkflow ¶ added in v0.18.0
func (tm *TabletManager) DeleteVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.DeleteVReplicationWorkflowRequest) (*tabletmanagerdatapb.DeleteVReplicationWorkflowResponse, error)
func (*TabletManager) DemotePrimary ¶ added in v0.11.0
func (tm *TabletManager) DemotePrimary(ctx context.Context) (*replicationdatapb.PrimaryStatus, error)
DemotePrimary prepares a PRIMARY tablet to give up leadership to another tablet.
It attempts to idempotently ensure the following guarantees upon returning successfully:
- No future writes will be accepted.
- No writes are in-flight.
- MySQL is in read-only mode.
- Semi-sync settings are consistent with a REPLICA tablet.
If necessary, it waits for all in-flight writes to complete or time out.
It should be safe to call this on a PRIMARY tablet that was already demoted, or on a tablet that already transitioned to REPLICA.
If a step fails in the middle, it will try to undo any changes it made.
func (*TabletManager) DeniedTables ¶ added in v0.12.0
func (tm *TabletManager) DeniedTables() []string
DeniedTables returns the list of currently denied tables.
func (*TabletManager) ExecuteFetchAsAllPrivs ¶
func (tm *TabletManager) ExecuteFetchAsAllPrivs(ctx context.Context, req *tabletmanagerdatapb.ExecuteFetchAsAllPrivsRequest) (*querypb.QueryResult, error)
ExecuteFetchAsAllPrivs will execute the given query, possibly reloading schema.
func (*TabletManager) ExecuteFetchAsApp ¶
func (tm *TabletManager) ExecuteFetchAsApp(ctx context.Context, req *tabletmanagerdatapb.ExecuteFetchAsAppRequest) (*querypb.QueryResult, error)
ExecuteFetchAsApp will execute the given query.
func (*TabletManager) ExecuteFetchAsDba ¶
func (tm *TabletManager) ExecuteFetchAsDba(ctx context.Context, req *tabletmanagerdatapb.ExecuteFetchAsDbaRequest) (*querypb.QueryResult, error)
ExecuteFetchAsDba will execute the given query, possibly disabling binlogs and reload schema.
func (*TabletManager) ExecuteHook ¶
func (tm *TabletManager) ExecuteHook(ctx context.Context, hk *hook.Hook) *hook.HookResult
ExecuteHook executes the provided hook locally, and returns the result.
func (*TabletManager) ExecuteMultiFetchAsDba ¶ added in v0.20.0
func (tm *TabletManager) ExecuteMultiFetchAsDba(ctx context.Context, req *tabletmanagerdatapb.ExecuteMultiFetchAsDbaRequest) ([]*querypb.QueryResult, error)
ExecuteMultiFetchAsDba will execute the given queries, possibly disabling binlogs and reload schema.
func (*TabletManager) ExecuteQuery ¶ added in v0.11.0
func (tm *TabletManager) ExecuteQuery(ctx context.Context, req *tabletmanagerdatapb.ExecuteQueryRequest) (*querypb.QueryResult, error)
ExecuteQuery submits a new online DDL request
func (*TabletManager) FullStatus ¶ added in v0.14.0
func (tm *TabletManager) FullStatus(ctx context.Context) (*replicationdatapb.FullStatus, error)
FullStatus returns the full status of MySQL including the replication information, semi-sync information, GTID information among others
func (*TabletManager) GetGlobalStatusVars ¶ added in v0.20.0
func (tm *TabletManager) GetGlobalStatusVars(ctx context.Context, variables []string) (map[string]string, error)
GetGlobalStatusVars returns the server's global status variables asked for. An empty/nil variable name parameter slice means you want all of them.
func (*TabletManager) GetPermissions ¶
func (tm *TabletManager) GetPermissions(ctx context.Context) (*tabletmanagerdatapb.Permissions, error)
GetPermissions returns the db permissions.
func (*TabletManager) GetReplicas ¶
func (tm *TabletManager) GetReplicas(ctx context.Context) ([]string, error)
GetReplicas returns the address of all the replicas
func (*TabletManager) GetSchema ¶
func (tm *TabletManager) GetSchema(ctx context.Context, request *tabletmanagerdatapb.GetSchemaRequest) (*tabletmanagerdatapb.SchemaDefinition, error)
GetSchema returns the schema.
func (*TabletManager) HandleRPCPanic ¶
func (tm *TabletManager) HandleRPCPanic(ctx context.Context, name string, args, reply any, verbose bool, err *error)
HandleRPCPanic is part of the RPCTM interface.
func (*TabletManager) HasVReplicationWorkflows ¶ added in v0.20.0
func (tm *TabletManager) HasVReplicationWorkflows(ctx context.Context, req *tabletmanagerdatapb.HasVReplicationWorkflowsRequest) (*tabletmanagerdatapb.HasVReplicationWorkflowsResponse, error)
func (*TabletManager) InitPrimary ¶ added in v0.11.0
InitPrimary enables writes and returns the replication position.
func (*TabletManager) InitReplica ¶
func (tm *TabletManager) InitReplica(ctx context.Context, parent *topodatapb.TabletAlias, position string, timeCreatedNS int64, semiSync bool) error
InitReplica sets replication primary and position, and waits for the reparent_journal table entry up to context timeout
func (*TabletManager) LockTables ¶
func (tm *TabletManager) LockTables(ctx context.Context) error
LockTables will lock all tables with read locks, effectively pausing replication while the lock is held (idempotent)
func (*TabletManager) Ping ¶
func (tm *TabletManager) Ping(ctx context.Context, args string) string
Ping makes sure RPCs work, and refreshes the tablet record.
func (*TabletManager) PopulateReparentJournal ¶
func (tm *TabletManager) PopulateReparentJournal(ctx context.Context, timeCreatedNS int64, actionName string, primaryAlias *topodatapb.TabletAlias, position string) error
PopulateReparentJournal adds an entry into the reparent_journal table.
func (*TabletManager) PreflightSchema ¶
func (tm *TabletManager) PreflightSchema(ctx context.Context, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)
PreflightSchema will try out the schema changes in "changes".
func (*TabletManager) PrimaryPosition ¶ added in v0.11.0
func (tm *TabletManager) PrimaryPosition(ctx context.Context) (string, error)
PrimaryPosition returns the position of a primary database
func (*TabletManager) PrimaryStatus ¶ added in v0.11.0
func (tm *TabletManager) PrimaryStatus(ctx context.Context) (*replicationdatapb.PrimaryStatus, error)
PrimaryStatus returns the replication status for a primary tablet.
func (*TabletManager) PromoteReplica ¶
PromoteReplica makes the current tablet the primary
func (*TabletManager) ReadVReplicationWorkflow ¶ added in v0.18.0
func (tm *TabletManager) ReadVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.ReadVReplicationWorkflowRequest) (*tabletmanagerdatapb.ReadVReplicationWorkflowResponse, error)
func (*TabletManager) ReadVReplicationWorkflows ¶ added in v0.20.0
func (tm *TabletManager) ReadVReplicationWorkflows(ctx context.Context, req *tabletmanagerdatapb.ReadVReplicationWorkflowsRequest) (*tabletmanagerdatapb.ReadVReplicationWorkflowsResponse, error)
func (*TabletManager) RefreshState ¶
func (tm *TabletManager) RefreshState(ctx context.Context) error
RefreshState reload the tablet record from the topo server.
func (*TabletManager) ReloadSchema ¶
func (tm *TabletManager) ReloadSchema(ctx context.Context, waitPosition string) error
ReloadSchema will reload the schema This doesn't need the action mutex because periodic schema reloads happen in the background anyway.
func (*TabletManager) ReplicaWasPromoted ¶
func (tm *TabletManager) ReplicaWasPromoted(ctx context.Context) error
ReplicaWasPromoted promotes a replica to primary, no questions asked.
func (*TabletManager) ReplicaWasRestarted ¶
func (tm *TabletManager) ReplicaWasRestarted(ctx context.Context, parent *topodatapb.TabletAlias) error
ReplicaWasRestarted updates the parent record for a tablet.
func (*TabletManager) ReplicationStatus ¶
func (tm *TabletManager) ReplicationStatus(ctx context.Context) (*replicationdatapb.Status, error)
ReplicationStatus returns the replication status
func (*TabletManager) ResetReplication ¶
func (tm *TabletManager) 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 (*TabletManager) ResetReplicationParameters ¶ added in v0.14.0
func (tm *TabletManager) ResetReplicationParameters(ctx context.Context) error
ResetReplicationParameters resets the replica replication parameters
func (*TabletManager) ResetSequences ¶ added in v0.18.0
func (tm *TabletManager) ResetSequences(ctx context.Context, tables []string) error
ResetSequences will reset the auto-inc counters on the specified tables.
func (*TabletManager) RestoreData ¶
func (tm *TabletManager) RestoreData( ctx context.Context, logger logutil.Logger, waitForBackupInterval time.Duration, deleteBeforeRestore bool, backupTime time.Time, restoreToTimetamp time.Time, restoreToPos string, mysqlShutdownTimeout time.Duration) error
RestoreData 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 (*TabletManager) RestoreFromBackup ¶
func (tm *TabletManager) RestoreFromBackup(ctx context.Context, logger logutil.Logger, request *tabletmanagerdatapb.RestoreFromBackupRequest) error
RestoreFromBackup deletes all local data and then restores the data from the latest backup [at or before the backupTime value if specified]
func (*TabletManager) RunHealthCheck ¶
func (tm *TabletManager) RunHealthCheck(ctx context.Context)
RunHealthCheck will manually run the health check on the tablet.
func (*TabletManager) SetReadOnly ¶
func (tm *TabletManager) SetReadOnly(ctx context.Context, rdonly bool) error
SetReadOnly makes the mysql instance read-only or read-write.
func (*TabletManager) SetReplicationSource ¶ added in v0.11.0
func (tm *TabletManager) SetReplicationSource(ctx context.Context, parentAlias *topodatapb.TabletAlias, timeCreatedNS int64, waitPosition string, forceStartReplication bool, semiSync bool, heartbeatInterval float64) error
SetReplicationSource sets replication primary, and waits for the reparent_journal table entry up to context timeout
func (*TabletManager) Sleep ¶
func (tm *TabletManager) Sleep(ctx context.Context, duration time.Duration)
Sleep sleeps for the duration
func (*TabletManager) Start ¶
func (tm *TabletManager) Start(tablet *topodatapb.Tablet, config *tabletenv.TabletConfig) error
Start starts the TabletManager.
func (*TabletManager) StartReplication ¶
func (tm *TabletManager) StartReplication(ctx context.Context, semiSync bool) error
StartReplication will start the mysql. Works both when Vitess manages replication or not (using hook if not).
func (*TabletManager) StartReplicationUntilAfter ¶
func (tm *TabletManager) StartReplicationUntilAfter(ctx context.Context, position string, waitTime time.Duration) error
StartReplicationUntilAfter will start the replication and let it catch up until and including the transactions in `position`
func (*TabletManager) Stop ¶
func (tm *TabletManager) Stop()
Stop shuts down the tm. 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 a tm immediately.
func (*TabletManager) StopReplication ¶
func (tm *TabletManager) StopReplication(ctx context.Context) error
StopReplication will stop the mysql. Works both when Vitess manages replication or not (using hook if not).
func (*TabletManager) StopReplicationAndGetStatus ¶
func (tm *TabletManager) StopReplicationAndGetStatus(ctx context.Context, stopReplicationMode replicationdatapb.StopReplicationMode) (StopReplicationAndGetStatusResponse, error)
StopReplicationAndGetStatus stops MySQL replication, and returns the current status.
func (*TabletManager) StopReplicationMinimum ¶
func (tm *TabletManager) StopReplicationMinimum(ctx context.Context, position string, waitTime time.Duration) (string, error)
StopReplicationMinimum will stop the replication after it reaches at least the provided position. Works both when Vitess manages replication or not (using hook if not).
func (*TabletManager) Tablet ¶
func (tm *TabletManager) Tablet() *topodatapb.Tablet
Tablet reads the stored Tablet from the tm.
func (*TabletManager) UndoDemotePrimary ¶ added in v0.11.0
func (tm *TabletManager) UndoDemotePrimary(ctx context.Context, semiSync bool) error
UndoDemotePrimary reverts a previous call to DemotePrimary it sets read-only to false, fixes semi-sync and returns its primary position.
func (*TabletManager) UnlockTables ¶
func (tm *TabletManager) UnlockTables(ctx context.Context) error
UnlockTables will unlock all tables (idempotent)
func (*TabletManager) UpdateVReplicationWorkflow ¶ added in v0.18.0
func (tm *TabletManager) UpdateVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.UpdateVReplicationWorkflowRequest) (*tabletmanagerdatapb.UpdateVReplicationWorkflowResponse, error)
UpdateVReplicationWorkflow updates the sidecar databases's vreplication record(s) for this tablet's vreplication workflow stream(s). If there are no streams for the given workflow on the tablet then a nil result is returned as this is expected e.g. on source tablets of a Reshard workflow (source and target are the same keyspace). The caller can consider this case an error if they choose to. Note: the VReplication engine creates a new controller for the workflow stream when the record is updated, so we also in effect restart the workflow stream via the update.
func (*TabletManager) UpdateVReplicationWorkflows ¶ added in v0.20.0
func (tm *TabletManager) UpdateVReplicationWorkflows(ctx context.Context, req *tabletmanagerdatapb.UpdateVReplicationWorkflowsRequest) (*tabletmanagerdatapb.UpdateVReplicationWorkflowsResponse, error)
UpdateVReplicationWorkflows operates in much the same way that UpdateVReplicationWorkflow does, but it allows you to update the metadata/flow control fields -- state, message, and stop_pos -- for multiple workflows. Note: today this is only used during Reshard as all of the vreplication streams need to be migrated from the old shards to the new ones.
func (*TabletManager) VDiff ¶ added in v0.14.0
func (tm *TabletManager) VDiff(ctx context.Context, req *tabletmanagerdatapb.VDiffRequest) (*tabletmanagerdatapb.VDiffResponse, error)
func (*TabletManager) VReplicationExec ¶
func (tm *TabletManager) VReplicationExec(ctx context.Context, query string) (*querypb.QueryResult, error)
VReplicationExec executes a vreplication command.
func (*TabletManager) VReplicationWaitForPos ¶
VReplicationWaitForPos waits for the specified position.
func (*TabletManager) WaitForPosition ¶
func (tm *TabletManager) WaitForPosition(ctx context.Context, pos string) error
WaitForPosition waits until replication reaches the desired position
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package events contains event structs used by the tabletmanager package.
|
Package events contains event structs used by the tabletmanager package. |
package vdiff implements the Vitess Diff functionality which compares the logical contents of MySQL tables across keyspaces and shards
|
package vdiff implements the Vitess Diff functionality which compares the logical contents of MySQL tables across keyspaces and shards |
queryhistory
Package queryhistory provides tools for verifying that a SQL statement history conforms to a set of expectations.
|
Package queryhistory provides tools for verifying that a SQL statement history conforms to a set of expectations. |