logic

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CheckAndRecoverGenericProblemRecoveryName        string = "CheckAndRecoverGenericProblem"
	RecoverDeadPrimaryRecoveryName                   string = "RecoverDeadPrimary"
	RecoverPrimaryTabletDeletedRecoveryName          string = "RecoverPrimaryTabletDeleted"
	RecoverPrimaryHasPrimaryRecoveryName             string = "RecoverPrimaryHasPrimary"
	CheckAndRecoverLockedSemiSyncPrimaryRecoveryName string = "CheckAndRecoverLockedSemiSyncPrimary"
	ElectNewPrimaryRecoveryName                      string = "ElectNewPrimary"
	FixPrimaryRecoveryName                           string = "FixPrimary"
	FixReplicaRecoveryName                           string = "FixReplica"
	RecoverErrantGTIDDetectedName                    string = "RecoverErrantGTIDDetected"
)
View Source
const (
	DiscoveryMetricsName = "DISCOVERY_METRICS"
)
View Source
const TopologyRecoveriesTemplate = `` /* 576-byte string literal not displayed */

TopologyRecoveriesTemplate is the HTML to use to display the topology recovery steps list object

Variables

View Source
var (

	// ErrNoPrimaryTablet is a fixed error message.
	ErrNoPrimaryTablet = errors.New("no primary tablet found")
)

Functions

func AcknowledgeCrashedRecoveries

func AcknowledgeCrashedRecoveries() (countAcknowledgedEntries int64, err error)

AcknowledgeCrashedRecoveries marks recoveries whose processing nodes has crashed as acknowledged.

func AcknowledgeInstanceCompletedRecoveries

func AcknowledgeInstanceCompletedRecoveries(tabletAlias string, owner string, comment string) (countAcknowledgedEntries int64, err error)

AcknowledgeInstanceCompletedRecoveries marks active and COMPLETED recoveries for given instance as acknowledged. 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()

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 ContinuousDiscovery

func ContinuousDiscovery()

ContinuousDiscovery starts an asynchronous 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(tabletAlias string, forceDiscovery bool)

DiscoverInstance will attempt to discover (poll) an instance (unless it is already up-to-date) and will also ensure that its primary 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 IsLeader

func IsLeader() bool

func IsLeaderOrActive

func IsLeaderOrActive() bool

func IsRecoveryDisabled

func IsRecoveryDisabled() (disabled bool, err error)

IsRecoveryDisabled returns true if Recoveries are disabled globally

func LockShard

func LockShard(ctx context.Context, tabletAlias string, lockAction string) (context.Context, func(*error), error)

LockShard locks the keyspace-shard preventing others from performing conflicting actions.

func OpenTabletDiscovery

func OpenTabletDiscovery() <-chan time.Time

OpenTabletDiscovery opens the vitess topo if enables and returns a ticker channel for polling.

func RefreshAllKeyspacesAndShards added in v0.18.0

func RefreshAllKeyspacesAndShards()

RefreshAllKeyspacesAndShards reloads the keyspace and shard information for the keyspaces that vtorc is concerned with.

func RefreshKeyspaceAndShard added in v0.18.0

func RefreshKeyspaceAndShard(keyspaceName string, shardName string) error

RefreshKeyspaceAndShard refreshes the keyspace record and shard record for the given keyspace and shard.

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 RegisterFlags

func RegisterFlags(fs *pflag.FlagSet)

RegisterFlags registers the flags required by VTOrc

Types

type RecoveryType

type RecoveryType string

type TopologyRecovery

type TopologyRecovery struct {
	ID                     int64
	UID                    string
	AnalysisEntry          inst.ReplicationAnalysis
	SuccessorHostname      string
	SuccessorPort          int
	SuccessorAlias         string
	IsActive               bool
	IsSuccessful           bool
	AllErrors              []string
	RecoveryStartTimestamp string
	RecoveryEndTimestamp   string
	ProcessingNodeHostname string
	ProcessingNodeToken    string
	Acknowledged           bool
	AcknowledgedAt         string
	AcknowledgedBy         string
	AcknowledgedComment    string
	LastDetectionID        int64
	RelatedRecoveryID      int64
	Type                   RecoveryType
}

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 NewTopologyRecovery

func NewTopologyRecovery(replicationAnalysis inst.ReplicationAnalysis) *TopologyRecovery

func ReadInActivePeriodClusterRecovery

func ReadInActivePeriodClusterRecovery(keyspace string, shard, analysis string) ([]*TopologyRecovery, error)

ReadInActivePeriodClusterRecovery reads recoveries (possibly complete!) that are in active period for the analysis. (may be used to block further recoveries of the same analysis on this cluster)

func ReadInActivePeriodSuccessorInstanceRecovery

func ReadInActivePeriodSuccessorInstanceRecovery(tabletAlias string) ([]*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 ReadRecentRecoveries

func ReadRecentRecoveries(unacknowledgedOnly bool, page int) ([]*TopologyRecovery, error)

ReadRecentRecoveries reads latest recovery entries from topology_recovery

func (*TopologyRecovery) AddError

func (topologyRecovery *TopologyRecovery) AddError(err error) error

func (*TopologyRecovery) AddErrors

func (topologyRecovery *TopologyRecovery) AddErrors(errs []error)

type TopologyRecoveryStep

type TopologyRecoveryStep struct {
	ID          int64
	RecoveryUID string
	AuditAt     string
	Message     string
}

func NewTopologyRecoveryStep

func NewTopologyRecoveryStep(uid string, message string) *TopologyRecoveryStep

Jump to

Keyboard shortcuts

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