Documentation ¶
Index ¶
- func AcknowledgeAllRecoveries(owner string, comment string) (countAcknowledgedEntries int64, err error)
- func AcknowledgeClusterRecoveries(clusterName string, owner string, comment string) (countAcknowledgedEntries int64, err error)
- func AcknowledgeCrashedRecoveries() (countAcknowledgedEntries int64, err error)
- func AcknowledgeInstanceCompletedRecoveries(instanceKey *inst.InstanceKey, owner string, comment string) (countAcknowledgedEntries int64, err error)
- func AcknowledgeInstanceRecoveries(instanceKey *inst.InstanceKey, owner string, comment string) (countAcknowledgedEntries int64, err error)
- func AcknowledgeRecovery(recoveryId int64, owner string, comment string) (countAcknowledgedEntries int64, err error)
- func AcknowledgeRecoveryByUID(recoveryUID string, owner string, comment string) (countAcknowledgedEntries int64, err error)
- func AttemptFailureDetectionRegistration(analysisEntry *inst.ReplicationAnalysis) (registrationSuccessful bool, err error)
- func AuditTopologyRecovery(topologyRecovery *TopologyRecovery, message string) error
- func CheckAndRecover(specificInstance *inst.InstanceKey, candidateInstanceKey *inst.InstanceKey, ...) (recoveryAttempted bool, promotedReplicaKey *inst.InstanceKey, err error)
- func ClearActiveFailureDetections() error
- func ClearActiveRecoveries() error
- func ContinuousAgentsPoll()
- func ContinuousDiscovery()
- func DisableRecovery() error
- func DiscoverInstance(instanceKey inst.InstanceKey)
- func EnableRecovery() error
- func ExpireBlockedRecoveries() error
- func ExpireFailureDetectionHistory() error
- func ExpireTopologyRecoveryHistory() error
- func ExpireTopologyRecoveryStepsHistory() error
- func GetCandidateSiblingOfIntermediateMaster(topologyRecovery *TopologyRecovery, intermediateMasterInstance *inst.Instance) (*inst.Instance, error)
- func InjectPseudoGTIDOnWriters() error
- func IsLeader() bool
- func IsLeaderOrActive() bool
- func IsRecoveryDisabled() (disabled bool, err error)
- func LockShard(instanceKey inst.InstanceKey) (func(*error), error)
- func MasterFailoverGeographicConstraintSatisfied(analysisEntry *inst.ReplicationAnalysis, suggestedInstance *inst.Instance) (satisfied bool, dissatisfiedReason string)
- func OpenTabletDiscovery() <-chan time.Time
- func RecoverDeadCoMaster(topologyRecovery *TopologyRecovery, skipProcesses bool) (promotedReplica *inst.Instance, lostReplicas [](*inst.Instance), err error)
- func RecoverDeadIntermediateMaster(topologyRecovery *TopologyRecovery, skipProcesses bool) (successorInstance *inst.Instance, err error)
- func RefreshTablets()
- func RegisterBlockedRecoveries(analysisEntry *inst.ReplicationAnalysis, ...) error
- func SetRecoveryDisabled(disabled bool) error
- func ShardMaster(instanceKey *inst.InstanceKey) (masterKey *inst.InstanceKey, err error)
- func SubmitMastersToKvStores(clusterName string, force bool) (kvPairs [](*kv.KVPair), submittedCount int, err error)
- func SuggestReplacementForPromotedReplica(topologyRecovery *TopologyRecovery, deadInstanceKey *inst.InstanceKey, ...) (replacement *inst.Instance, actionRequired bool, err error)
- func TabletDemoteMaster(instanceKey inst.InstanceKey) error
- func TabletRefresh(instanceKey inst.InstanceKey) (*topodatapb.Tablet, error)
- func TabletUndoDemoteMaster(instanceKey inst.InstanceKey) error
- type BlockedTopologyRecovery
- type CommandApplier
- type InstancesByCountReplicas
- type MasterRecoveryType
- type RecoveryAcknowledgement
- type RecoveryType
- type SnapshotData
- type SnapshotDataCreatorApplier
- type TopologyRecovery
- func AttemptRecoveryRegistration(analysisEntry *inst.ReplicationAnalysis, ...) (*TopologyRecovery, error)
- func ForceExecuteRecovery(analysisEntry inst.ReplicationAnalysis, candidateInstanceKey *inst.InstanceKey, ...) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error)
- func ForceMasterFailover(clusterName string) (topologyRecovery *TopologyRecovery, err error)
- func ForceMasterTakeover(clusterName string, destination *inst.Instance) (topologyRecovery *TopologyRecovery, err error)
- func GracefulMasterTakeover(clusterName string, designatedKey *inst.InstanceKey, auto bool) (topologyRecovery *TopologyRecovery, ...)
- func NewTopologyRecovery(replicationAnalysis inst.ReplicationAnalysis) *TopologyRecovery
- func ReadActiveClusterRecovery(clusterName string) ([]*TopologyRecovery, error)
- func ReadActiveRecoveries() ([]*TopologyRecovery, error)
- func ReadCompletedRecoveries(page int) ([]*TopologyRecovery, error)
- func ReadFailureDetection(detectionId int64) ([]*TopologyRecovery, error)
- func ReadInActivePeriodClusterRecovery(clusterName string) ([]*TopologyRecovery, error)
- func ReadInActivePeriodSuccessorInstanceRecovery(instanceKey *inst.InstanceKey) ([]*TopologyRecovery, error)
- func ReadRecentFailureDetections(clusterAlias string, page int) ([]*TopologyRecovery, error)
- func ReadRecentRecoveries(clusterName string, clusterAlias string, unacknowledgedOnly bool, page int) ([]*TopologyRecovery, error)
- func ReadRecentlyActiveClusterRecovery(clusterName string) ([]*TopologyRecovery, error)
- func ReadRecentlyActiveInstanceRecovery(instanceKey *inst.InstanceKey) ([]*TopologyRecovery, error)
- func ReadRecovery(recoveryId int64) ([]*TopologyRecovery, error)
- func ReadRecoveryByUID(recoveryUID string) ([]*TopologyRecovery, error)
- type TopologyRecoveryStep
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcknowledgeAllRecoveries ¶
func AcknowledgeAllRecoveries(owner string, comment string) (countAcknowledgedEntries int64, err error)
AcknowledgeAllRecoveries acknowledges all unacknowledged recoveries.
func AcknowledgeClusterRecoveries ¶
func AcknowledgeClusterRecoveries(clusterName string, owner string, comment string) (countAcknowledgedEntries int64, err error)
AcknowledgeClusterRecoveries marks active recoveries for given cluster as acknowledged. This also implied clearing their active period, which in turn enables further recoveries on those topologies
func AcknowledgeCrashedRecoveries ¶
AcknowledgeCrashedRecoveries marks recoveries whose processing nodes has crashed as acknowledged.
func AcknowledgeInstanceCompletedRecoveries ¶
func AcknowledgeInstanceCompletedRecoveries(instanceKey *inst.InstanceKey, owner string, comment string) (countAcknowledgedEntries int64, err error)
AcknowledgeInstanceCompletedRecoveries marks active and COMPLETED recoveries for given instane as acknowledged. This also implied clearing their active period, which in turn enables further recoveries on those topologies
func AcknowledgeInstanceRecoveries ¶
func AcknowledgeInstanceRecoveries(instanceKey *inst.InstanceKey, owner string, comment string) (countAcknowledgedEntries int64, err error)
AcknowledgeInstanceRecoveries marks active recoveries for given instane as acknowledged. This also implied clearing their active period, which in turn enables further recoveries on those topologies
func AcknowledgeRecovery ¶
func AcknowledgeRecovery(recoveryId int64, owner string, comment string) (countAcknowledgedEntries int64, err error)
AcknowledgeRecovery acknowledges a particular recovery. This also implied clearing their active period, which in turn enables further recoveries on those topologies
func AcknowledgeRecoveryByUID ¶
func AcknowledgeRecoveryByUID(recoveryUID string, owner string, comment string) (countAcknowledgedEntries int64, err error)
AcknowledgeRecovery acknowledges a particular recovery. This also implied clearing their active period, which in turn enables further recoveries on those topologies
func AttemptFailureDetectionRegistration ¶
func AttemptFailureDetectionRegistration(analysisEntry *inst.ReplicationAnalysis) (registrationSuccessful bool, err error)
AttemptFailureDetectionRegistration tries to add a failure-detection entry; if this fails that means the problem has already been detected
func AuditTopologyRecovery ¶
func AuditTopologyRecovery(topologyRecovery *TopologyRecovery, message string) error
AuditTopologyRecovery audits a single step in a topology recovery process.
func CheckAndRecover ¶
func CheckAndRecover(specificInstance *inst.InstanceKey, candidateInstanceKey *inst.InstanceKey, skipProcesses bool) (recoveryAttempted bool, promotedReplicaKey *inst.InstanceKey, err error)
CheckAndRecover is the main entry point for the recovery mechanism
func ClearActiveFailureDetections ¶
func ClearActiveFailureDetections() error
ClearActiveFailureDetections clears the "in_active_period" flag for old-enough detections, thereby allowing for further detections on cleared instances.
func ClearActiveRecoveries ¶
func ClearActiveRecoveries() error
ClearActiveRecoveries clears the "in_active_period" flag for old-enough recoveries, thereby allowing for further recoveries on cleared instances.
func ContinuousAgentsPoll ¶
func ContinuousAgentsPoll()
ContinuousAgentsPoll starts an asynchronuous infinite process where agents are periodically investigated and their status captured, and long since unseen agents are purged and forgotten.
func ContinuousDiscovery ¶
func ContinuousDiscovery()
ContinuousDiscovery starts an asynchronuous infinite discovery process where instances are periodically investigated and their status captured, and long since unseen instances are purged and forgotten. nolint SA1015: using time.Tick leaks the underlying ticker
func DisableRecovery ¶
func DisableRecovery() error
DisableRecovery ensures recoveries are disabled globally
func DiscoverInstance ¶
func DiscoverInstance(instanceKey inst.InstanceKey)
DiscoverInstance will attempt to discover (poll) an instance (unless it is already up to date) and will also ensure that its master and replicas (if any) are also checked.
func EnableRecovery ¶
func EnableRecovery() error
EnableRecovery ensures recoveries are enabled globally
func ExpireBlockedRecoveries ¶
func ExpireBlockedRecoveries() error
ExpireBlockedRecoveries clears listing of blocked recoveries that are no longer actually blocked.
func ExpireFailureDetectionHistory ¶
func ExpireFailureDetectionHistory() error
ExpireFailureDetectionHistory removes old rows from the topology_failure_detection table
func ExpireTopologyRecoveryHistory ¶
func ExpireTopologyRecoveryHistory() error
ExpireTopologyRecoveryHistory removes old rows from the topology_failure_detection table
func ExpireTopologyRecoveryStepsHistory ¶
func ExpireTopologyRecoveryStepsHistory() error
ExpireTopologyRecoveryStepsHistory removes old rows from the topology_failure_detection table
func GetCandidateSiblingOfIntermediateMaster ¶
func GetCandidateSiblingOfIntermediateMaster(topologyRecovery *TopologyRecovery, intermediateMasterInstance *inst.Instance) (*inst.Instance, error)
GetCandidateSiblingOfIntermediateMaster chooses the best sibling of a dead intermediate master to whom the IM's replicas can be moved.
func InjectPseudoGTIDOnWriters ¶
func InjectPseudoGTIDOnWriters() error
InjectPseudoGTIDOnWriters will inject a PseudoGTID entry on all writable, accessible, supported writers.
func IsLeaderOrActive ¶
func IsLeaderOrActive() bool
func IsRecoveryDisabled ¶
IsRecoveryDisabled returns true if Recoveries are disabled globally
func LockShard ¶
func LockShard(instanceKey inst.InstanceKey) (func(*error), error)
LockShard locks the keyspace-shard preventing others from performing conflicting actions.
func OpenTabletDiscovery ¶
OpenTabletDiscovery opens the vitess topo if enables and returns a ticker channel for polling.
func RecoverDeadCoMaster ¶
func RecoverDeadCoMaster(topologyRecovery *TopologyRecovery, skipProcesses bool) (promotedReplica *inst.Instance, lostReplicas [](*inst.Instance), err error)
RecoverDeadCoMaster recovers a dead co-master, complete logic inside
func RecoverDeadIntermediateMaster ¶
func RecoverDeadIntermediateMaster(topologyRecovery *TopologyRecovery, skipProcesses bool) (successorInstance *inst.Instance, err error)
RecoverDeadIntermediateMaster performs intermediate master recovery; complete logic inside
func RegisterBlockedRecoveries ¶
func RegisterBlockedRecoveries(analysisEntry *inst.ReplicationAnalysis, blockingRecoveries []*TopologyRecovery) error
RegisterBlockedRecoveries writes down currently blocked recoveries, and indicates what recovery they are blocked on. Recoveries are blocked thru the in_active_period flag, which comes to avoid flapping.
func SetRecoveryDisabled ¶
func ShardMaster ¶
func ShardMaster(instanceKey *inst.InstanceKey) (masterKey *inst.InstanceKey, err error)
func SubmitMastersToKvStores ¶
func SubmitMastersToKvStores(clusterName string, force bool) (kvPairs [](*kv.KVPair), submittedCount int, err error)
Write a cluster's master (or all clusters masters) to kv stores. This should generally only happen once in a lifetime of a cluster. Otherwise KV stores are updated via failovers.
func SuggestReplacementForPromotedReplica ¶
func SuggestReplacementForPromotedReplica(topologyRecovery *TopologyRecovery, deadInstanceKey *inst.InstanceKey, promotedReplica *inst.Instance, candidateInstanceKey *inst.InstanceKey) (replacement *inst.Instance, actionRequired bool, err error)
SuggestReplacementForPromotedReplica returns a server to take over the already promoted replica, if such server is found and makes an improvement over the promoted replica.
func TabletDemoteMaster ¶
func TabletDemoteMaster(instanceKey inst.InstanceKey) error
TabletDemoteMaster requests the master tablet to stop accepting transactions.
func TabletRefresh ¶
func TabletRefresh(instanceKey inst.InstanceKey) (*topodatapb.Tablet, error)
TabletRefresh refreshes the tablet info.
func TabletUndoDemoteMaster ¶
func TabletUndoDemoteMaster(instanceKey inst.InstanceKey) error
TabletUndoDemoteMaster requests the master tablet to undo the demote.
Types ¶
type BlockedTopologyRecovery ¶
type BlockedTopologyRecovery struct { FailedInstanceKey inst.InstanceKey ClusterName string Analysis inst.AnalysisCode LastBlockedTimestamp string BlockingRecoveryId int64 }
BlockedTopologyRecovery represents an entry in the blocked_topology_recovery table
func ReadBlockedRecoveries ¶
func ReadBlockedRecoveries(clusterName string) ([]BlockedTopologyRecovery, error)
ReadBlockedRecoveries reads blocked recovery entries, potentially filtered by cluster name (empty to unfilter)
type CommandApplier ¶
type CommandApplier struct { }
AsyncRequest represents an entry in the async_request table
func NewCommandApplier ¶
func NewCommandApplier() *CommandApplier
func (*CommandApplier) ApplyCommand ¶
func (applier *CommandApplier) ApplyCommand(op string, value []byte) interface{}
type InstancesByCountReplicas ¶
InstancesByCountReplicas sorts instances by umber of replicas, descending
func (InstancesByCountReplicas) Len ¶
func (this InstancesByCountReplicas) Len() int
func (InstancesByCountReplicas) Less ¶
func (this InstancesByCountReplicas) Less(i, j int) bool
func (InstancesByCountReplicas) Swap ¶
func (this InstancesByCountReplicas) Swap(i, j int)
type MasterRecoveryType ¶
type MasterRecoveryType string
const ( NotMasterRecovery MasterRecoveryType = "NotMasterRecovery" MasterRecoveryGTID MasterRecoveryType = "MasterRecoveryGTID" MasterRecoveryPseudoGTID MasterRecoveryType = "MasterRecoveryPseudoGTID" MasterRecoveryBinlogServer MasterRecoveryType = "MasterRecoveryBinlogServer" )
func GetMasterRecoveryType ¶
func GetMasterRecoveryType(analysisEntry *inst.ReplicationAnalysis) (masterRecoveryType MasterRecoveryType)
type RecoveryAcknowledgement ¶
type RecoveryAcknowledgement struct { CreatedAt time.Time Owner string Comment string Key inst.InstanceKey ClusterName string Id int64 UID string AllRecoveries bool }
func NewInternalAcknowledgement ¶
func NewInternalAcknowledgement() *RecoveryAcknowledgement
func NewRecoveryAcknowledgement ¶
func NewRecoveryAcknowledgement(owner string, comment string) *RecoveryAcknowledgement
type RecoveryType ¶
type RecoveryType string
const ( MasterRecovery RecoveryType = "MasterRecovery" CoMasterRecovery RecoveryType = "CoMasterRecovery" IntermediateMasterRecovery RecoveryType = "IntermediateMasterRecovery" )
type SnapshotData ¶
type SnapshotData struct { Keys []inst.InstanceKey // Kept for backwards comapatibility MinimalInstances []inst.MinimalInstance RecoveryDisabled bool ClusterAlias, ClusterAliasOverride, ClusterDomainName, HostAttributes, InstanceTags, AccessToken, PoolInstances, InjectedPseudoGTIDClusters, HostnameResolves, HostnameUnresolves, DowntimedInstances, Candidates, Detections, KVStore, Recovery, RecoverySteps sqlutils.NamedResultData LeaderURI string }
func CreateSnapshotData ¶
func CreateSnapshotData() *SnapshotData
func NewSnapshotData ¶
func NewSnapshotData() *SnapshotData
type SnapshotDataCreatorApplier ¶
type SnapshotDataCreatorApplier struct { }
func NewSnapshotDataCreatorApplier ¶
func NewSnapshotDataCreatorApplier() *SnapshotDataCreatorApplier
func (*SnapshotDataCreatorApplier) GetData ¶
func (this *SnapshotDataCreatorApplier) GetData() (data []byte, err error)
func (*SnapshotDataCreatorApplier) Restore ¶
func (this *SnapshotDataCreatorApplier) Restore(rc io.ReadCloser) error
type TopologyRecovery ¶
type TopologyRecovery struct { inst.PostponedFunctionsContainer Id int64 UID string AnalysisEntry inst.ReplicationAnalysis SuccessorKey *inst.InstanceKey SuccessorAlias string IsActive bool IsSuccessful bool LostReplicas inst.InstanceKeyMap ParticipatingInstanceKeys inst.InstanceKeyMap AllErrors []string RecoveryStartTimestamp string RecoveryEndTimestamp string ProcessingNodeHostname string ProcessingNodeToken string Acknowledged bool AcknowledgedAt string AcknowledgedBy string AcknowledgedComment string LastDetectionId int64 RelatedRecoveryId int64 Type RecoveryType RecoveryType MasterRecoveryType }
TopologyRecovery represents an entry in the topology_recovery table
func AttemptRecoveryRegistration ¶
func AttemptRecoveryRegistration(analysisEntry *inst.ReplicationAnalysis, failIfFailedInstanceInActiveRecovery bool, failIfClusterInActiveRecovery bool) (*TopologyRecovery, error)
AttemptRecoveryRegistration tries to add a recovery entry; if this fails that means recovery is already in place.
func ForceExecuteRecovery ¶
func ForceExecuteRecovery(analysisEntry inst.ReplicationAnalysis, candidateInstanceKey *inst.InstanceKey, skipProcesses bool) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error)
ForceExecuteRecovery can be called to issue a recovery process even if analysis says there is no recovery case. The caller of this function injects the type of analysis it wishes the function to assume. By calling this function one takes responsibility for one's actions.
func ForceMasterFailover ¶
func ForceMasterFailover(clusterName string) (topologyRecovery *TopologyRecovery, err error)
ForceMasterFailover *trusts* master of given cluster is dead and initiates a failover
func ForceMasterTakeover ¶
func ForceMasterTakeover(clusterName string, destination *inst.Instance) (topologyRecovery *TopologyRecovery, err error)
ForceMasterTakeover *trusts* master of given cluster is dead and fails over to designated instance, which has to be its direct child.
func GracefulMasterTakeover ¶
func GracefulMasterTakeover(clusterName string, designatedKey *inst.InstanceKey, auto bool) (topologyRecovery *TopologyRecovery, promotedMasterCoordinates *inst.BinlogCoordinates, err error)
GracefulMasterTakeover will demote master of existing topology and promote its direct replica instead. It expects that replica to have no siblings. This function is graceful in that it will first lock down the master, then wait for the designated replica to catch up with last position. It will point old master at the newly promoted master at the correct coordinates.
func NewTopologyRecovery ¶
func NewTopologyRecovery(replicationAnalysis inst.ReplicationAnalysis) *TopologyRecovery
func ReadActiveClusterRecovery ¶
func ReadActiveClusterRecovery(clusterName string) ([]*TopologyRecovery, error)
ReadActiveRecoveries reads active recovery entry/audit entries from topology_recovery
func ReadActiveRecoveries ¶
func ReadActiveRecoveries() ([]*TopologyRecovery, error)
ReadActiveRecoveries reads active recovery entry/audit entries from topology_recovery
func ReadCompletedRecoveries ¶
func ReadCompletedRecoveries(page int) ([]*TopologyRecovery, error)
ReadCompletedRecoveries reads completed recovery entry/audit entries from topology_recovery
func ReadFailureDetection ¶
func ReadFailureDetection(detectionId int64) ([]*TopologyRecovery, error)
ReadFailureDetection
func ReadInActivePeriodClusterRecovery ¶
func ReadInActivePeriodClusterRecovery(clusterName string) ([]*TopologyRecovery, error)
ReadInActivePeriodClusterRecovery reads recoveries (possibly complete!) that are in active period. (may be used to block further recoveries on this cluster)
func ReadInActivePeriodSuccessorInstanceRecovery ¶
func ReadInActivePeriodSuccessorInstanceRecovery(instanceKey *inst.InstanceKey) ([]*TopologyRecovery, error)
ReadInActivePeriodSuccessorInstanceRecovery reads completed recoveries for a given instance, where said instance was promoted as result, still in active period (may be used to block further recoveries should this instance die)
func ReadRecentFailureDetections ¶
func ReadRecentFailureDetections(clusterAlias string, page int) ([]*TopologyRecovery, error)
ReadRecentFailureDetections
func ReadRecentRecoveries ¶
func ReadRecentRecoveries(clusterName string, clusterAlias string, unacknowledgedOnly bool, page int) ([]*TopologyRecovery, error)
ReadCRecoveries reads latest recovery entries from topology_recovery
func ReadRecentlyActiveClusterRecovery ¶
func ReadRecentlyActiveClusterRecovery(clusterName string) ([]*TopologyRecovery, error)
ReadRecentlyActiveClusterRecovery reads recently completed entries for a given cluster
func ReadRecentlyActiveInstanceRecovery ¶
func ReadRecentlyActiveInstanceRecovery(instanceKey *inst.InstanceKey) ([]*TopologyRecovery, error)
ReadRecentlyActiveInstanceRecovery reads recently completed entries for a given instance
func ReadRecovery ¶
func ReadRecovery(recoveryId int64) ([]*TopologyRecovery, error)
ReadRecovery reads completed recovery entry/audit entries from topology_recovery
func ReadRecoveryByUID ¶
func ReadRecoveryByUID(recoveryUID string) ([]*TopologyRecovery, error)
ReadRecoveryByUID reads completed recovery entry/audit entries from topology_recovery
func (*TopologyRecovery) AddError ¶
func (this *TopologyRecovery) AddError(err error) error
func (*TopologyRecovery) AddErrors ¶
func (this *TopologyRecovery) AddErrors(errs []error)
type TopologyRecoveryStep ¶
func NewTopologyRecoveryStep ¶
func NewTopologyRecoveryStep(uid string, message string) *TopologyRecoveryStep
func ReadTopologyRecoverySteps ¶
func ReadTopologyRecoverySteps(recoveryUID string) ([]TopologyRecoveryStep, error)
ReadTopologyRecoverySteps reads recovery steps for a given recovery