app

package
v0.0.0-...-4486c9f Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CauseManual means switchover was issued via command line
	CauseManual = "manual"
	// CauseWorker means switchover was initiated via MDB worker (set directly to dcs)
	CauseWorker = "worker"
	// CauseAuto  means failover was started automatically by failure detection process
	CauseAuto = "auto"
)

Variables

View Source
var (
	ErrNoMaster      = errors.New("no alive master found")
	ErrManyMasters   = errors.New("more than one master found")
	ErrNoActiveNodes = errors.New("no active nodes found")
)

Functions

func ResetSlaveAlgorithm

func ResetSlaveAlgorithm(app *App, node *mysql.Node, master string, channel string) error

func StartSlaveAlgorithm

func StartSlaveAlgorithm(app *App, node *mysql.Node, _ string, channel string) error

Types

type App

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

App is main application structure

func NewApp

func NewApp(configFile, logLevel string, interactive bool) (*App, error)

NewApp returns new App. Suddenly.

func (*App) CheckAsyncSwitchAllowed

func (app *App) CheckAsyncSwitchAllowed(node *mysql.Node, switchover *Switchover) bool

func (*App) ClearRecovery

func (app *App) ClearRecovery(host string) error

func (*App) CliAbort

func (app *App) CliAbort() int

CliAbort cleans switchover node from DCS

func (*App) CliDisableMaintenance

func (app *App) CliDisableMaintenance(waitTimeout time.Duration) int

CliDisableMaintenance disables maintenance mode

func (*App) CliEnableMaintenance

func (app *App) CliEnableMaintenance(waitTimeout time.Duration) int

CliEnableMaintenance enables maintenance mode

func (*App) CliGetMaintenance

func (app *App) CliGetMaintenance() int

CliGetMaintenance prints on/off depending on current maintenance status

func (*App) CliHostAdd

func (app *App) CliHostAdd(host string, streamFrom *string, priority *int64, dryRun bool, skipMySQLCheck bool) int

CliHostAdd add hosts to the list of managed HA/cascade hosts

func (*App) CliHostList

func (app *App) CliHostList() int

CliHostList prints list of managed HA/cascade hosts

func (*App) CliHostRemove

func (app *App) CliHostRemove(host string) int

CliHostRemove removes hosts from the list of managed HA/cascade hosts

func (*App) CliInfo

func (app *App) CliInfo(short bool) int

CliInfo is CLI command printing information from DCS to the stdout

func (*App) CliState

func (app *App) CliState(short bool) int

CliState print state of the cluster to the stdout

func (*App) CliSwitch

func (app *App) CliSwitch(switchFrom, switchTo string, waitTimeout time.Duration) int

CliSwitch performs manual switch-over of the master node nolint: gocyclo, funlen

func (*App) FailSwitchover

func (app *App) FailSwitchover(switchover *Switchover, err error) error

Fail current switchover, it will be repeated next cycle

func (*App) FinishSwitchover

func (app *App) FinishSwitchover(switchover *Switchover, switchErr error) error

FinishSwitchover finish current switchover and write the result

func (*App) GetActiveNodes

func (app *App) GetActiveNodes() ([]string, error)

GetActiveNodes returns master + alive running replicas

func (*App) GetClusterCascadeFqdnsFromDcs

func (app *App) GetClusterCascadeFqdnsFromDcs() ([]string, error)

func (*App) GetHostsOnRecovery

func (app *App) GetHostsOnRecovery() ([]string, error)

func (*App) GetLastShutdownNodeTime

func (app *App) GetLastShutdownNodeTime() (time.Time, error)

func (*App) GetLastSwitchover

func (app *App) GetLastSwitchover() Switchover

func (*App) GetMaintenance

func (app *App) GetMaintenance() (*Maintenance, error)

func (*App) GetMasterHostFromDcs

func (app *App) GetMasterHostFromDcs() (string, error)

func (*App) GetReplMonTS

func (app *App) GetReplMonTS() (string, error)

func (*App) GetResetupStatus

func (app *App) GetResetupStatus(host string) (mysql.ResetupStatus, error)

func (*App) IsRecoveryNeeded

func (app *App) IsRecoveryNeeded(host string) bool

func (*App) IssueFailover

func (app *App) IssueFailover(master string) error

func (*App) MarkReplicationRunning

func (app *App) MarkReplicationRunning(node *mysql.Node, channel string)

func (*App) Run

func (app *App) Run() int

Run enters the main application loop When Run exits mysync process is over

func (*App) SetMasterHost

func (app *App) SetMasterHost(master string) (string, error)

func (*App) SetRecovery

func (app *App) SetRecovery(host string) error

func (*App) SetReplMonTS

func (app *App) SetReplMonTS(ts string) error

func (*App) SetResetupStatus

func (app *App) SetResetupStatus()

func (*App) StartSwitchover

func (app *App) StartSwitchover(switchover *Switchover) error

func (*App) TryRepairReplication

func (app *App) TryRepairReplication(node *mysql.Node, master string, channel string)

func (*App) UpdateLastShutdownNodeTime

func (app *App) UpdateLastShutdownNodeTime() error

type DaemonState

type DaemonState struct {
	StartTime     time.Time `json:"start_time"`
	RecoveryTime  time.Time `json:"recovery_time"`
	CrashRecovery bool      `json:"crash_recovery"`
}

type DiskState

type DiskState struct {
	Used  uint64
	Total uint64
}

DiskState contains information about disk space on the node

func (DiskState) Usage

func (ds DiskState) Usage() float64

type Maintenance

type Maintenance struct {
	InitiatedBy  string    `json:"initiated_by"`
	InitiatedAt  time.Time `json:"initiated_at"`
	MySyncPaused bool      `json:"mysync_paused"`
	ShouldLeave  bool      `json:"should_leave"`
}

Maintenance struct presence means that cluster under manual control

func (*Maintenance) String

func (m *Maintenance) String() string

type MasterState

type MasterState struct {
	ExecutedGtidSet string `json:"executed_gtid_set"`
}

MasterState contains master specific info

type NodeState

type NodeState struct {
	CheckBy              string         `json:"check_by"`
	CheckAt              time.Time      `json:"check_at"`
	PingOk               bool           `json:"ping_ok"`
	PingDubious          bool           `json:"ping_dubious"`
	IsMaster             bool           `json:"is_master"`
	IsReadOnly           bool           `json:"is_readonly"`
	IsSuperReadOnly      bool           `json:"is_super_readonly"`
	IsOffline            bool           `json:"is_offline"`
	IsCascade            bool           `json:"is_cascade"`
	IsFileSystemReadonly bool           `json:"is_file_system_readonly"`
	Error                string         `json:"error"`
	DiskState            *DiskState     `json:"disk_state"`
	DaemonState          *DaemonState   `json:"daemon_state"`
	MasterState          *MasterState   `json:"master_state"`
	SlaveState           *SlaveState    `json:"slave_state"`
	SemiSyncState        *SemiSyncState `json:"semi_sync_state"`

	ShowOnlyGTIDDiff bool
}

NodeState contains status check performed by some mysync process

func (*NodeState) CalcGTIDDiffWithMaster

func (ns *NodeState) CalcGTIDDiffWithMaster() (string, error)

func (*NodeState) IsReplicationPermanentlyBroken

func (ns *NodeState) IsReplicationPermanentlyBroken() (bool, int)

func (*NodeState) String

func (ns *NodeState) String() string

type RepairReplicationAlgorithm

type RepairReplicationAlgorithm func(app *App, node *mysql.Node, master string, channel string) error

type ReplicationRepairAlgorithmType

type ReplicationRepairAlgorithmType int
const (
	StartSlave ReplicationRepairAlgorithmType = iota
	ResetSlave
)

type ReplicationRepairState

type ReplicationRepairState struct {
	LastAttempt      time.Time
	History          map[ReplicationRepairAlgorithmType]int
	LastGTIDExecuted string
}

type SemiSyncState

type SemiSyncState struct {
	MasterEnabled  bool `json:"master_enabled"`
	SlaveEnabled   bool `json:"slave_enabled"`
	WaitSlaveCount int  `json:"wait_slave_count"`
}

SemiSyncState contains semi sync host settings

type SlaveState

type SlaveState struct {
	MasterHost       string   `json:"master_host"`
	RetrievedGtidSet string   `json:"retrieved_gtid_get"`
	ExecutedGtidSet  string   `json:"executed_gtid_set"`
	ReplicationLag   *float64 `json:"replication_lag"`
	ReplicationState string   `json:"replication_state"`
	MasterLogFile    string   `json:"master_log_file"`
	MasterLogPos     int64    `json:"master_log_pos"`
	LastIOErrno      int      `json:"last_io_errno"`
	LastSQLErrno     int      `json:"last_sql_errno"`
}

SlaveState contains slave specific info. Master always has this state empty

func (*SlaveState) FromReplicaStatus

func (ns *SlaveState) FromReplicaStatus(replStatus mysql.ReplicaStatus)

type Switchover

type Switchover struct {
	From        string            `json:"from"`
	To          string            `json:"to"`
	Cause       string            `json:"cause"`
	InitiatedBy string            `json:"initiated_by"`
	InitiatedAt time.Time         `json:"initiated_at"`
	StartedBy   string            `json:"started_by"`
	StartedAt   time.Time         `json:"started_at"`
	Result      *SwitchoverResult `json:"result"`
	RunCount    int               `json:"run_count,omitempty"`
}

Switchover contains info about currently running or scheduled switchover/failover process

func (*Switchover) String

func (sw *Switchover) String() string

type SwitchoverResult

type SwitchoverResult struct {
	Ok         bool      `json:"ok"`
	Error      string    `json:"error"`
	FinishedAt time.Time `json:"finished_at"`
}

SwitchoverResult contains results of finished/failed switchover

Jump to

Keyboard shortcuts

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