Documentation ¶
Index ¶
- Constants
- func ASCIITopology(instanceKey *InstanceKey, historyTimestampPattern string) (string, error)
- func ApplyClusterAlias(clusterInfo *ClusterInfo)
- func ApplyClusterDomain(clusterInfo *ClusterInfo)
- func ApplyPoolInstances(pool string, instancesList string) error
- func AuditOperation(auditType string, instanceKey *InstanceKey, message string) error
- func BeginBoundedMaintenance(instanceKey *InstanceKey, owner string, reason string, durationSeconds uint) (int64, error)
- func BeginDowntime(instanceKey *InstanceKey, owner string, reason string, durationSeconds uint) error
- func BeginMaintenance(instanceKey *InstanceKey, owner string, reason string) (int64, error)
- func DeleteInvalidHostnameResolves() error
- func DeregisterHostnameUnresolve(instanceKey *InstanceKey) error
- func EmptyCommitInstance(instanceKey *InstanceKey) error
- func EnableAuditSyslog() (err error)
- func EndDowntime(instanceKey *InstanceKey) error
- func EndMaintenance(maintenanceToken int64) error
- func EndMaintenanceByInstanceKey(instanceKey *InstanceKey) error
- func ExecDBWriteFunc(f func() error) error
- func ExecInstance(instanceKey *InstanceKey, query string, args ...interface{}) (sql.Result, error)
- func ExecInstanceNoPrepare(instanceKey *InstanceKey, query string, args ...interface{}) (sql.Result, error)
- func ExecuteOnTopology(f func())
- func ExpireAudit() error
- func ExpireCandidateInstances() error
- func ExpireClusterDomainName() error
- func ExpireDowntime() error
- func ExpireHostnameUnresolve() error
- func ExpireMaintenance() error
- func ExpireMasterPositionEquivalence() error
- func FlushNontrivialResolveCacheToDatabase() error
- func ForgetExpiredHostnameResolves() error
- func ForgetInstance(instanceKey *InstanceKey) error
- func ForgetLongUnseenInstances() error
- func ForgetUnseenInstancesDifferentlyResolved() error
- func GetCNAME(hostname string) (string, error)
- func GetCandidateSlave(masterKey *InstanceKey, forRematchPurposes bool) (*Instance, [](*Instance), [](*Instance), [](*Instance), error)
- func GetClusterByAlias(alias string) (string, error)
- func GetClusterHeuristicLag(clusterName string) (int64, error)
- func GetClusterName(instanceKey *InstanceKey) (clusterName string, err error)
- func GetMaintenanceOwner() string
- func HostnameResolveCache() (map[string]*cache.Item, error)
- func InjectUnseenMasters() error
- func InstanceIsMasterOf(allegedMaster, allegedSlave *Instance) bool
- func InstancesAreSiblings(instance0, instance1 *Instance) bool
- func LoadHostnameResolveCacheFromDatabase() error
- func MatchBelow(instanceKey, otherKey *InstanceKey, requireInstanceMaintenance bool) (*Instance, *BinlogCoordinates, error)
- func MatchUp(instanceKey *InstanceKey, requireInstanceMaintenance bool) (*Instance, *BinlogCoordinates, error)
- func MatchUpSlaves(masterKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
- func MoveSlavesGTID(masterKey *InstanceKey, belowKey *InstanceKey, pattern string) (movedSlaves [](*Instance), unmovedSlaves [](*Instance), err error, ...)
- func MoveUpSlaves(instanceKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
- func MultiMatchBelow(slaves [](*Instance), belowKey *InstanceKey, slavesAlreadyStopped bool, ...) ([](*Instance), *Instance, error, []error)
- func MultiMatchSlaves(masterKey *InstanceKey, belowKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
- func PopulateInstancesAgents(instances [](*Instance)) error
- func ReadClusterAliases() error
- func ReadClusterByAlias(alias string) (string, error)
- func ReadClusterDomainName(clusterName string) (string, error)
- func ReadClusterNameByMaster(instanceKey *InstanceKey, masterKey *InstanceKey) (clusterName string, replicationDepth uint, isCoMaster bool, err error)
- func ReadClusters() ([]string, error)
- func ReadCountMySQLSnapshots(hostnames []string) (map[string]int, error)
- func ReadResolvedHostname(hostname string) (string, error)
- func RefreshTopologyInstances(instances [](*Instance))
- func RegisterCandidateInstance(instanceKey *InstanceKey) error
- func RegisterHostnameUnresolve(instanceKey *InstanceKey, unresolvedHostname string) (err error)
- func RegroupSlaves(masterKey *InstanceKey, returnSlaveEvenOnFailureToRegroup bool, ...) (aheadSlaves [](*Instance), equalSlaves [](*Instance), ...)
- func RegroupSlavesBinlogServers(masterKey *InstanceKey, returnSlaveEvenOnFailureToRegroup bool) (repointedBinlogServers [](*Instance), promotedBinlogServer *Instance, ...)
- func RegroupSlavesGTID(masterKey *InstanceKey, returnSlaveEvenOnFailureToRegroup bool, ...) ([](*Instance), [](*Instance), *Instance, error)
- func RegroupSlavesPseudoGTID(masterKey *InstanceKey, returnSlaveEvenOnFailureToRegroup bool, ...) ([](*Instance), [](*Instance), [](*Instance), *Instance, error)
- func RegroupSlavesPseudoGTIDIncludingSubSlavesOfBinlogServers(masterKey *InstanceKey, returnSlaveEvenOnFailureToRegroup bool, ...) ([](*Instance), [](*Instance), [](*Instance), *Instance, error)
- func RelocateSlaves(instanceKey, otherKey *InstanceKey, pattern string) (slaves [](*Instance), other *Instance, err error, errs []error)
- func RematchSlave(instanceKey *InstanceKey, requireInstanceMaintenance bool) (*Instance, *BinlogCoordinates, error)
- func ResetHostnameResolveCache() error
- func ResolveHostname(hostname string) (string, error)
- func ResolveUnknownMasterHostnameResolves() error
- func ReviewUnseenInstances() error
- func ScanInstanceRow(instanceKey *InstanceKey, query string, dest ...interface{}) error
- func SetClusterAlias(clusterName string, alias string) error
- func SetMaintenanceOwner(owner string)
- func SnapshotTopologies() error
- func StartSlaves(slaves [](*Instance))
- func UpdateClusterAliases() error
- func UpdateInstanceLastAttemptedCheck(instanceKey *InstanceKey) error
- func UpdateInstanceLastChecked(instanceKey *InstanceKey) error
- func UpdateResolvedHostname(hostname string, resolvedHostname string) bool
- func WriteClusterAlias(clusterName string, alias string) error
- func WriteClusterDomainName(clusterName string, domainName string) error
- func WriteHostnameUnresolve(instanceKey *InstanceKey, unresolvedHostname string) error
- func WriteLongRunningProcesses(instanceKey *InstanceKey, processes []Process) error
- func WriteMasterPositionEquivalence(master1Key *InstanceKey, master1BinlogCoordinates *BinlogCoordinates, ...) error
- func WriteResolvedHostname(hostname string, resolvedHostname string) error
- type AnalysisCode
- type Audit
- type BinlogCoordinates
- func CorrelateBinlogCoordinates(instance *Instance, binlogCoordinates *BinlogCoordinates, ...) (*BinlogCoordinates, int, error)
- func FindLastPseudoGTIDEntry(instance *Instance, recordedInstanceRelayLogCoordinates BinlogCoordinates, ...) (*BinlogCoordinates, string, error)
- func GetEquivalentBinlogCoordinatesFor(instanceCoordinates *InstanceBinlogCoordinates, belowKey *InstanceKey) (*BinlogCoordinates, error)
- func GetNextBinlogCoordinatesToMatch(instance *Instance, instanceCoordinates BinlogCoordinates, ...) (*BinlogCoordinates, int, error)
- func ParseBinlogCoordinates(logFileLogPos string) (*BinlogCoordinates, error)
- func SearchEntryInBinlog(instanceKey *InstanceKey, binlog string, entryText string, ...) (BinlogCoordinates, bool, error)
- func SearchEntryInInstanceBinlogs(instance *Instance, entryText string, monotonicPseudoGTIDEntries bool) (*BinlogCoordinates, error)
- func (this *BinlogCoordinates) DetachedCoordinates() (isDetached bool, detachedLogFile string, detachedLogPos string)
- func (this *BinlogCoordinates) DisplayString() string
- func (this *BinlogCoordinates) Equals(other *BinlogCoordinates) bool
- func (this *BinlogCoordinates) FileNumber() (int, int)
- func (this *BinlogCoordinates) FileNumberDistance(other *BinlogCoordinates) int
- func (this *BinlogCoordinates) FileSmallerThan(other *BinlogCoordinates) bool
- func (this *BinlogCoordinates) NextFileCoordinates() (BinlogCoordinates, error)
- func (this *BinlogCoordinates) PreviousFileCoordinates() (BinlogCoordinates, error)
- func (this *BinlogCoordinates) PreviousFileCoordinatesBy(offset int) (BinlogCoordinates, error)
- func (this *BinlogCoordinates) SmallerThan(other *BinlogCoordinates) bool
- func (this BinlogCoordinates) String() string
- type BinlogEvent
- type BinlogEventCursor
- type BinlogType
- type ClusterInfo
- type ClusterPoolInstance
- type HostnameResolve
- type Instance
- func ChangeMasterTo(instanceKey *InstanceKey, masterKey *InstanceKey, ...) (*Instance, error)
- func DetachSlave(instanceKey *InstanceKey) (*Instance, error)
- func DetachSlaveOperation(instanceKey *InstanceKey) (*Instance, error)
- func DisableGTID(instanceKey *InstanceKey) (*Instance, error)
- func EnableGTID(instanceKey *InstanceKey) (*Instance, error)
- func EnslaveMaster(instanceKey *InstanceKey) (*Instance, error)
- func EnslaveSiblings(instanceKey *InstanceKey) (*Instance, int, error)
- func FindInstances(regexpPattern string) ([](*Instance), error)
- func FlushBinaryLogs(instanceKey *InstanceKey, count int) (*Instance, error)
- func FlushBinaryLogsTo(instanceKey *InstanceKey, logFile string) (*Instance, error)
- func GetCandidateSlaveOfBinlogServerTopology(masterKey *InstanceKey) (candidateSlave *Instance, err error)
- func GetClusterOSCSlaves(clusterName string) ([](*Instance), error)
- func GetInstanceMaster(instance *Instance) (*Instance, error)
- func KillQuery(instanceKey *InstanceKey, process int64) (*Instance, error)
- func MakeCoMaster(instanceKey *InstanceKey) (*Instance, error)
- func MakeLocalMaster(instanceKey *InstanceKey) (*Instance, error)
- func MakeMaster(instanceKey *InstanceKey) (*Instance, error)
- func MasterPosWait(instanceKey *InstanceKey, binlogCoordinates *BinlogCoordinates) (*Instance, error)
- func MoveBelow(instanceKey, siblingKey *InstanceKey) (*Instance, error)
- func MoveBelowGTID(instanceKey, otherKey *InstanceKey) (*Instance, error)
- func MoveEquivalent(instanceKey, otherKey *InstanceKey) (*Instance, error)
- func MoveUp(instanceKey *InstanceKey) (*Instance, error)
- func NewInstance() *Instance
- func PurgeBinaryLogsTo(instanceKey *InstanceKey, logFile string) (*Instance, error)
- func PurgeBinaryLogsToCurrent(instanceKey *InstanceKey) (*Instance, error)
- func ReadBinlogServerSlaveInstances(masterKey *InstanceKey) ([](*Instance), error)
- func ReadClusterCandidateInstances(clusterName string) ([](*Instance), error)
- func ReadClusterInstances(clusterName string) ([](*Instance), error)
- func ReadHistoryClusterInstances(clusterName string, historyTimestampPattern string) ([](*Instance), error)
- func ReadInstance(instanceKey *InstanceKey) (*Instance, bool, error)
- func ReadProblemInstances(clusterName string) ([](*Instance), error)
- func ReadSlaveInstances(masterKey *InstanceKey) ([](*Instance), error)
- func ReadSlaveInstancesIncludingBinlogServerSubSlaves(masterKey *InstanceKey) ([](*Instance), error)
- func ReadTopologyInstance(instanceKey *InstanceKey) (*Instance, error)
- func ReadUnseenInstances() ([](*Instance), error)
- func ReattachSlave(instanceKey *InstanceKey) (*Instance, error)
- func ReattachSlaveOperation(instanceKey *InstanceKey) (*Instance, error)
- func RefreshInstanceSlaveHosts(instanceKey *InstanceKey) (*Instance, error)
- func RefreshTopologyInstance(instanceKey *InstanceKey) (*Instance, error)
- func RelocateBelow(instanceKey, otherKey *InstanceKey) (*Instance, error)
- func RemoveBinlogServerInstances(instances [](*Instance)) [](*Instance)
- func RemoveInstance(instances [](*Instance), instanceKey *InstanceKey) [](*Instance)
- func RemoveNilInstances(instances [](*Instance)) [](*Instance)
- func Repoint(instanceKey *InstanceKey, masterKey *InstanceKey, gitdHint OperationGTIDHint) (*Instance, error)
- func RepointSlaves(instanceKey *InstanceKey, pattern string) ([](*Instance), error, []error)
- func RepointSlavesTo(instanceKey *InstanceKey, pattern string, belowKey *InstanceKey) ([](*Instance), error, []error)
- func RepointTo(slaves [](*Instance), belowKey *InstanceKey) ([](*Instance), error, []error)
- func ResetSlave(instanceKey *InstanceKey) (*Instance, error)
- func ResetSlaveOperation(instanceKey *InstanceKey) (*Instance, error)
- func RestartSlave(instanceKey *InstanceKey) (instance *Instance, err error)
- func SearchInstances(searchString string) ([](*Instance), error)
- func SetReadOnly(instanceKey *InstanceKey, readOnly bool) (*Instance, error)
- func SkipQuery(instanceKey *InstanceKey) (*Instance, error)
- func SkipToNextBinaryLog(instanceKey *InstanceKey) (*Instance, error)
- func StartSlave(instanceKey *InstanceKey) (*Instance, error)
- func StartSlaveUntilMasterCoordinates(instanceKey *InstanceKey, masterCoordinates *BinlogCoordinates) (*Instance, error)
- func StopSlave(instanceKey *InstanceKey) (*Instance, error)
- func StopSlaveNicely(instanceKey *InstanceKey, timeout time.Duration) (*Instance, error)
- func StopSlavesNicely(slaves [](*Instance), timeout time.Duration) [](*Instance)
- func (this *Instance) AddSlaveKey(slaveKey *InstanceKey)
- func (this *Instance) CanMove() (bool, error)
- func (this *Instance) CanMoveAsCoMaster() (bool, error)
- func (this *Instance) CanMoveViaMatch() (bool, error)
- func (this *Instance) CanReplicateFrom(other *Instance) (bool, error)
- func (this *Instance) Equals(other *Instance) bool
- func (this *Instance) GetNextBinaryLog(binlogCoordinates BinlogCoordinates) (BinlogCoordinates, error)
- func (this *Instance) HasReasonableMaintenanceReplicationLag() bool
- func (this *Instance) HumanReadableDescription() string
- func (this *Instance) IsBinlogServer() bool
- func (this *Instance) IsMariaDB() bool
- func (this *Instance) IsMasterOf(slave *Instance) bool
- func (this *Instance) IsMySQL51() bool
- func (this *Instance) IsMySQL55() bool
- func (this *Instance) IsMySQL56() bool
- func (this *Instance) IsMySQL57() bool
- func (this *Instance) IsMySQL58() bool
- func (this *Instance) IsOracleMySQL() bool
- func (this *Instance) IsSlave() bool
- func (this *Instance) IsSlaveOf(master *Instance) bool
- func (this *Instance) IsSmallerMajorVersion(other *Instance) bool
- func (this *Instance) IsSmallerMajorVersionByString(otherVersion string) bool
- func (this *Instance) MajorVersion() []string
- func (this *Instance) NextGTID() (string, error)
- func (this *Instance) SQLThreadUpToDate() bool
- func (this *Instance) SlaveRunning() bool
- func (this *Instance) StatusString() string
- func (this *Instance) UsingGTID() bool
- type InstanceBinlogCoordinates
- type InstanceKey
- func NewInstanceKeyFromStrings(hostname string, port string) (*InstanceKey, error)
- func NewRawInstanceKey(hostPort string) (*InstanceKey, error)
- func ParseInstanceKey(hostPort string) (*InstanceKey, error)
- func ParseInstanceKeyLoose(hostPort string) (*InstanceKey, error)
- func ReadMaintenanceInstanceKey(maintenanceToken int64) (*InstanceKey, error)
- func ReadOutdatedInstanceKeys() ([]InstanceKey, error)
- func UnresolveHostname(instanceKey *InstanceKey) (InstanceKey, bool, error)
- type InstanceKeyMap
- func (this *InstanceKeyMap) AddInstances(instances [](*Instance))
- func (this *InstanceKeyMap) AddKey(key InstanceKey)
- func (this *InstanceKeyMap) AddKeys(keys []InstanceKey)
- func (this *InstanceKeyMap) GetInstanceKeys() []InstanceKey
- func (this *InstanceKeyMap) MarshalJSON() ([]byte, error)
- func (this *InstanceKeyMap) ReadCommaDelimitedList(list string) error
- func (this *InstanceKeyMap) ReadJson(jsonString string) error
- func (this *InstanceKeyMap) ToCommaDelimitedList() string
- func (this *InstanceKeyMap) ToJSON() (string, error)
- func (this *InstanceKeyMap) ToJSONString() string
- type InstancesByCountSlaveHosts
- type InstancesByExecBinlogCoordinates
- type Maintenance
- type OperationGTIDHint
- type PoolInstancesMap
- type PostponedFunctionsContainer
- type Process
- type ReplicationAnalysis
Constants ¶
const ( NoProblem AnalysisCode = "NoProblem" DeadMasterWithoutSlaves = "DeadMasterWithoutSlaves" DeadMaster = "DeadMaster" DeadMasterAndSlaves = "DeadMasterAndSlaves" DeadMasterAndSomeSlaves = "DeadMasterAndSomeSlaves" UnreachableMaster = "UnreachableMaster" MasterSingleSlaveNotReplicating = "MasterSingleSlaveNotReplicating" MasterSingleSlaveDead = "MasterSingleSlaveDead" AllMasterSlavesNotReplicating = "AllMasterSlavesNotReplicating" AllMasterSlavesNotReplicatingOrDead = "AllMasterSlavesNotReplicatingOrDead" MasterWithoutSlaves = "MasterWithoutSlaves" DeadCoMaster = "DeadCoMaster" DeadCoMasterAndSomeSlaves = "DeadCoMasterAndSomeSlaves" UnreachableCoMaster = "UnreachableCoMaster" AllCoMasterSlavesNotReplicating = "AllCoMasterSlavesNotReplicating" DeadIntermediateMaster = "DeadIntermediateMaster" DeadIntermediateMasterWithSingleSlave = "DeadIntermediateMasterWithSingleSlave" DeadIntermediateMasterWithSingleSlaveFailingToConnect = "DeadIntermediateMasterWithSingleSlaveFailingToConnect" DeadIntermediateMasterAndSomeSlaves = "DeadIntermediateMasterAndSomeSlaves" UnreachableIntermediateMaster = "UnreachableIntermediateMaster" AllIntermediateMasterSlavesFailingToConnectOrDead = "AllIntermediateMasterSlavesFailingToConnectOrDead" AllIntermediateMasterSlavesNotReplicating = "AllIntermediateMasterSlavesNotReplicating" FirstTierSlaveFailingToConnectToMaster = "FirstTierSlaveFailingToConnectToMaster" BinlogServerFailingToConnectToMaster = "BinlogServerFailingToConnectToMaster" )
const ( GTIDHintDeny OperationGTIDHint = "NoGTID" GTIDHintNeutral = "GTIDHintNeutral" GTIDHintForce = "GTIDHintForce" )
Variables ¶
This section is empty.
Functions ¶
func ASCIITopology ¶
func ASCIITopology(instanceKey *InstanceKey, historyTimestampPattern string) (string, error)
ASCIITopology returns a string representation of the topology of given instance.
func ApplyClusterAlias ¶
func ApplyClusterAlias(clusterInfo *ClusterInfo)
func ApplyClusterDomain ¶ added in v1.4.283
func ApplyClusterDomain(clusterInfo *ClusterInfo)
func ApplyPoolInstances ¶
func AuditOperation ¶
func AuditOperation(auditType string, instanceKey *InstanceKey, message string) error
AuditOperation creates and writes a new audit entry by given params
func BeginBoundedMaintenance ¶
func BeginBoundedMaintenance(instanceKey *InstanceKey, owner string, reason string, durationSeconds uint) (int64, error)
BeginBoundedMaintenance will make new maintenance entry for given instanceKey.
func BeginDowntime ¶
func BeginDowntime(instanceKey *InstanceKey, owner string, reason string, durationSeconds uint) error
BeginDowntime will make mark an instance as downtimed (or override existing downtime period)
func BeginMaintenance ¶
func BeginMaintenance(instanceKey *InstanceKey, owner string, reason string) (int64, error)
BeginMaintenance will make new maintenance entry for given instanceKey. Maintenance time is unbounded
func DeleteInvalidHostnameResolves ¶
func DeleteInvalidHostnameResolves() error
DeleteInvalidHostnameResolves removes invalid resolves. At this time these are: - infinite loop resolves (A->B and B->A), remove earlier mapping
func DeregisterHostnameUnresolve ¶
func DeregisterHostnameUnresolve(instanceKey *InstanceKey) error
DeregisterHostnameUnresolve removes an unresovle entry
func EmptyCommitInstance ¶ added in v1.4.328
func EmptyCommitInstance(instanceKey *InstanceKey) error
EmptyCommitInstance issues an empty COMMIT on a given instance
func EnableAuditSyslog ¶ added in v1.4.454
func EnableAuditSyslog() (err error)
EnableSyslogWriter enables, if possible, writes to syslog. These will execute _in addition_ to normal logging
func EndDowntime ¶
func EndDowntime(instanceKey *InstanceKey) error
EndDowntime will remove downtime flag from an instance
func EndMaintenance ¶
EndMaintenance will terminate an active maintenance via maintenanceToken
func EndMaintenanceByInstanceKey ¶
func EndMaintenanceByInstanceKey(instanceKey *InstanceKey) error
EndMaintenanceByInstanceKey will terminate an active maintenance using given instanceKey as hint
func ExecDBWriteFunc ¶
ExecDBWriteFunc chooses how to execute a write onto the database: whether synchronuously or not
func ExecInstance ¶
func ExecInstance(instanceKey *InstanceKey, query string, args ...interface{}) (sql.Result, error)
ExecInstance executes a given query on the given MySQL topology instance
func ExecInstanceNoPrepare ¶
func ExecInstanceNoPrepare(instanceKey *InstanceKey, query string, args ...interface{}) (sql.Result, error)
ExecInstanceNoPrepare executes a given query on the given MySQL topology instance, without using prepared statements
func ExecuteOnTopology ¶
func ExecuteOnTopology(f func())
ExecuteOnTopology will execute given function while maintaining concurrency limit on topology servers. It is safe in the sense that we will not leak tokens.
func ExpireAudit ¶ added in v1.4.291
func ExpireAudit() error
ExpireAudit removes old rows from the audit table
func ExpireCandidateInstances ¶
func ExpireCandidateInstances() error
RegisterCandidateInstance markes a given instance as suggested for successoring a master in the event of failover.
func ExpireClusterDomainName ¶ added in v1.4.283
func ExpireClusterDomainName() error
ExpireClusterDomainName expires cluster_domain_name entries that haven't been updated recently.
func ExpireDowntime ¶
func ExpireDowntime() error
ExpireDowntime will remove the maintenance flag on old downtimes
func ExpireHostnameUnresolve ¶
func ExpireHostnameUnresolve() error
ExpireHostnameUnresolve expires hostname_unresolve entries that haven't been updated recently.
func ExpireMaintenance ¶
func ExpireMaintenance() error
ExpireMaintenance will remove the maintenance flag on old maintenances and on bounded maintenances
func ExpireMasterPositionEquivalence ¶ added in v1.4.328
func ExpireMasterPositionEquivalence() error
ExpireMasterPositionEquivalence expires old master_position_equivalence
func FlushNontrivialResolveCacheToDatabase ¶ added in v1.4.421
func FlushNontrivialResolveCacheToDatabase() error
func ForgetExpiredHostnameResolves ¶
func ForgetExpiredHostnameResolves() error
ForgetExpiredHostnameResolves
func ForgetInstance ¶
func ForgetInstance(instanceKey *InstanceKey) error
ForgetInstance removes an instance entry from the orchestrator backed database. It may be auto-rediscovered through topology or requested for discovery by multiple means.
func ForgetLongUnseenInstances ¶
func ForgetLongUnseenInstances() error
ForgetLongUnseenInstances will remove entries of all instacnes that have long since been last seen.
func ForgetUnseenInstancesDifferentlyResolved ¶
func ForgetUnseenInstancesDifferentlyResolved() error
ForgetUnseenInstancesDifferentlyResolved will purge instances which are invalid, and whose hostname appears on the hostname_resolved table; this means some time in the past their hostname was unresovled, and now resovled to a different value; the old hostname is never accessed anymore and the old entry should be removed.
func GetCandidateSlave ¶
func GetCandidateSlave(masterKey *InstanceKey, forRematchPurposes bool) (*Instance, [](*Instance), [](*Instance), [](*Instance), error)
GetCandidateSlave chooses the best slave to promote given a (possibly dead) master
func GetClusterByAlias ¶
GetClusterByAlias returns the cluster name associated with given alias. The function returns with error when: - No cluster is associated with the alias - More than one cluster is associated with the alias
func GetClusterHeuristicLag ¶
GetClusterHeuristicLag returns a heuristic lag for a cluster, based on its OSC slaves
func GetClusterName ¶ added in v1.4.460
func GetClusterName(instanceKey *InstanceKey) (clusterName string, err error)
func GetMaintenanceOwner ¶
func GetMaintenanceOwner() string
func HostnameResolveCache ¶
func InjectUnseenMasters ¶
func InjectUnseenMasters() error
InjectUnseenMasters will review masters of instances that are known to be replicating, yet which are not listed in database_instance. Since their slaves are listed as replicating, we can assume that such masters actually do exist: we shall therefore inject them with minimal details into the database_instance table.
func InstanceIsMasterOf ¶
InstanceIsMasterOf checks whether an instance is the master of another
func InstancesAreSiblings ¶
InstancesAreSiblings checks whether both instances are replicating from same master
func LoadHostnameResolveCacheFromDatabase ¶
func LoadHostnameResolveCacheFromDatabase() error
func MatchBelow ¶
func MatchBelow(instanceKey, otherKey *InstanceKey, requireInstanceMaintenance bool) (*Instance, *BinlogCoordinates, error)
MatchBelow will attempt moving instance indicated by instanceKey below its the one indicated by otherKey. The refactoring is based on matching binlog entries, not on "classic" positions comparisons. The "other instance" could be the sibling of the moving instance any of its ancestors. It may actually be a cousin of some sort (though unlikely). The only important thing is that the "other instance" is more advanced in replication than given instance.
func MatchUp ¶
func MatchUp(instanceKey *InstanceKey, requireInstanceMaintenance bool) (*Instance, *BinlogCoordinates, error)
MatchUp will move a slave up the replication chain, so that it becomes sibling of its master, via Pseudo-GTID
func MatchUpSlaves ¶
func MatchUpSlaves(masterKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
MatchUpSlaves will move all slaves of given master up the replication chain, so that they become siblings of their master. This should be called when the local master dies, and all its slaves are to be resurrected via Pseudo-GTID
func MoveSlavesGTID ¶ added in v1.4.338
func MoveSlavesGTID(masterKey *InstanceKey, belowKey *InstanceKey, pattern string) (movedSlaves [](*Instance), unmovedSlaves [](*Instance), err error, errs []error)
MoveSlavesGTID will (attempt to) move all slaves of given master below given instance.
func MoveUpSlaves ¶
func MoveUpSlaves(instanceKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
MoveUpSlaves will attempt moving up all slaves of a given instance, at the same time. Clock-time, this is fater than moving one at a time. However this means all slaves of the given instance, and the instance itself, will all stop replicating together.
func MultiMatchBelow ¶
func MultiMatchBelow(slaves [](*Instance), belowKey *InstanceKey, slavesAlreadyStopped bool, postponedFunctionsContainer *PostponedFunctionsContainer) ([](*Instance), *Instance, error, []error)
MultiMatchBelow will efficiently match multiple slaves below a given instance. It is assumed that all given slaves are siblings
func MultiMatchSlaves ¶
func MultiMatchSlaves(masterKey *InstanceKey, belowKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
MultiMatchSlaves will match (via pseudo-gtid) all slaves of given master below given instance.
func PopulateInstancesAgents ¶
PopulateInstancesAgents will fill in extra data acquired from agents for given instances At current this is the number of snapshots. This isn't too pretty; it's a push-into-instance-data-that-belongs-to-agent thing. Originally the need was to visually present the number of snapshots per host on the web/cluster page, which indeed proves to be useful in our experience.
func ReadClusterAliases ¶
func ReadClusterAliases() error
ReadClusterAliases reads the entrie cluster name aliases mapping
func ReadClusterByAlias ¶
ReadClusterAliases reads the entrie cluster name aliases mapping
func ReadClusterDomainName ¶ added in v1.4.283
ReadClusterDomainName reads the domain name associated with a cluster, if any
func ReadClusterNameByMaster ¶
func ReadClusterNameByMaster(instanceKey *InstanceKey, masterKey *InstanceKey) (clusterName string, replicationDepth uint, isCoMaster bool, err error)
ReadClusterNameByMaster will return the cluster name for a given instance by looking at its master and getting it from there. It is a non-recursive function and so-called-recursion is performed upon periodic reading of instances.
func ReadClusters ¶
ReadClusters reads names of all known clusters
func ReadCountMySQLSnapshots ¶
ReadCountMySQLSnapshots is a utility method to return registered number of snapshots for a given list of hosts
func ReadResolvedHostname ¶
ReadResolvedHostname returns the resolved hostname given a hostname, or empty if not exists
func RefreshTopologyInstances ¶
func RefreshTopologyInstances(instances [](*Instance))
RefreshTopologyInstances will do a blocking (though concurrent) refresh of all given instances
func RegisterCandidateInstance ¶
func RegisterCandidateInstance(instanceKey *InstanceKey) error
RegisterCandidateInstance markes a given instance as suggested for successoring a master in the event of failover.
func RegisterHostnameUnresolve ¶
func RegisterHostnameUnresolve(instanceKey *InstanceKey, unresolvedHostname string) (err error)
func RegroupSlaves ¶
func RegroupSlaves(masterKey *InstanceKey, returnSlaveEvenOnFailureToRegroup bool, onCandidateSlaveChosen func(*Instance), postponedFunctionsContainer *PostponedFunctionsContainer) ( aheadSlaves [](*Instance), equalSlaves [](*Instance), laterSlaves [](*Instance), instance *Instance, err error)
RegroupSlaves is a "smart" method of promoting one slave over the others ("promoting" it on top of its siblings) This method decides which strategy to use: GTID, Pseudo-GTID, Binlog Servers.
func RegroupSlavesBinlogServers ¶ added in v1.4.408
func RegroupSlavesBinlogServers(masterKey *InstanceKey, returnSlaveEvenOnFailureToRegroup bool) (repointedBinlogServers [](*Instance), promotedBinlogServer *Instance, err error)
RegroupSlavesBinlogServers works on a binlog-servers topology. It picks the most up-to-date BLS and repoints all other BLS below it
func RegroupSlavesGTID ¶ added in v1.4.408
func RegroupSlavesGTID(masterKey *InstanceKey, returnSlaveEvenOnFailureToRegroup bool, onCandidateSlaveChosen func(*Instance)) ([](*Instance), [](*Instance), *Instance, error)
RegroupSlavesGTID will choose a candidate slave of a given instance, and enslave its siblings using GTID
func RegroupSlavesPseudoGTID ¶ added in v1.4.470
func RegroupSlavesPseudoGTID(masterKey *InstanceKey, returnSlaveEvenOnFailureToRegroup bool, onCandidateSlaveChosen func(*Instance), postponedFunctionsContainer *PostponedFunctionsContainer) ([](*Instance), [](*Instance), [](*Instance), *Instance, error)
RegroupSlaves will choose a candidate slave of a given instance, and enslave its siblings using either simple CHANGE MASTER TO, where possible, or pseudo-gtid
func RegroupSlavesPseudoGTIDIncludingSubSlavesOfBinlogServers ¶ added in v1.4.470
func RegroupSlavesPseudoGTIDIncludingSubSlavesOfBinlogServers(masterKey *InstanceKey, returnSlaveEvenOnFailureToRegroup bool, onCandidateSlaveChosen func(*Instance), postponedFunctionsContainer *PostponedFunctionsContainer) ([](*Instance), [](*Instance), [](*Instance), *Instance, error)
RegroupSlavesIncludingSubSlavesOfBinlogServers works in a mixed standard/binlog-server topology. This kind of topology shouldn't really exist, but life is hard. To transition binlog servers into your topology you live sometimes with this hybrid solution.
func RelocateSlaves ¶ added in v1.4.304
func RelocateSlaves(instanceKey, otherKey *InstanceKey, pattern string) (slaves [](*Instance), other *Instance, err error, errs []error)
RelocateSlaves will attempt moving slaves of an instance indicated by instanceKey below another instance. Orchestrator will try and figure out the best way to relocate the servers. This could span normal binlog-position, pseudo-gtid, repointing, binlog servers...
func RematchSlave ¶
func RematchSlave(instanceKey *InstanceKey, requireInstanceMaintenance bool) (*Instance, *BinlogCoordinates, error)
RematchSlave will re-match a slave to its master, using pseudo-gtid
func ResetHostnameResolveCache ¶
func ResetHostnameResolveCache() error
func ResolveHostname ¶
Attempt to resolve a hostname. This may return a database cached hostname or otherwise it may resolve the hostname via CNAME
func ResolveUnknownMasterHostnameResolves ¶ added in v1.4.219
func ResolveUnknownMasterHostnameResolves() error
ResolveUnknownMasterHostnameResolves fixes missing hostname resolves based on hostname_resolve_history The use case is slaves replicating from some unknown-hostname which cannot be otherwise found. This could happen due to an expire unresolve together with clearing up of hostname cache.
func ReviewUnseenInstances ¶
func ReviewUnseenInstances() error
ReviewUnseenInstances reviews instances that have not been seen (suposedly dead) and updates some of their data
func ScanInstanceRow ¶
func ScanInstanceRow(instanceKey *InstanceKey, query string, dest ...interface{}) error
ScanInstanceRow executes a read-a-single-row query on a given MySQL topology instance
func SetClusterAlias ¶
SetClusterAlias will write (and override) a single cluster name mapping
func SetMaintenanceOwner ¶
func SetMaintenanceOwner(owner string)
func SnapshotTopologies ¶
func SnapshotTopologies() error
SnapshotTopologies records topology graph for all existing topologies
func StartSlaves ¶
func StartSlaves(slaves [](*Instance))
StartSlaves will do concurrent start-slave
func UpdateClusterAliases ¶ added in v1.4.408
func UpdateClusterAliases() error
func UpdateInstanceLastAttemptedCheck ¶
func UpdateInstanceLastAttemptedCheck(instanceKey *InstanceKey) error
UpdateInstanceLastAttemptedCheck updates the last_attempted_check timestamp in the orchestrator backed database for a given instance. This is used as a failsafe mechanism in case access to the instance gets hung (it happens), in which case the entire ReadTopology gets stuck (and no, connection timeout nor driver timeouts don't help. Don't look at me, the world is a harsh place to live in). And so we make sure to note down *before* we even attempt to access the instance; and this raises a red flag when we wish to access the instance again: if last_attempted_check is *newer* than last_checked, that's bad news and means we have a "hanging" issue.
func UpdateInstanceLastChecked ¶
func UpdateInstanceLastChecked(instanceKey *InstanceKey) error
UpdateInstanceLastChecked updates the last_check timestamp in the orchestrator backed database for a given instance
func UpdateResolvedHostname ¶
UpdateResolvedHostname will store the given resolved hostname in cache Returns false when the key already existed with same resolved value (similar to AFFECTED_ROWS() in mysql)
func WriteClusterAlias ¶
WriteClusterAlias will write (and override) a single cluster name mapping
func WriteClusterDomainName ¶ added in v1.4.283
WriteClusterDomainName will write (and override) the domain name of a cluster
func WriteHostnameUnresolve ¶ added in v1.4.204
func WriteHostnameUnresolve(instanceKey *InstanceKey, unresolvedHostname string) error
WriteHostnameUnresolve upserts an entry in hostname_unresolve
func WriteLongRunningProcesses ¶
func WriteLongRunningProcesses(instanceKey *InstanceKey, processes []Process) error
WriteLongRunningProcesses rewrites current state of long running processes for given instance
func WriteMasterPositionEquivalence ¶ added in v1.4.328
func WriteMasterPositionEquivalence(master1Key *InstanceKey, master1BinlogCoordinates *BinlogCoordinates, master2Key *InstanceKey, master2BinlogCoordinates *BinlogCoordinates) error
func WriteResolvedHostname ¶
WriteResolvedHostname stores a hostname and the resolved hostname to backend database
Types ¶
type AnalysisCode ¶
type AnalysisCode string
type Audit ¶
type Audit struct { AuditId int64 AuditTimestamp string AuditType string AuditInstanceKey InstanceKey Message string }
Audit presents a single audit entry (namely in the database)
func ReadRecentAudit ¶
func ReadRecentAudit(instanceKey *InstanceKey, page int) ([]Audit, error)
ReadRecentAudit returns a list of audit entries order chronologically descending, using page number.
type BinlogCoordinates ¶
type BinlogCoordinates struct { LogFile string LogPos int64 Type BinlogType }
BinlogCoordinates described binary log coordinates in the form of log file & log position.
func CorrelateBinlogCoordinates ¶ added in v1.4.470
func CorrelateBinlogCoordinates(instance *Instance, binlogCoordinates *BinlogCoordinates, otherInstance *Instance) (*BinlogCoordinates, int, error)
CorrelateBinlogCoordinates
func FindLastPseudoGTIDEntry ¶
func FindLastPseudoGTIDEntry(instance *Instance, recordedInstanceRelayLogCoordinates BinlogCoordinates, maxBinlogCoordinates *BinlogCoordinates, exhaustiveSearch bool, expectedBinlogFormat *string) (*BinlogCoordinates, string, error)
FindLastPseudoGTIDEntry will search an instance's binary logs or relay logs for the last pseudo-GTID entry, and return found coordinates as well as entry text
func GetEquivalentBinlogCoordinatesFor ¶ added in v1.4.328
func GetEquivalentBinlogCoordinatesFor(instanceCoordinates *InstanceBinlogCoordinates, belowKey *InstanceKey) (*BinlogCoordinates, error)
func GetNextBinlogCoordinatesToMatch ¶
func GetNextBinlogCoordinatesToMatch(instance *Instance, instanceCoordinates BinlogCoordinates, recordedInstanceRelayLogCoordinates BinlogCoordinates, maxBinlogCoordinates *BinlogCoordinates, other *Instance, otherCoordinates BinlogCoordinates) (*BinlogCoordinates, int, error)
GetNextBinlogCoordinatesToMatch is given a twin-coordinates couple for a would-be slave (instanceKey) and another instance (otherKey). This is part of the match-below process, and is the heart of the operation: matching the binlog events starting the twin-coordinates (where both share the same Pseudo-GTID) until "instance" runs out of entries, hopefully before "other" runs out. If "other" runs out that means "instance" is more advanced in replication than "other", in which case we can't turn it into a slave of "other". Otherwise "instance" will point to the *next* binlog entry in "other"
func ParseBinlogCoordinates ¶ added in v1.4.470
func ParseBinlogCoordinates(logFileLogPos string) (*BinlogCoordinates, error)
ParseInstanceKey will parse an InstanceKey from a string representation such as 127.0.0.1:3306
func SearchEntryInBinlog ¶ added in v1.4.470
func SearchEntryInBinlog(instanceKey *InstanceKey, binlog string, entryText string, monotonicPseudoGTIDEntries bool) (BinlogCoordinates, bool, error)
SearchEntryInBinlog Given a binlog entry text (query), search it in the given binary log of a given instance
func SearchEntryInInstanceBinlogs ¶ added in v1.4.470
func SearchEntryInInstanceBinlogs(instance *Instance, entryText string, monotonicPseudoGTIDEntries bool) (*BinlogCoordinates, error)
SearchEntryInInstanceBinlogs will search for a specific text entry within the binary logs of a given instance.
func (*BinlogCoordinates) DetachedCoordinates ¶ added in v1.4.408
func (this *BinlogCoordinates) DetachedCoordinates() (isDetached bool, detachedLogFile string, detachedLogPos string)
FileSmallerThan returns true if this coordinate's file is strictly smaller than the other's.
func (*BinlogCoordinates) DisplayString ¶
func (this *BinlogCoordinates) DisplayString() string
DisplayString returns a user-friendly string representation of these coordinates
func (*BinlogCoordinates) Equals ¶
func (this *BinlogCoordinates) Equals(other *BinlogCoordinates) bool
Equals tests equality of this corrdinate and another one.
func (*BinlogCoordinates) FileNumber ¶ added in v1.4.291
func (this *BinlogCoordinates) FileNumber() (int, int)
FileNumber returns the numeric value of the file, and the length in characters representing the number in the filename. Example: FileNumber() of mysqld.log.000789 is (789, 6)
func (*BinlogCoordinates) FileNumberDistance ¶ added in v1.4.291
func (this *BinlogCoordinates) FileNumberDistance(other *BinlogCoordinates) int
FileNumberDistance returns the numeric distance between this corrdinate's file number and the other's. Effectively it means "how many roatets/FLUSHes would make these coordinates's file reach the other's"
func (*BinlogCoordinates) FileSmallerThan ¶
func (this *BinlogCoordinates) FileSmallerThan(other *BinlogCoordinates) bool
FileSmallerThan returns true if this coordinate's file is strictly smaller than the other's.
func (*BinlogCoordinates) NextFileCoordinates ¶
func (this *BinlogCoordinates) NextFileCoordinates() (BinlogCoordinates, error)
PreviousFileCoordinates guesses the filename of the previous binlog/relaylog
func (*BinlogCoordinates) PreviousFileCoordinates ¶
func (this *BinlogCoordinates) PreviousFileCoordinates() (BinlogCoordinates, error)
PreviousFileCoordinates guesses the filename of the previous binlog/relaylog
func (*BinlogCoordinates) PreviousFileCoordinatesBy ¶ added in v1.4.219
func (this *BinlogCoordinates) PreviousFileCoordinatesBy(offset int) (BinlogCoordinates, error)
PreviousFileCoordinatesBy guesses the filename of the previous binlog/relaylog, by given offset (number of files back)
func (*BinlogCoordinates) SmallerThan ¶
func (this *BinlogCoordinates) SmallerThan(other *BinlogCoordinates) bool
SmallerThan returns true if this coordinate is strictly smaller than the other.
func (BinlogCoordinates) String ¶ added in v1.4.470
func (this BinlogCoordinates) String() string
String returns a user-friendly string representation of these coordinates
type BinlogEvent ¶
type BinlogEvent struct { Coordinates BinlogCoordinates NextEventPos int64 EventType string Info string }
func (*BinlogEvent) NextBinlogCoordinates ¶
func (this *BinlogEvent) NextBinlogCoordinates() BinlogCoordinates
func (*BinlogEvent) NormalizeInfo ¶
func (this *BinlogEvent) NormalizeInfo()
type BinlogEventCursor ¶
type BinlogEventCursor struct {
// contains filtered or unexported fields
}
func NewBinlogEventCursor ¶
func NewBinlogEventCursor(startCoordinates BinlogCoordinates, fetchNextEventsFunc func(BinlogCoordinates) ([]BinlogEvent, error)) BinlogEventCursor
fetchNextEventsFunc expected to return events starting at a given position, and automatically fetch those from next binary log when no more rows are found in current log. It is expected to return empty array with no error upon end of binlogs It is expected to return error upon error...
type ClusterInfo ¶
type ClusterInfo struct { ClusterName string ClusterAlias string // Human friendly alias ClusterDomain string // CNAME/VIP/A-record/whatever of the master of this cluster CountInstances uint HeuristicLag int64 HasAutomatedMasterRecovery bool HasAutomatedIntermediateMasterRecovery bool }
ClusterInfo makes for a cluster status/info summary
func ReadClusterInfo ¶
func ReadClusterInfo(clusterName string) (*ClusterInfo, error)
ReadClusterInfo reads some info about a given cluster
func ReadClustersInfo ¶
func ReadClustersInfo() ([]ClusterInfo, error)
ReadClustersInfo reads names of all known clusters and some aggregated info
type ClusterPoolInstance ¶
type ClusterPoolInstance struct { ClusterName string ClusterAlias string Pool string Hostname string Port int }
ClusterPoolInstance is an instance mapping a cluster, pool & instance
func ReadAllClusterPoolInstances ¶
func ReadAllClusterPoolInstances() ([](*ClusterPoolInstance), error)
type HostnameResolve ¶
type HostnameResolve struct {
// contains filtered or unexported fields
}
type Instance ¶
type Instance struct { Key InstanceKey Uptime uint ServerID uint ServerUUID string Version string ReadOnly bool Binlog_format string LogBinEnabled bool LogSlaveUpdatesEnabled bool SelfBinlogCoordinates BinlogCoordinates MasterKey InstanceKey Slave_SQL_Running bool Slave_IO_Running bool HasReplicationFilters bool SupportsOracleGTID bool UsingOracleGTID bool UsingMariaDBGTID bool UsingPseudoGTID bool ReadBinlogCoordinates BinlogCoordinates ExecBinlogCoordinates BinlogCoordinates IsDetached bool RelaylogCoordinates BinlogCoordinates LastSQLError string LastIOError string SecondsBehindMaster sql.NullInt64 SQLDelay uint ExecutedGtidSet string SlaveLagSeconds sql.NullInt64 SlaveHosts InstanceKeyMap ClusterName string SuggestedClusterAlias string DataCenter string PhysicalEnvironment string ReplicationDepth uint IsCoMaster bool IsLastCheckValid bool IsUpToDate bool IsRecentlyChecked bool SecondsSinceLastSeen sql.NullInt64 CountMySQLSnapshots int IsCandidate bool IsDowntimed bool DowntimeReason string DowntimeOwner string DowntimeEndTimestamp string UnresolvedHostname string }
Instance represents a database instance, including its current configuration & status. It presents important replication configuration and detailed replication status.
func ChangeMasterTo ¶
func ChangeMasterTo(instanceKey *InstanceKey, masterKey *InstanceKey, masterBinlogCoordinates *BinlogCoordinates, skipUnresolve bool, gtidHint OperationGTIDHint) (*Instance, error)
ChangeMasterTo changes the given instance's master according to given input.
func DetachSlave ¶
func DetachSlave(instanceKey *InstanceKey) (*Instance, error)
DetachSlave detaches a slave from replication; forcibly corrupting the binlog coordinates (though in such way that is reversible)
func DetachSlaveOperation ¶
func DetachSlaveOperation(instanceKey *InstanceKey) (*Instance, error)
DetachSlaveOperation will detach a slave from its master by forcibly corrupting its replication coordinates
func DisableGTID ¶ added in v1.4.309
func DisableGTID(instanceKey *InstanceKey) (*Instance, error)
DisableGTID will attempt to disable GTID-mode (either Oracle or MariaDB) and revert to binlog file:pos replication
func EnableGTID ¶ added in v1.4.309
func EnableGTID(instanceKey *InstanceKey) (*Instance, error)
EnableGTID will attempt to enable GTID-mode (either Oracle or MariaDB)
func EnslaveMaster ¶
func EnslaveMaster(instanceKey *InstanceKey) (*Instance, error)
EnslaveMaster will move an instance up the chain and cause its master to become its slave. It's almost a role change, just that other slaves of either 'instance' or its master are currently unaffected (they continue replicate without change) Note that the master must itself be a slave; however the grandparent does not necessarily have to be reachable and can in fact be dead.
func EnslaveSiblings ¶
func EnslaveSiblings(instanceKey *InstanceKey) (*Instance, int, error)
EnslaveSiblings is a convenience method for turning sublings of a slave to be its subordinates. This uses normal connected replication (does not utilize Pseudo-GTID)
func FindInstances ¶
FindInstances reads all instances whose name matches given pattern
func FlushBinaryLogs ¶
func FlushBinaryLogs(instanceKey *InstanceKey, count int) (*Instance, error)
FlushBinaryLogs attempts a 'FLUSH BINARY LOGS' statement on the given instance.
func FlushBinaryLogsTo ¶ added in v1.4.291
func FlushBinaryLogsTo(instanceKey *InstanceKey, logFile string) (*Instance, error)
FlushBinaryLogsTo attempts to 'FLUSH BINARY LOGS' until given binary log is reached
func GetCandidateSlaveOfBinlogServerTopology ¶ added in v1.4.408
func GetCandidateSlaveOfBinlogServerTopology(masterKey *InstanceKey) (candidateSlave *Instance, err error)
GetCandidateSlaveOfBinlogServerTopology chooses the best slave to promote given a (possibly dead) master
func GetClusterOSCSlaves ¶
GetClusterOSCSlaves returns a heuristic list of slaves which are fit as controll slaves for an OSC operation. These would be intermediate masters
func GetInstanceMaster ¶
GetInstanceMaster synchronously reaches into the replication topology and retrieves master's data
func KillQuery ¶
func KillQuery(instanceKey *InstanceKey, process int64) (*Instance, error)
KillQuery stops replication on a given instance
func MakeCoMaster ¶
func MakeCoMaster(instanceKey *InstanceKey) (*Instance, error)
MakeCoMaster will attempt to make an instance co-master with its master, by making its master a slave of its own. This only works out if the master is not replicating; the master does not have a known master (it may have an unknown master).
func MakeLocalMaster ¶
func MakeLocalMaster(instanceKey *InstanceKey) (*Instance, error)
MakeLocalMaster promotes a slave above its master, making it slave of its grandparent, while also enslaving its siblings. This serves as a convenience method to recover replication when a local master fails; the instance promoted is one of its slaves, which is most advanced among its siblings. This method utilizes Pseudo GTID
func MakeMaster ¶
func MakeMaster(instanceKey *InstanceKey) (*Instance, error)
MakeMaster will take an instance, make all its siblings its slaves (via pseudo-GTID) and make it master (stop its replicaiton, make writeable).
func MasterPosWait ¶
func MasterPosWait(instanceKey *InstanceKey, binlogCoordinates *BinlogCoordinates) (*Instance, error)
MasterPosWait issues a MASTER_POS_WAIT() an given instance according to given coordinates.
func MoveBelow ¶
func MoveBelow(instanceKey, siblingKey *InstanceKey) (*Instance, error)
MoveBelow will attempt moving instance indicated by instanceKey below its supposed sibling indicated by sinblingKey. It will perform all safety and sanity checks and will tamper with this instance's replication as well as its sibling.
func MoveBelowGTID ¶ added in v1.4.338
func MoveBelowGTID(instanceKey, otherKey *InstanceKey) (*Instance, error)
MoveBelowGTID will attempt moving instance indicated by instanceKey below another instance using either Oracle GTID or MariaDB GTID.
func MoveEquivalent ¶ added in v1.4.328
func MoveEquivalent(instanceKey, otherKey *InstanceKey) (*Instance, error)
MoveEquivalent will attempt moving instance indicated by instanceKey below another instance, based on known master coordinates equivalence
func MoveUp ¶
func MoveUp(instanceKey *InstanceKey) (*Instance, error)
MoveUp will attempt moving instance indicated by instanceKey up the topology hierarchy. It will perform all safety and sanity checks and will tamper with this instance's replication as well as its master.
func PurgeBinaryLogsTo ¶ added in v1.4.408
func PurgeBinaryLogsTo(instanceKey *InstanceKey, logFile string) (*Instance, error)
FlushBinaryLogsTo attempts to 'PURGE BINARY LOGS' until given binary log is reached
func PurgeBinaryLogsToCurrent ¶ added in v1.4.408
func PurgeBinaryLogsToCurrent(instanceKey *InstanceKey) (*Instance, error)
FlushBinaryLogsTo attempts to 'PURGE BINARY LOGS' until given binary log is reached
func ReadBinlogServerSlaveInstances ¶ added in v1.4.258
func ReadBinlogServerSlaveInstances(masterKey *InstanceKey) ([](*Instance), error)
ReadBinlogServerSlaveInstances reads direct slaves of a given master that are binlog servers
func ReadClusterCandidateInstances ¶
ReadClusterCandidateInstances reads cluster instances which are also marked as candidates
func ReadClusterInstances ¶
ReadClusterInstances reads all instances of a given cluster
func ReadHistoryClusterInstances ¶
func ReadHistoryClusterInstances(clusterName string, historyTimestampPattern string) ([](*Instance), error)
ReadHistoryClusterInstances reads (thin) instances from history
func ReadInstance ¶
func ReadInstance(instanceKey *InstanceKey) (*Instance, bool, error)
ReadInstance reads an instance from the orchestrator backend database
func ReadProblemInstances ¶
ReadProblemInstances reads all instances with problems
func ReadSlaveInstances ¶
func ReadSlaveInstances(masterKey *InstanceKey) ([](*Instance), error)
ReadSlaveInstances reads slaves of a given master
func ReadSlaveInstancesIncludingBinlogServerSubSlaves ¶ added in v1.4.258
func ReadSlaveInstancesIncludingBinlogServerSubSlaves(masterKey *InstanceKey) ([](*Instance), error)
ReadSlaveInstancesIncludingBinlogServerSubSlaves returns a list of direct slves including any slaves of a binlog server replica
func ReadTopologyInstance ¶
func ReadTopologyInstance(instanceKey *InstanceKey) (*Instance, error)
ReadTopologyInstance connects to a topology MySQL instance and reads its configuration and replication status. It writes read info into orchestrator's backend.
func ReadUnseenInstances ¶
ReadUnseenInstances reads all instances which were not recently seen
func ReattachSlave ¶
func ReattachSlave(instanceKey *InstanceKey) (*Instance, error)
ReattachSlave restores a detahced slave back into replication
func ReattachSlaveOperation ¶
func ReattachSlaveOperation(instanceKey *InstanceKey) (*Instance, error)
ReattachSlaveOperation will detach a slave from its master by forcibly corrupting its replication coordinates
func RefreshInstanceSlaveHosts ¶
func RefreshInstanceSlaveHosts(instanceKey *InstanceKey) (*Instance, error)
RefreshInstanceSlaveHosts is a workaround for a bug in MySQL where SHOW SLAVE HOSTS continues to present old, long disconnected slaves. It turns out issuing a couple FLUSH commands mitigates the problem.
func RefreshTopologyInstance ¶
func RefreshTopologyInstance(instanceKey *InstanceKey) (*Instance, error)
RefreshTopologyInstance will synchronuously re-read topology instance
func RelocateBelow ¶ added in v1.4.304
func RelocateBelow(instanceKey, otherKey *InstanceKey) (*Instance, error)
RelocateBelow will attempt moving instance indicated by instanceKey below another instance. Orchestrator will try and figure out the best way to relocate the server. This could span normal binlog-position, pseudo-gtid, repointing, binlog servers...
func RemoveBinlogServerInstances ¶ added in v1.4.454
removeBinlogServerInstances will remove all binlog servers from given lsit
func RemoveInstance ¶ added in v1.4.454
func RemoveInstance(instances [](*Instance), instanceKey *InstanceKey) [](*Instance)
removeInstance will remove an instance from a list of instances
func RemoveNilInstances ¶ added in v1.4.454
removeNilInstances
func Repoint ¶
func Repoint(instanceKey *InstanceKey, masterKey *InstanceKey, gitdHint OperationGTIDHint) (*Instance, error)
Repoint connects a slave to a master using its exact same executing coordinates. The given masterKey can be null, in which case the existing master is used. Two use cases: - masterKey is nil: use case is corrupted relay logs on slave - masterKey is not nil: using Binlog servers (coordinates remain the same)
func RepointSlaves ¶
func RepointSlaves(instanceKey *InstanceKey, pattern string) ([](*Instance), error, []error)
RepointSlaves repoints all slaves of a given instance onto its existing master.
func RepointSlavesTo ¶ added in v1.4.219
func RepointSlavesTo(instanceKey *InstanceKey, pattern string, belowKey *InstanceKey) ([](*Instance), error, []error)
RepointSlaves repoints slaves of a given instance (possibly filtered) onto another master. Binlog Server is the major use case
func RepointTo ¶ added in v1.4.271
func RepointTo(slaves [](*Instance), belowKey *InstanceKey) ([](*Instance), error, []error)
RepointTo repoints list of slaves onto another master. Binlog Server is the major use case
func ResetSlave ¶
func ResetSlave(instanceKey *InstanceKey) (*Instance, error)
ResetSlave resets a slave, breaking the replication
func ResetSlaveOperation ¶
func ResetSlaveOperation(instanceKey *InstanceKey) (*Instance, error)
ResetSlaveOperation will reset a slave
func RestartSlave ¶ added in v1.4.328
func RestartSlave(instanceKey *InstanceKey) (instance *Instance, err error)
RestartSlave stops & starts replication on a given instance
func SearchInstances ¶
SearchInstances reads all instances qualifying for some searchString
func SetReadOnly ¶
func SetReadOnly(instanceKey *InstanceKey, readOnly bool) (*Instance, error)
SetReadOnly sets or clears the instance's global read_only variable
func SkipQuery ¶
func SkipQuery(instanceKey *InstanceKey) (*Instance, error)
SkipQuery skip a single query in a failed replication instance
func SkipToNextBinaryLog ¶ added in v1.4.408
func SkipToNextBinaryLog(instanceKey *InstanceKey) (*Instance, error)
SkipToNextBinaryLog changes master position to beginning of next binlog USE WITH CARE! Use case is binlog servers where the master was gone & replaced by another.
func StartSlave ¶
func StartSlave(instanceKey *InstanceKey) (*Instance, error)
StartSlave starts replication on a given instance
func StartSlaveUntilMasterCoordinates ¶
func StartSlaveUntilMasterCoordinates(instanceKey *InstanceKey, masterCoordinates *BinlogCoordinates) (*Instance, error)
StartSlaveUntilMasterCoordinates issuesa START SLAVE UNTIL... statement on given instance
func StopSlave ¶
func StopSlave(instanceKey *InstanceKey) (*Instance, error)
StopSlave stops replication on a given instance
func StopSlaveNicely ¶
func StopSlaveNicely(instanceKey *InstanceKey, timeout time.Duration) (*Instance, error)
StopSlaveNicely stops a slave such that SQL_thread and IO_thread are aligned (i.e. SQL_thread consumes all relay log entries) It will actually START the sql_thread even if the slave is completely stopped.
func StopSlavesNicely ¶
StopSlavesNicely will attemt to stop all given slaves nicely, up to timeout
func (*Instance) AddSlaveKey ¶
func (this *Instance) AddSlaveKey(slaveKey *InstanceKey)
AddSlaveKey adds a slave to the list of this instance's slaves.
func (*Instance) CanMove ¶
CanMove returns true if this instance's state allows it to be repositioned. For example, if this instance lags too much, it will not be moveable.
func (*Instance) CanMoveAsCoMaster ¶
CanMoveAsCoMaster returns true if this instance's state allows it to be repositioned.
func (*Instance) CanMoveViaMatch ¶
CanMoveViaMatch returns true if this instance's state allows it to be repositioned via pseudo-GTID matching
func (*Instance) CanReplicateFrom ¶
CanReplicateFrom uses heursitics to decide whether this instacne can practically replicate from other instance. Checks are made to binlog format, version number, binary logs etc.
func (*Instance) Equals ¶
Equals tests that this instance is the same instance as other. The function does not test configuration or status.
func (*Instance) GetNextBinaryLog ¶
func (this *Instance) GetNextBinaryLog(binlogCoordinates BinlogCoordinates) (BinlogCoordinates, error)
GetNextBinaryLog returns the successive, if any, binary log file to the one given
func (*Instance) HasReasonableMaintenanceReplicationLag ¶
HasReasonableMaintenanceReplicationLag returns true when the slave lag is reasonable, and maintenance operations should have a green light to go.
func (*Instance) HumanReadableDescription ¶
HumanReadableDescription returns a simple readable string describing the status, version, etc. properties of this instance
func (*Instance) IsBinlogServer ¶ added in v1.4.258
IsMaxScale checkes whether this is any type of a binlog server (currently only maxscale)
func (*Instance) IsMasterOf ¶
IsSlaveOf returns true if this i supposed master of given slave
func (*Instance) IsOracleMySQL ¶ added in v1.4.291
IsOracleMySQL checkes whether this is an Oracle MySQL distribution
func (*Instance) IsSlave ¶
IsSlave makes simple heuristics to decide whether this insatnce is a slave of another instance
func (*Instance) IsSlaveOf ¶
IsSlaveOf returns true if this instance claims to replicate from given master
func (*Instance) IsSmallerMajorVersion ¶
IsSmallerMajorVersion tests this instance against another and returns true if this instance is of a smaller "major" varsion. e.g. 5.5.36 is NOT a smaller major version as comapred to 5.5.36, but IS as compared to 5.6.9
func (*Instance) IsSmallerMajorVersionByString ¶ added in v1.4.291
IsSmallerMajorVersionByString cehcks if this instance has a smaller major version number than given one
func (*Instance) MajorVersion ¶
MajorVersion returns this instance's major version number (e.g. for 5.5.36 it returns "5.5")
func (*Instance) NextGTID ¶ added in v1.4.328
NextGTID returns the next (Oracle) GTID to be executed. Useful for skipping queries
func (*Instance) SQLThreadUpToDate ¶
SQLThreadUpToDate returns true when the instance had consumed all relay logs.
func (*Instance) SlaveRunning ¶
SlaveRunning returns true when this instance's status is of a replicating slave.
func (*Instance) StatusString ¶
StatusString returns a human readable description of this instance's status
type InstanceBinlogCoordinates ¶ added in v1.4.328
type InstanceBinlogCoordinates struct { Key InstanceKey Coordinates BinlogCoordinates }
InstanceBinlogCoordinates is a convenice wrapper for instance key + binlog coordinates
func GetEquivalentMasterCoordinates ¶ added in v1.4.328
func GetEquivalentMasterCoordinates(instanceCoordinates *InstanceBinlogCoordinates) (result [](*InstanceBinlogCoordinates), err error)
type InstanceKey ¶
InstanceKey is an instance indicator, identifued by hostname and port
func NewInstanceKeyFromStrings ¶
func NewInstanceKeyFromStrings(hostname string, port string) (*InstanceKey, error)
NewInstanceKeyFromStrings creates a new InstanceKey by resolving hostname and port. hostname is normalized via ResolveHostname. port is tested to be valid integer.
func NewRawInstanceKey ¶
func NewRawInstanceKey(hostPort string) (*InstanceKey, error)
ParseInstanceKey will parse an InstanceKey from a string representation such as 127.0.0.1:3306
func ParseInstanceKey ¶
func ParseInstanceKey(hostPort string) (*InstanceKey, error)
ParseInstanceKey will parse an InstanceKey from a string representation such as 127.0.0.1:3306
func ParseInstanceKeyLoose ¶
func ParseInstanceKeyLoose(hostPort string) (*InstanceKey, error)
ParseInstanceKeyLoose will parse an InstanceKey from a string representation such as 127.0.0.1:3306. The port part is optional
func ReadMaintenanceInstanceKey ¶
func ReadMaintenanceInstanceKey(maintenanceToken int64) (*InstanceKey, error)
ReadMaintenanceInstanceKey will return the instanceKey for active maintenance by maintenanceToken
func ReadOutdatedInstanceKeys ¶
func ReadOutdatedInstanceKeys() ([]InstanceKey, error)
ReadOutdatedInstanceKeys reads and returns keys for all instances that are not up to date (i.e. pre-configured time has passed since they were last cheked) But we also check for the case where an attempt at instance checking has been made, that hasn't resulted in an actual check! This can happen when TCP/IP connections are hung, in which case the "check" never returns. In such case we multiply interval by a factor, so as not to open too many connections on the instance.
func UnresolveHostname ¶
func UnresolveHostname(instanceKey *InstanceKey) (InstanceKey, bool, error)
func (*InstanceKey) DisplayString ¶
func (this *InstanceKey) DisplayString() string
DisplayString returns a user-friendly string representation of this key
func (*InstanceKey) Equals ¶
func (this *InstanceKey) Equals(other *InstanceKey) bool
Equals tests equality between this key and another key
func (*InstanceKey) Formalize ¶
func (this *InstanceKey) Formalize() *InstanceKey
Formalize this key by getting CNAME for hostname
func (*InstanceKey) IsValid ¶
func (this *InstanceKey) IsValid() bool
IsValid uses simple heuristics to see whether this key represents an actual instance
func (InstanceKey) String ¶ added in v1.4.421
func (this InstanceKey) String() string
String returns a user-friendly string representation of this key
type InstanceKeyMap ¶
type InstanceKeyMap map[InstanceKey]bool
InstanceKeyMap is a convenience struct for listing InstanceKey-s
func NewInstanceKeyMap ¶ added in v1.4.408
func NewInstanceKeyMap() *InstanceKeyMap
func (*InstanceKeyMap) AddInstances ¶ added in v1.4.408
func (this *InstanceKeyMap) AddInstances(instances [](*Instance))
AddInstances adds keys of all given instances to this map
func (*InstanceKeyMap) AddKey ¶ added in v1.4.408
func (this *InstanceKeyMap) AddKey(key InstanceKey)
AddKey adds a single key to this map
func (*InstanceKeyMap) AddKeys ¶ added in v1.4.408
func (this *InstanceKeyMap) AddKeys(keys []InstanceKey)
AddKeys adds all given keys to this map
func (*InstanceKeyMap) GetInstanceKeys ¶
func (this *InstanceKeyMap) GetInstanceKeys() []InstanceKey
GetInstanceKeys returns keys in this map in the form of an array
func (*InstanceKeyMap) MarshalJSON ¶
func (this *InstanceKeyMap) MarshalJSON() ([]byte, error)
MarshalJSON will marshal this map as JSON
func (*InstanceKeyMap) ReadCommaDelimitedList ¶ added in v1.4.408
func (this *InstanceKeyMap) ReadCommaDelimitedList(list string) error
ReadJson unmarshalls a json into this map
func (*InstanceKeyMap) ReadJson ¶ added in v1.4.408
func (this *InstanceKeyMap) ReadJson(jsonString string) error
ReadJson unmarshalls a json into this map
func (*InstanceKeyMap) ToCommaDelimitedList ¶ added in v1.4.408
func (this *InstanceKeyMap) ToCommaDelimitedList() string
MarshalJSON will marshal this map as JSON
func (*InstanceKeyMap) ToJSON ¶ added in v1.4.408
func (this *InstanceKeyMap) ToJSON() (string, error)
MarshalJSON will marshal this map as JSON
func (*InstanceKeyMap) ToJSONString ¶ added in v1.4.408
func (this *InstanceKeyMap) ToJSONString() string
MarshalJSON will marshal this map as JSON
type InstancesByCountSlaveHosts ¶
type InstancesByCountSlaveHosts [](*Instance)
InstancesByCountSlaveHosts is a sortable type for Instance
func (InstancesByCountSlaveHosts) Len ¶
func (this InstancesByCountSlaveHosts) Len() int
func (InstancesByCountSlaveHosts) Less ¶
func (this InstancesByCountSlaveHosts) Less(i, j int) bool
func (InstancesByCountSlaveHosts) Swap ¶
func (this InstancesByCountSlaveHosts) Swap(i, j int)
type InstancesByExecBinlogCoordinates ¶
type InstancesByExecBinlogCoordinates [](*Instance)
InstancesByExecBinlogCoordinates is a sortabel type for BinlogCoordinates
func (InstancesByExecBinlogCoordinates) Len ¶
func (this InstancesByExecBinlogCoordinates) Len() int
func (InstancesByExecBinlogCoordinates) Less ¶
func (this InstancesByExecBinlogCoordinates) Less(i, j int) bool
func (InstancesByExecBinlogCoordinates) Swap ¶
func (this InstancesByExecBinlogCoordinates) Swap(i, j int)
type Maintenance ¶
type Maintenance struct { MaintenanceId uint Key InstanceKey BeginTimestamp string SecondsElapsed uint IsActive bool Owner string Reason string }
Maintenance indicates a maintenance entry (also in the database)
func ReadActiveMaintenance ¶
func ReadActiveMaintenance() ([]Maintenance, error)
ReadActiveMaintenance returns the list of currently active maintenance entries
type OperationGTIDHint ¶ added in v1.4.309
type OperationGTIDHint string
type PoolInstancesMap ¶
type PoolInstancesMap map[string]([]*InstanceKey)
PoolInstancesMap lists instance keys per pool name
func ReadClusterPoolInstances ¶
func ReadClusterPoolInstances(clusterName string) (*PoolInstancesMap, error)
type PostponedFunctionsContainer ¶ added in v1.4.428
type PostponedFunctionsContainer struct {
PostponedFunctions [](func() error)
}
func NewPostponedFunctionsContainer ¶ added in v1.4.428
func NewPostponedFunctionsContainer() *PostponedFunctionsContainer
func (*PostponedFunctionsContainer) AddPostponedFunction ¶ added in v1.4.428
func (this *PostponedFunctionsContainer) AddPostponedFunction(f func() error)
func (*PostponedFunctionsContainer) InvokePostponed ¶ added in v1.4.428
func (this *PostponedFunctionsContainer) InvokePostponed() (err error)
type Process ¶
type Process struct { InstanceHostname string InstancePort int Id int64 User string Host string Db string Command string Time int64 State string Info string StartedAt string }
Process presents a MySQL executing thread (as observed by PROCESSLIST)
func ReadLongRunningProcesses ¶
ReadLongRunningProcesses returns the list of current known long running processes of all instances
type ReplicationAnalysis ¶
type ReplicationAnalysis struct { AnalyzedInstanceKey InstanceKey AnalyzedInstanceMasterKey InstanceKey ClusterDetails ClusterInfo IsMaster bool IsCoMaster bool LastCheckValid bool CountSlaves uint CountValidSlaves uint CountValidReplicatingSlaves uint CountSlavesFailingToConnectToMaster uint ReplicationDepth uint SlaveHosts InstanceKeyMap IsFailingToConnectToMaster bool Analysis AnalysisCode Description string IsDowntimed bool DowntimeEndTimestamp string DowntimeRemainingSeconds int IsBinlogServer bool PseudoGTIDImmediateTopology bool OracleGTIDImmediateTopology bool MariaDBGTIDImmediateTopology bool BinlogServerImmediateTopology bool }
ReplicationAnalysis notes analysis on replication chain status, per instance
func GetReplicationAnalysis ¶
func GetReplicationAnalysis(includeDowntimed bool) ([]ReplicationAnalysis, error)
GetReplicationAnalysis will check for replication problems (dead master; unreachable master; etc)
func (*ReplicationAnalysis) ReadSlaveHostsFromString ¶
func (this *ReplicationAnalysis) ReadSlaveHostsFromString(slaveHostsString string) error
ReadSlaveHostsFromString parses and reads slave keys from comma delimited string
Source Files ¶
- analysis.go
- analysis_dao.go
- audit.go
- audit_dao.go
- binlog.go
- cluster.go
- cluster_alias.go
- cluster_alias_dao.go
- cluster_domain.go
- cluster_domain_dao.go
- downtime_dao.go
- instance.go
- instance_binlog.go
- instance_binlog_dao.go
- instance_dao.go
- instance_key.go
- instance_key_map.go
- instance_topology.go
- instance_utils.go
- maintenance.go
- maintenance_dao.go
- master_equivalence.go
- master_equivalence_dao.go
- pool.go
- pool_dao.go
- postponed_functions.go
- process.go
- process_dao.go
- resolve.go
- resolve_dao.go