Documentation ¶
Index ¶
- Constants
- Variables
- func ASCIITopology(clusterName string, historyTimestampPattern string, tabulated bool, ...) (result string, err error)
- func ApplyPoolInstances(submission *PoolInstancesSubmission) error
- func AuditOperation(auditType string, instanceKey *InstanceKey, message string) error
- func BeginBoundedMaintenance(instanceKey *InstanceKey, owner string, reason string, durationSeconds uint, ...) (int64, error)
- func BeginDowntime(downtime *Downtime) (err error)
- func BeginMaintenance(instanceKey *InstanceKey, owner string, reason string) (int64, error)
- func CheckAndInjectPseudoGTIDOnWriter(instance *Instance) (injected bool, err error)
- func CheckMoveViaGTID(instance, otherInstance *Instance) (err error)
- func DeduceClusterName(nameOrAlias string) (clusterName string, err error)
- func DelayReplication(instanceKey *InstanceKey, seconds int) error
- func DeleteHostnameUnresolve(instanceKey *InstanceKey) error
- func DeleteInvalidHostnameResolves() error
- func EmptyCommitInstance(instanceKey *InstanceKey) error
- func EnableAuditSyslog() (err error)
- func EnableSemiSync(instanceKey *InstanceKey, master, replica bool) error
- func EndDowntime(instanceKey *InstanceKey) (wasDowntimed bool, err error)
- func EndMaintenance(maintenanceToken int64) (wasMaintenance bool, err error)
- func EndMaintenanceByInstanceKey(instanceKey *InstanceKey) (wasMaintenance bool, err error)
- func ErrantGTIDInjectEmpty(instanceKey *InstanceKey) (instance *Instance, clusterMaster *Instance, countInjectedTransactions int64, ...)
- func ExecDBWriteFunc(f func() error) error
- func ExecInstance(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 ExpireInjectedPseudoGTID() error
- func ExpireInstanceAnalysisChangelog() error
- func ExpireMaintenance() error
- func ExpireMasterPositionEquivalence() error
- func ExpirePoolInstances() error
- func ExpireStaleInstanceBinlogCoordinates() error
- func ExpireTableData(tableName string, timestampColumn string) error
- func FigureClusterName(clusterHint string, instanceKey *InstanceKey, thisInstanceKey *InstanceKey) (clusterName string, err error)
- func FiltersMatchInstanceKey(instanceKey *InstanceKey, filters []string) bool
- func FlushNontrivialResolveCacheToDatabase() error
- func ForgetCluster(clusterName string) error
- func ForgetExpiredHostnameResolves() error
- func ForgetInstance(instanceKey *InstanceKey) error
- func ForgetLongUnseenClusterAliases() error
- func ForgetLongUnseenInstances() error
- func ForgetUnseenInstancesDifferentlyResolved() error
- func GTIDSubtract(instanceKey *InstanceKey, gtidSet string, gtidSubset string) (gtidSubtract string, err error)
- func GetCNAME(hostname string) (string, error)
- func GetCandidateReplica(masterKey *InstanceKey, forRematchPurposes bool) (*Instance, [](*Instance), [](*Instance), [](*Instance), [](*Instance), error)
- func GetClusterByAlias(alias string) (string, error)
- func GetClusterHeuristicLag(clusterName string) (int64, error)
- func GetClusterMasterKVKey(clusterAlias string) string
- func GetClusterMasterKVPairs(clusterAlias string, masterKey *InstanceKey) (kvPairs [](*kv.KVPair))
- func GetClusterName(instanceKey *InstanceKey) (clusterName string, err error)
- func GetHeuristicClusterPoolInstancesLag(clusterName string, pool string) (int64, error)
- func GetHeuristiclyRecentCoordinatesForInstance(instanceKey *InstanceKey) (selfCoordinates *BinlogCoordinates, relayLogCoordinates *BinlogCoordinates, ...)
- func GetInstancesMaxLag(instances [](*Instance)) (maxLag int64, err error)
- func GetMaintenanceOwner() string
- func GetMastersKVPairs(clusterName string) (kvPairs [](*kv.KVPair), err error)
- func GetReplicationRestartPreserveStatements(instanceKey *InstanceKey, injectedStatement string) (statements []string, err error)
- func HostnameResolveCache() (map[string]cache.Item, error)
- func HostnameResolveMethodIsNone() bool
- func InMaintenance(instanceKey *InstanceKey) (inMaintenance bool, err error)
- func InjectSeed(instanceKey *InstanceKey) error
- func InjectUnseenMasters() error
- func InstanceIsForgotten(instanceKey *InstanceKey) bool
- func InstanceIsMasterOf(allegedMaster, allegedReplica *Instance) bool
- func InstanceTagExists(instanceKey *InstanceKey, tag *Tag) (tagExists bool, err error)
- func InstancesAreSiblings(instance0, instance1 *Instance) bool
- func IsBannedFromBeingCandidateReplica(replica *Instance) bool
- func IsSmallerBinlogFormat(binlogFormat string, otherBinlogFormat string) bool
- func IsSmallerMajorVersion(version string, otherVersion string) bool
- func LoadHostnameResolveCache() error
- func LocateErrantGTID(instanceKey *InstanceKey) (errantBinlogs []string, err error)
- func MajorVersion(version string) []string
- func MatchBelow(instanceKey, otherKey *InstanceKey, requireInstanceMaintenance bool) (*Instance, *BinlogCoordinates, error)
- func MatchUp(instanceKey *InstanceKey, requireInstanceMaintenance bool) (*Instance, *BinlogCoordinates, error)
- func MatchUpReplicas(masterKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
- func MoveReplicasGTID(masterKey *InstanceKey, belowKey *InstanceKey, pattern string) (movedReplicas [](*Instance), unmovedReplicas [](*Instance), err error, ...)
- func MoveUpReplicas(instanceKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
- func MultiMatchBelow(replicas [](*Instance), belowKey *InstanceKey, ...) (matchedReplicas [](*Instance), belowInstance *Instance, err error, ...)
- func MultiMatchReplicas(masterKey *InstanceKey, belowKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
- func NewBinlogFormatSortedByCount(formatsCount map[string]int) *binlogFormatSortedByCount
- func NewMajorVersionsSortedByCount(versionsCount map[string]int) *majorVersionsSortedByCount
- func PopulateGroupReplicationInformation(instance *Instance, db *sql.DB) error
- func PopulateInstancesAgents(instances [](*Instance)) error
- func PutInstanceTag(instanceKey *InstanceKey, tag *Tag) (err error)
- func ReadAliasByClusterName(clusterName string) (alias string, err error)
- func ReadClusterAliasOverride(instance *Instance) (err error)
- func ReadClusterNameByAlias(alias string) (clusterName string, err error)
- func ReadClusters() (clusterNames []string, err error)
- func ReadCountMySQLSnapshots(hostnames []string) (map[string]int, error)
- func ReadInstanceClusterAttributes(instance *Instance) (err error)
- func ReadInstancePromotionRule(instance *Instance) (err error)
- func ReadInstanceTag(instanceKey *InstanceKey, tag *Tag) (tagExists bool, err error)
- func ReadReplicationGroupPrimary(instance *Instance) (err error)
- func ReadResolvedHostname(hostname string) (string, error)
- func ReadUnambiguousSuggestedClusterAliases() (result map[string]InstanceKey, err error)
- func RecordInstanceCoordinatesHistory() error
- func RecordStaleInstanceBinlogCoordinates(instanceKey *InstanceKey, binlogCoordinates *BinlogCoordinates) error
- func RefreshTopologyInstances(instances [](*Instance))
- func RegisterCandidateInstance(candidate *CandidateDatabaseInstance) error
- func RegisterHostnameUnresolve(registration *HostnameRegistration) (err error)
- func RegisterInjectedPseudoGTID(clusterName string) error
- func RegroupReplicas(masterKey *InstanceKey, returnReplicaEvenOnFailureToRegroup bool, ...) (aheadReplicas [](*Instance), equalReplicas [](*Instance), ...)
- func RegroupReplicasBinlogServers(masterKey *InstanceKey, returnReplicaEvenOnFailureToRegroup bool) (repointedBinlogServers [](*Instance), promotedBinlogServer *Instance, ...)
- func RegroupReplicasGTID(masterKey *InstanceKey, returnReplicaEvenOnFailureToRegroup bool, ...) (lostReplicas [](*Instance), movedReplicas [](*Instance), ...)
- func RegroupReplicasPseudoGTID(masterKey *InstanceKey, returnReplicaEvenOnFailureToRegroup bool, ...) (aheadReplicas [](*Instance), equalReplicas [](*Instance), ...)
- func RegroupReplicasPseudoGTIDIncludingSubReplicasOfBinlogServers(masterKey *InstanceKey, returnReplicaEvenOnFailureToRegroup bool, ...) (aheadReplicas [](*Instance), equalReplicas [](*Instance), ...)
- func RelocateReplicas(instanceKey, otherKey *InstanceKey, pattern string) (replicas [](*Instance), other *Instance, err error, errs []error)
- func RematchReplica(instanceKey *InstanceKey, requireInstanceMaintenance bool) (*Instance, *BinlogCoordinates, error)
- func ReplaceAliasClusterName(oldClusterName string, newClusterName string) (err error)
- func ReplaceClusterName(oldClusterName string, newClusterName string) error
- func ResetHostnameResolveCache() error
- func ResetInstanceRelaylogCoordinatesHistory(instanceKey *InstanceKey) error
- func ResolveHostname(hostname string) (string, error)
- func ResolveHostnameIPs(hostname string) error
- func ResolveUnknownMasterHostnameResolves() error
- func RestartReplicationQuick(instanceKey *InstanceKey) error
- func ReviewUnseenInstances() error
- func ScanInstanceRow(instanceKey *InstanceKey, query string, dest ...interface{}) error
- func SemicolonTerminated(statement string) string
- func SetClusterAlias(clusterName string, alias string) error
- func SetClusterAliasManualOverride(clusterName string, alias string) error
- func SetMaintenanceOwner(owner string)
- func ShowBinaryLogs(instanceKey *InstanceKey) (binlogs []string, err error)
- func ShowMasterStatus(instanceKey *InstanceKey) (masterStatusFound bool, executedGtidSet string, err error)
- func SnapshotTopologies() error
- func StartReplicas(replicas [](*Instance))
- func TakeMasterHook(successor *Instance, demoted *Instance)
- func UpdateClusterAliases() error
- func UpdateInstanceLastAttemptedCheck(instanceKey *InstanceKey) error
- func UpdateInstanceLastChecked(instanceKey *InstanceKey, partialSuccess bool) error
- func UpdateResolvedHostname(hostname string, resolvedHostname string) bool
- func ValidSecondsFromSeenToLastAttemptedCheck() uint
- func WriteClusterDomainName(clusterName string, domainName string) error
- func WriteHostnameUnresolve(instanceKey *InstanceKey, unresolvedHostname string) error
- func WriteInstance(instance *Instance, instanceWasActuallyFound bool, lastError error) error
- func WriteMasterPositionEquivalence(master1Key *InstanceKey, master1BinlogCoordinates *BinlogCoordinates, ...) error
- func WriteResolvedHostname(hostname string, resolvedHostname string) error
- type AggregatedWriteBufferMetric
- type AnalysisCode
- type AnalysisInstanceType
- type AnalysisMap
- type Audit
- type BinlogCoordinates
- func CorrelateBinlogCoordinates(instance *Instance, binlogCoordinates *BinlogCoordinates, ...) (*BinlogCoordinates, int, error)
- func CorrelateRelaylogCoordinates(instance *Instance, relaylogCoordinates *BinlogCoordinates, ...) (instanceCoordinates, correlatedCoordinates, nextCoordinates *BinlogCoordinates, ...)
- func FindLastPseudoGTIDEntry(instance *Instance, recordedInstanceRelayLogCoordinates BinlogCoordinates, ...) (instancePseudoGtidCoordinates *BinlogCoordinates, ...)
- func GetEquivalentBinlogCoordinatesFor(instanceCoordinates *InstanceBinlogCoordinates, belowKey *InstanceKey) (*BinlogCoordinates, error)
- func GetNextBinlogCoordinatesToMatch(instance *Instance, instanceCoordinates BinlogCoordinates, ...) (*BinlogCoordinates, int, error)
- func GetPreviousKnownRelayLogCoordinatesForInstance(instance *Instance) (relayLogCoordinates *BinlogCoordinates, err error)
- func ParseBinlogCoordinates(logFileLogPos string) (*BinlogCoordinates, error)
- func SearchEntryInBinlog(pseudoGTIDRegexp *regexp.Regexp, instanceKey *InstanceKey, binlog string, ...) (BinlogCoordinates, bool, error)
- func SearchEntryInInstanceBinlogs(instance *Instance, entryText string, monotonicPseudoGTIDEntries bool, ...) (*BinlogCoordinates, error)
- func SearchEventInRelayLogs(searchEvent *BinlogEvent, instance *Instance, ...) (binlogCoordinates, nextCoordinates *BinlogCoordinates, found bool, err error)
- func (this *BinlogCoordinates) Detach() (detachedCoordinates BinlogCoordinates)
- func (this *BinlogCoordinates) DisplayString() string
- func (this *BinlogCoordinates) Equals(other *BinlogCoordinates) bool
- func (this *BinlogCoordinates) ExtractDetachedCoordinates() (isDetached bool, detachedCoordinates BinlogCoordinates)
- func (this *BinlogCoordinates) FileNumber() (int, int)
- func (this *BinlogCoordinates) FileNumberDistance(other *BinlogCoordinates) int
- func (this *BinlogCoordinates) FileSmallerThan(other *BinlogCoordinates) bool
- func (this *BinlogCoordinates) IsEmpty() 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) SmallerThanOrEquals(other *BinlogCoordinates) bool
- func (this BinlogCoordinates) String() string
- type BinlogEvent
- type BinlogEventCursor
- type BinlogType
- type CandidateDatabaseInstance
- type CandidatePromotionRule
- type ClusterInfo
- type ClusterPoolInstance
- type Downtime
- type HostnameRegistration
- type HostnameResolve
- type HostnameUnresolve
- type Instance
- func ChangeMasterCredentials(instanceKey *InstanceKey, creds *ReplicationCredentials) (*Instance, error)
- func ChangeMasterTo(instanceKey *InstanceKey, masterKey *InstanceKey, ...) (*Instance, error)
- func DetachReplicaMasterHost(instanceKey *InstanceKey) (*Instance, error)
- func DisableGTID(instanceKey *InstanceKey) (*Instance, error)
- func EnableGTID(instanceKey *InstanceKey) (*Instance, error)
- func EnableMasterSSL(instanceKey *InstanceKey) (*Instance, error)
- func ErrantGTIDResetMaster(instanceKey *InstanceKey) (instance *Instance, err error)
- func FindInstances(regexpPattern string) (result [](*Instance), err error)
- func FlushBinaryLogs(instanceKey *InstanceKey, count int) (*Instance, error)
- func FlushBinaryLogsTo(instanceKey *InstanceKey, logFile string) (*Instance, error)
- func GetCandidateReplicaOfBinlogServerTopology(masterKey *InstanceKey) (candidateReplica *Instance, err error)
- func GetClusterGhostReplicas(clusterName string) (result [](*Instance), err error)
- func GetClusterOSCReplicas(clusterName string) ([](*Instance), error)
- func GetHeuristicClusterPoolInstances(clusterName string, pool string) (result [](*Instance), err error)
- func GetInstanceMaster(instance *Instance) (*Instance, error)
- func GetSortedReplicas(masterKey *InstanceKey, stopReplicationMethod StopReplicationMethod) (replicas [](*Instance), err 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, force bool) (*Instance, error)
- func PurgeBinaryLogsToLatest(instanceKey *InstanceKey, force bool) (*Instance, error)
- func ReadBinlogServerReplicaInstances(masterKey *InstanceKey) ([](*Instance), error)
- func ReadClusterCandidateInstances(clusterName string) ([](*Instance), error)
- func ReadClusterInstances(clusterName string) ([](*Instance), error)
- func ReadClusterMaster(clusterName string) ([](*Instance), error)
- func ReadClusterNeutralPromotionRuleInstances(clusterName string) (neutralInstances [](*Instance), err error)
- func ReadClusterWriteableMaster(clusterName string) ([](*Instance), error)
- func ReadDowntimedInstances(clusterName string) ([](*Instance), error)
- func ReadFuzzyInstance(fuzzyInstanceKey *InstanceKey) (*Instance, error)
- func ReadHistoryClusterInstances(clusterName string, historyTimestampPattern string) ([](*Instance), error)
- func ReadInstance(instanceKey *InstanceKey) (*Instance, bool, error)
- func ReadLostInRecoveryInstances(clusterName string) ([](*Instance), error)
- func ReadProblemInstances(clusterName string) ([](*Instance), error)
- func ReadReplicaInstances(masterKey *InstanceKey) ([](*Instance), error)
- func ReadReplicaInstancesIncludingBinlogServerSubReplicas(masterKey *InstanceKey) ([](*Instance), error)
- func ReadTopologyInstance(instanceKey *InstanceKey) (*Instance, error)
- func ReadTopologyInstanceBufferable(instanceKey *InstanceKey, bufferWrites bool, latency *stopwatch.NamedStopwatch) (inst *Instance, err error)
- func ReadUnseenInstances() ([](*Instance), error)
- func ReadWriteableClustersMasters() (instances [](*Instance), err error)
- func ReattachReplicaMasterHost(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, gtidHint OperationGTIDHint) (*Instance, error)
- func RepointReplicas(instanceKey *InstanceKey, pattern string) ([](*Instance), error, []error)
- func RepointReplicasTo(instanceKey *InstanceKey, pattern string, belowKey *InstanceKey) ([](*Instance), error, []error)
- func RepointTo(replicas [](*Instance), belowKey *InstanceKey) ([](*Instance), error, []error)
- func ResetMaster(instanceKey *InstanceKey) (*Instance, error)
- func ResetReplication(instanceKey *InstanceKey) (*Instance, error)
- func ResetReplicationOperation(instanceKey *InstanceKey) (*Instance, error)
- func RestartReplication(instanceKey *InstanceKey) (instance *Instance, err error)
- func RetryInstanceFunction(f func() (*Instance, error)) (instance *Instance, err error)
- func SearchInstances(searchString string) ([](*Instance), error)
- func SetReadOnly(instanceKey *InstanceKey, readOnly bool) (*Instance, error)
- func SetSemiSyncMaster(instanceKey *InstanceKey, enableMaster bool) (*Instance, error)
- func SetSemiSyncReplica(instanceKey *InstanceKey, enableReplica bool) (*Instance, error)
- func SkipQuery(instanceKey *InstanceKey) (*Instance, error)
- func SkipToNextBinaryLog(instanceKey *InstanceKey) (*Instance, error)
- func StartReplication(instanceKey *InstanceKey) (*Instance, error)
- func StartReplicationUntilMasterCoordinates(instanceKey *InstanceKey, masterCoordinates *BinlogCoordinates) (*Instance, error)
- func StopReplicas(replicas [](*Instance), stopReplicationMethod StopReplicationMethod, ...) [](*Instance)
- func StopReplicasNicely(replicas [](*Instance), timeout time.Duration) [](*Instance)
- func StopReplication(instanceKey *InstanceKey) (*Instance, error)
- func StopReplicationNicely(instanceKey *InstanceKey, timeout time.Duration) (*Instance, error)
- func TakeMaster(instanceKey *InstanceKey, allowTakingCoMaster bool) (*Instance, error)
- func TakeSiblings(instanceKey *InstanceKey) (instance *Instance, takenSiblings int, err error)
- func WaitForExecBinlogCoordinatesToReach(instanceKey *InstanceKey, coordinates *BinlogCoordinates, ...) (instance *Instance, exactMatch bool, err error)
- func WaitForSQLThreadUpToDate(instanceKey *InstanceKey, overallTimeout time.Duration, ...) (instance *Instance, err error)
- func (this *Instance) AddGroupMemberKey(groupMemberKey *InstanceKey)
- func (this *Instance) AddReplicaKey(replicaKey *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) FlavorNameAndMajorVersion() string
- 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) IsDescendantOf(other *Instance) bool
- func (this *Instance) IsMariaDB() bool
- func (this *Instance) IsMaster() bool
- func (this *Instance) IsMasterOf(replica *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) IsMySQL80() bool
- func (this *Instance) IsNDB() bool
- func (this *Instance) IsOracleMySQL() bool
- func (this *Instance) IsPercona() bool
- func (this *Instance) IsReplica() bool
- func (this *Instance) IsReplicaOf(master *Instance) bool
- func (this *Instance) IsReplicationGroupMember() bool
- func (this *Instance) IsReplicationGroupPrimary() bool
- func (this *Instance) IsReplicationGroupSecondary() bool
- func (this *Instance) IsSeed() bool
- func (this *Instance) IsSmallerBinlogFormat(other *Instance) bool
- func (this *Instance) IsSmallerMajorVersion(other *Instance) bool
- func (this *Instance) IsSmallerMajorVersionByString(otherVersion string) bool
- func (this *Instance) LagStatusString() string
- func (this *Instance) MajorVersion() []string
- func (this *Instance) MajorVersionString() string
- func (this *Instance) MarshalJSON() ([]byte, error)
- func (this *Instance) NextGTID() (string, error)
- func (this *Instance) ReplicaRunning() bool
- func (this *Instance) ReplicationThreadsExist() bool
- func (this *Instance) ReplicationThreadsStopped() bool
- func (this *Instance) SQLThreadUpToDate() bool
- func (this *Instance) SetSeed()
- func (this *Instance) StatusString() string
- func (this *Instance) TabulatedDescription(separator string) string
- func (this *Instance) UsingGTID() bool
- type InstanceAnalysis
- type InstanceBinlogCoordinates
- type InstanceKey
- func BulkReadInstance() ([](*InstanceKey), error)
- func FigureInstanceKey(instanceKey *InstanceKey, thisInstanceKey *InstanceKey) (*InstanceKey, error)
- func GetHeuristicClusterDomainInstanceAttribute(clusterName string) (instanceKey *InstanceKey, err error)
- func HeuristicallyApplyClusterDomainInstanceAttribute(clusterName string) (instanceKey *InstanceKey, err error)
- func NewRawInstanceKeyStrings(hostname string, port string) (*InstanceKey, error)
- func NewResolveInstanceKey(hostname string, port int) (instanceKey *InstanceKey, err error)
- func NewResolveInstanceKeyStrings(hostname string, port string) (*InstanceKey, error)
- func ParseRawInstanceKey(hostPort string) (instanceKey *InstanceKey, err error)
- func ParseResolveInstanceKey(hostPort string) (instanceKey *InstanceKey, err error)
- func ReadAllInstanceKeys() ([]InstanceKey, error)
- func ReadFuzzyInstanceKey(fuzzyInstanceKey *InstanceKey) *InstanceKey
- func ReadFuzzyInstanceKeyIfPossible(fuzzyInstanceKey *InstanceKey) *InstanceKey
- func ReadMaintenanceInstanceKey(maintenanceToken int64) (*InstanceKey, error)
- func ReadOutdatedInstanceKeys() ([]InstanceKey, error)
- func UnresolveHostname(instanceKey *InstanceKey) (InstanceKey, bool, error)
- func (this *InstanceKey) DetachedKey() *InstanceKey
- func (this *InstanceKey) DisplayString() string
- func (this *InstanceKey) Equals(other *InstanceKey) bool
- func (this *InstanceKey) IsDetached() bool
- func (this *InstanceKey) IsIPv4() bool
- func (this *InstanceKey) IsValid() bool
- func (this *InstanceKey) ReattachedKey() *InstanceKey
- func (this *InstanceKey) ResolveHostname() (*InstanceKey, error)
- func (this *InstanceKey) SmallerThan(other *InstanceKey) bool
- func (this InstanceKey) String() string
- func (this *InstanceKey) StringCode() string
- 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) HasKey(key InstanceKey) bool
- func (this *InstanceKeyMap) Intersect(other *InstanceKeyMap) *InstanceKeyMap
- 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
- func (this *InstanceKeyMap) UnmarshalJSON(b []byte) error
- type InstanceTag
- type InstancesByCountReplicas
- type InstancesSorterByExec
- type Maintenance
- type MinimalInstance
- type OperationGTIDHint
- type OracleGtidSet
- func (this *OracleGtidSet) Explode() (result [](*OracleGtidSetEntry))
- func (this *OracleGtidSet) IsEmpty() bool
- func (this *OracleGtidSet) RemoveUUID(uuid string) (removed bool)
- func (this *OracleGtidSet) RetainUUID(uuid string) (anythingRemoved bool)
- func (this *OracleGtidSet) RetainUUIDs(uuids []string) (anythingRemoved bool)
- func (this *OracleGtidSet) SharedUUIDs(other *OracleGtidSet) (shared []string)
- func (this *OracleGtidSet) String() string
- type OracleGtidSetEntry
- type PeerAnalysisMap
- type PoolInstancesMap
- type PoolInstancesSubmission
- type PostponedFunctionsContainer
- type Process
- type ReplicationAnalysis
- type ReplicationAnalysisChangelog
- type ReplicationAnalysisHints
- type ReplicationCredentials
- type ReplicationThreadState
- type StopReplicationMethod
- type Tag
- type WriteBufferMetric
Constants ¶
const ( NoProblem AnalysisCode = "NoProblem" DeadMasterWithoutReplicas = "DeadMasterWithoutReplicas" DeadMaster = "DeadMaster" DeadMasterAndReplicas = "DeadMasterAndReplicas" DeadMasterAndSomeReplicas = "DeadMasterAndSomeReplicas" UnreachableMasterWithLaggingReplicas = "UnreachableMasterWithLaggingReplicas" UnreachableMaster = "UnreachableMaster" MasterSingleReplicaNotReplicating = "MasterSingleReplicaNotReplicating" MasterSingleReplicaDead = "MasterSingleReplicaDead" AllMasterReplicasNotReplicating = "AllMasterReplicasNotReplicating" AllMasterReplicasNotReplicatingOrDead = "AllMasterReplicasNotReplicatingOrDead" LockedSemiSyncMasterHypothesis = "LockedSemiSyncMasterHypothesis" LockedSemiSyncMaster = "LockedSemiSyncMaster" MasterWithoutReplicas = "MasterWithoutReplicas" DeadCoMaster = "DeadCoMaster" DeadCoMasterAndSomeReplicas = "DeadCoMasterAndSomeReplicas" UnreachableCoMaster = "UnreachableCoMaster" AllCoMasterReplicasNotReplicating = "AllCoMasterReplicasNotReplicating" DeadIntermediateMaster = "DeadIntermediateMaster" DeadIntermediateMasterWithSingleReplica = "DeadIntermediateMasterWithSingleReplica" DeadIntermediateMasterWithSingleReplicaFailingToConnect = "DeadIntermediateMasterWithSingleReplicaFailingToConnect" DeadIntermediateMasterAndSomeReplicas = "DeadIntermediateMasterAndSomeReplicas" DeadIntermediateMasterAndReplicas = "DeadIntermediateMasterAndReplicas" UnreachableIntermediateMasterWithLaggingReplicas = "UnreachableIntermediateMasterWithLaggingReplicas" UnreachableIntermediateMaster = "UnreachableIntermediateMaster" AllIntermediateMasterReplicasFailingToConnectOrDead = "AllIntermediateMasterReplicasFailingToConnectOrDead" AllIntermediateMasterReplicasNotReplicating = "AllIntermediateMasterReplicasNotReplicating" FirstTierReplicaFailingToConnectToMaster = "FirstTierReplicaFailingToConnectToMaster" BinlogServerFailingToConnectToMaster = "BinlogServerFailingToConnectToMaster" // Group replication problems DeadReplicationGroupMemberWithReplicas = "DeadReplicationGroupMemberWithReplicas" )
const ( StatementAndMixedLoggingReplicasStructureWarning AnalysisCode = "StatementAndMixedLoggingReplicasStructureWarning" StatementAndRowLoggingReplicasStructureWarning = "StatementAndRowLoggingReplicasStructureWarning" MixedAndRowLoggingReplicasStructureWarning = "MixedAndRowLoggingReplicasStructureWarning" MultipleMajorVersionsLoggingReplicasStructureWarning = "MultipleMajorVersionsLoggingReplicasStructureWarning" NoLoggingReplicasStructureWarning = "NoLoggingReplicasStructureWarning" DifferentGTIDModesStructureWarning = "DifferentGTIDModesStructureWarning" ErrantGTIDStructureWarning = "ErrantGTIDStructureWarning" NoFailoverSupportStructureWarning = "NoFailoverSupportStructureWarning" NoWriteableMasterStructureWarning = "NoWriteableMasterStructureWarning" NotEnoughValidSemiSyncReplicasStructureWarning = "NotEnoughValidSemiSyncReplicasStructureWarning" )
const ( ForceMasterFailoverCommandHint string = "force-master-failover" ForceMasterTakeoverCommandHint string = "force-master-takeover" GracefulMasterTakeoverCommandHint string = "graceful-master-takeover" )
const ( // Group member roles GroupReplicationMemberRolePrimary = "PRIMARY" GroupReplicationMemberRoleSecondary = "SECONDARY" // Group member states GroupReplicationMemberStateOnline = "ONLINE" GroupReplicationMemberStateRecovering = "RECOVERING" GroupReplicationMemberStateOffline = "OFFLINE" GroupReplicationMemberStateError = "ERROR" )
Constant strings for Group Replication information See https://dev.mysql.com/doc/refman/8.0/en/replication-group-members-table.html for additional information.
const ( NoStopReplication StopReplicationMethod = "NoStopReplication" StopReplicationNormal = "StopReplicationNormal" StopReplicationNice = "StopReplicationNice" )
const ( GTIDHintDeny OperationGTIDHint = "NoGTID" GTIDHintNeutral = "GTIDHintNeutral" GTIDHintForce = "GTIDHintForce" )
const ( ReplicationThreadStateNoThread ReplicationThreadState = -1 ReplicationThreadStateStopped = 0 ReplicationThreadStateRunning = 1 ReplicationThreadStateOther = 2 )
const (
Error1201CouldnotInitializeMasterInfoStructure = "Error 1201:"
)
const ReasonableDiscoveryLatency = 500 * time.Millisecond
Variables ¶
var (
DowntimeLostInRecoveryMessage = "lost-in-recovery"
)
var GroupReplicationNotSupportedErrors = map[uint16]bool{ 1193: true, 1146: true, }
We use this map to identify whether the query failed because the server does not support group replication or due to a different reason.
var ReplicationNotRunningError = fmt.Errorf("Replication not running")
var (
TagEqualsRegexp = regexp.MustCompile("^([^=]+)=(.*)$")
)
Functions ¶
func ASCIITopology ¶
func ASCIITopology(clusterName string, historyTimestampPattern string, tabulated bool, printTags bool) (result string, err error)
ASCIITopology returns a string representation of the topology of given cluster.
func ApplyPoolInstances ¶
func ApplyPoolInstances(submission *PoolInstancesSubmission) error
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, explicitlyBounded bool) (int64, error)
BeginBoundedMaintenance will make new maintenance entry for given instanceKey.
func BeginDowntime ¶
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 CheckAndInjectPseudoGTIDOnWriter ¶
CheckAndInjectPseudoGTIDOnWriter checks whether pseudo-GTID can and should be injected on given instance, and if so, attempts to inject.
func CheckMoveViaGTID ¶
func DeduceClusterName ¶
DeduceClusterName attempts to resolve a cluster name given a name or alias. If unsuccessful to match by alias, the function returns the same given string
func DelayReplication ¶
func DelayReplication(instanceKey *InstanceKey, seconds int) error
DelayReplication set the replication delay given seconds keeping the current state of the replication threads.
func DeleteHostnameUnresolve ¶
func DeleteHostnameUnresolve(instanceKey *InstanceKey) error
DeleteHostnameUnresolve removes an unresolve entry
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 EmptyCommitInstance ¶
func EmptyCommitInstance(instanceKey *InstanceKey) error
EmptyCommitInstance issues an empty COMMIT on a given instance
func EnableAuditSyslog ¶
func EnableAuditSyslog() (err error)
EnableSyslogWriter enables, if possible, writes to syslog. These will execute _in addition_ to normal logging
func EnableSemiSync ¶
func EnableSemiSync(instanceKey *InstanceKey, master, replica bool) error
EnableSemiSync sets the rpl_semi_sync_(master|replica)_enabled variables on a given instance.
func EndDowntime ¶
func EndDowntime(instanceKey *InstanceKey) (wasDowntimed bool, err 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) (wasMaintenance bool, err error)
EndMaintenanceByInstanceKey will terminate an active maintenance using given instanceKey as hint
func ErrantGTIDInjectEmpty ¶
func ErrantGTIDInjectEmpty(instanceKey *InstanceKey) (instance *Instance, clusterMaster *Instance, countInjectedTransactions int64, err error)
ErrantGTIDInjectEmpty will inject an empty transaction on the master of an instance's cluster in order to get rid of an errant transaction observed on the instance.
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 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 ExpireCandidateInstances ¶
func ExpireCandidateInstances() error
ExpireCandidateInstances removes stale master candidate suggestions.
func ExpireClusterDomainName ¶
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 ExpireInstanceAnalysisChangelog ¶
func ExpireInstanceAnalysisChangelog() error
ExpireInstanceAnalysisChangelog removes old-enough analysis entries from the changelog
func ExpireMaintenance ¶
func ExpireMaintenance() error
ExpireMaintenance will remove the maintenance flag on old maintenances and on bounded maintenances
func ExpireMasterPositionEquivalence ¶
func ExpireMasterPositionEquivalence() error
ExpireMasterPositionEquivalence expires old master_position_equivalence
func ExpirePoolInstances ¶
func ExpirePoolInstances() error
ExpirePoolInstances cleans up the database_instance_pool table from expired items
func ExpireStaleInstanceBinlogCoordinates ¶
func ExpireStaleInstanceBinlogCoordinates() error
func ExpireTableData ¶
func FigureClusterName ¶
func FigureClusterName(clusterHint string, instanceKey *InstanceKey, thisInstanceKey *InstanceKey) (clusterName string, err error)
FigureClusterName will make a best effort to deduce a cluster name using either a given alias or an instanceKey. First attempt is at alias, and if that doesn't work, we try instanceKey. - clusterHint may be an empty string
func FiltersMatchInstanceKey ¶
func FiltersMatchInstanceKey(instanceKey *InstanceKey, filters []string) bool
FiltersMatchInstanceKey returns true if given instance key matches any one of given filters. A filter could be: - An IP address, in which case we compare exact value - Any other string, in which case we compare via regular expression
func FlushNontrivialResolveCacheToDatabase ¶
func FlushNontrivialResolveCacheToDatabase() error
func ForgetCluster ¶
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 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 ForgetLongUnseenClusterAliases ¶
func ForgetLongUnseenClusterAliases() error
ForgetLongUnseenClusterAliases will remove entries of cluster_aliases that have long since been last seen. This function is compatible with ForgetLongUnseenInstances
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 GTIDSubtract ¶
func GTIDSubtract(instanceKey *InstanceKey, gtidSet string, gtidSubset string) (gtidSubtract string, err error)
func GetCandidateReplica ¶
func GetCandidateReplica(masterKey *InstanceKey, forRematchPurposes bool) (*Instance, [](*Instance), [](*Instance), [](*Instance), [](*Instance), error)
GetCandidateReplica chooses the best replica 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 replicas
func GetClusterMasterKVKey ¶
func GetClusterMasterKVPairs ¶
func GetClusterMasterKVPairs(clusterAlias string, masterKey *InstanceKey) (kvPairs [](*kv.KVPair))
GetClusterMasterKVPairs returns all KV pairs associated with a master. This includes the full identity of the master as well as a breakdown by hostname, port, ipv4, ipv6
func GetClusterName ¶
func GetClusterName(instanceKey *InstanceKey) (clusterName string, err error)
func GetHeuristicClusterPoolInstancesLag ¶
GetHeuristicClusterPoolInstancesLag returns a heuristic lag for the instances participating in a cluster pool (or all the cluster's pools)
func GetHeuristiclyRecentCoordinatesForInstance ¶
func GetHeuristiclyRecentCoordinatesForInstance(instanceKey *InstanceKey) (selfCoordinates *BinlogCoordinates, relayLogCoordinates *BinlogCoordinates, err error)
GetHeuristiclyRecentCoordinatesForInstance returns valid and reasonably recent coordinates for given instance.
func GetInstancesMaxLag ¶
GetInstancesMaxLag returns the maximum lag in a set of instances
func GetMaintenanceOwner ¶
func GetMaintenanceOwner() string
func GetMastersKVPairs ¶
Get a listing of KVPair for clusters masters, for all clusters or for a specific cluster.
func GetReplicationRestartPreserveStatements ¶
func GetReplicationRestartPreserveStatements(instanceKey *InstanceKey, injectedStatement string) (statements []string, err error)
GetReplicationRestartPreserveStatements returns a sequence of statements that make sure a replica is stopped and then returned to the same state. For example, if the replica was fully running, this will issue a STOP on both io_thread and sql_thread, followed by START on both. If one of them is not running at the time this function is called, said thread will be neither stopped nor started. The caller may provide an injected statememt, to be executed while the replica is stopped. This is useful for CHANGE MASTER TO commands, that unfortunately must take place while the replica is completely stopped.
func HostnameResolveCache ¶
func HostnameResolveMethodIsNone ¶
func HostnameResolveMethodIsNone() bool
func InMaintenance ¶
func InMaintenance(instanceKey *InstanceKey) (inMaintenance bool, err error)
InMaintenance checks whether a given instance is under maintenacne
func InjectSeed ¶
func InjectSeed(instanceKey *InstanceKey) error
InjectSeed: intented to be used to inject an instance upon startup, assuming it's not already known to orchestrator.
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 replicas 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 InstanceIsForgotten ¶
func InstanceIsForgotten(instanceKey *InstanceKey) bool
func InstanceIsMasterOf ¶
InstanceIsMasterOf checks whether an instance is the master of another
func InstanceTagExists ¶
func InstanceTagExists(instanceKey *InstanceKey, tag *Tag) (tagExists bool, err error)
func InstancesAreSiblings ¶
InstancesAreSiblings checks whether both instances are replicating from same master
func IsSmallerBinlogFormat ¶
IsSmallerBinlogFormat tests two binlog formats and sees if one is "smaller" than the other. "smaller" binlog format means you can replicate from the smaller to the larger.
func IsSmallerMajorVersion ¶
IsSmallerMajorVersion tests two versions against another and returns true if the former is a smaller "major" varsion than the latter. e.g. 5.5.36 is NOT a smaller major version as comapred to 5.5.40, but IS as compared to 5.6.9
func LoadHostnameResolveCache ¶
func LoadHostnameResolveCache() error
func LocateErrantGTID ¶
func LocateErrantGTID(instanceKey *InstanceKey) (errantBinlogs []string, err error)
func MajorVersion ¶
MajorVersion returns a MySQL major version number (e.g. given "5.5.36" it returns "5.5")
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 replica up the replication chain, so that it becomes sibling of its master, via Pseudo-GTID
func MatchUpReplicas ¶
func MatchUpReplicas(masterKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
MatchUpReplicas will move all replicas 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 replicas are to be resurrected via Pseudo-GTID
func MoveReplicasGTID ¶
func MoveReplicasGTID(masterKey *InstanceKey, belowKey *InstanceKey, pattern string) (movedReplicas [](*Instance), unmovedReplicas [](*Instance), err error, errs []error)
MoveReplicasGTID will (attempt to) move all replicas of given master below given instance.
func MoveUpReplicas ¶
func MoveUpReplicas(instanceKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
MoveUpReplicas will attempt moving up all replicas of a given instance, at the same time. Clock-time, this is fater than moving one at a time. However this means all replicas of the given instance, and the instance itself, will all stop replicating together.
func MultiMatchBelow ¶
func MultiMatchBelow(replicas [](*Instance), belowKey *InstanceKey, postponedFunctionsContainer *PostponedFunctionsContainer) (matchedReplicas [](*Instance), belowInstance *Instance, err error, errs []error)
MultiMatchBelow will efficiently match multiple replicas below a given instance. It is assumed that all given replicas are siblings
func MultiMatchReplicas ¶
func MultiMatchReplicas(masterKey *InstanceKey, belowKey *InstanceKey, pattern string) ([](*Instance), *Instance, error, []error)
MultiMatchReplicas will match (via pseudo-gtid) all replicas of given master below given instance.
func PopulateGroupReplicationInformation ¶
PopulateGroupReplicationInformation obtains information about Group Replication for this host as well as other hosts who are members of the same group (if any).
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 PutInstanceTag ¶
func PutInstanceTag(instanceKey *InstanceKey, tag *Tag) (err error)
func ReadAliasByClusterName ¶
ReadAliasByClusterName returns the cluster alias for the given cluster name, or the cluster name itself if not explicit alias found
func ReadClusterAliasOverride ¶
ReadClusterAliasOverride reads and applies SuggestedClusterAlias based on cluster_alias_override
func ReadClusterNameByAlias ¶
ReadClusterNameByAlias
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 ReadInstanceClusterAttributes ¶
ReadInstanceClusterAttributes 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 ReadInstanceTag ¶
func ReadInstanceTag(instanceKey *InstanceKey, tag *Tag) (tagExists bool, err error)
func ReadResolvedHostname ¶
ReadResolvedHostname returns the resolved hostname given a hostname, or empty if not exists
func ReadUnambiguousSuggestedClusterAliases ¶
func ReadUnambiguousSuggestedClusterAliases() (result map[string]InstanceKey, err error)
ReadUnambiguousSuggestedClusterAliases reads potential master hostname:port who have suggested cluster aliases, where no one else shares said suggested cluster alias. Such hostname:port are likely true owners of the alias.
func RecordInstanceCoordinatesHistory ¶
func RecordInstanceCoordinatesHistory() error
RecordInstanceCoordinatesHistory snapshots the binlog coordinates of instances
func RecordStaleInstanceBinlogCoordinates ¶
func RecordStaleInstanceBinlogCoordinates(instanceKey *InstanceKey, binlogCoordinates *BinlogCoordinates) error
RecordInstanceCoordinatesHistory snapshots the binlog coordinates of instances
func RefreshTopologyInstances ¶
func RefreshTopologyInstances(instances [](*Instance))
RefreshTopologyInstances will do a blocking (though concurrent) refresh of all given instances
func RegisterCandidateInstance ¶
func RegisterCandidateInstance(candidate *CandidateDatabaseInstance) error
RegisterCandidateInstance markes a given instance as suggested for successoring a master in the event of failover.
func RegisterHostnameUnresolve ¶
func RegisterHostnameUnresolve(registration *HostnameRegistration) (err error)
func RegisterInjectedPseudoGTID ¶
RegisterInjectedPseudoGTID
func RegroupReplicas ¶
func RegroupReplicas(masterKey *InstanceKey, returnReplicaEvenOnFailureToRegroup bool, onCandidateReplicaChosen func(*Instance), postponedFunctionsContainer *PostponedFunctionsContainer) ( aheadReplicas [](*Instance), equalReplicas [](*Instance), laterReplicas [](*Instance), cannotReplicateReplicas [](*Instance), instance *Instance, err error, )
RegroupReplicas is a "smart" method of promoting one replica over the others ("promoting" it on top of its siblings) This method decides which strategy to use: GTID, Pseudo-GTID, Binlog Servers.
func RegroupReplicasBinlogServers ¶
func RegroupReplicasBinlogServers(masterKey *InstanceKey, returnReplicaEvenOnFailureToRegroup bool) (repointedBinlogServers [](*Instance), promotedBinlogServer *Instance, err error)
RegroupReplicasBinlogServers works on a binlog-servers topology. It picks the most up-to-date BLS and repoints all other BLS below it
func RegroupReplicasGTID ¶
func RegroupReplicasGTID( masterKey *InstanceKey, returnReplicaEvenOnFailureToRegroup bool, onCandidateReplicaChosen func(*Instance), postponedFunctionsContainer *PostponedFunctionsContainer, postponeAllMatchOperations func(*Instance, bool) bool, ) ( lostReplicas [](*Instance), movedReplicas [](*Instance), cannotReplicateReplicas [](*Instance), candidateReplica *Instance, err error, )
RegroupReplicasGTID will choose a candidate replica of a given instance, and take its siblings using GTID
func RegroupReplicasPseudoGTID ¶
func RegroupReplicasPseudoGTID( masterKey *InstanceKey, returnReplicaEvenOnFailureToRegroup bool, onCandidateReplicaChosen func(*Instance), postponedFunctionsContainer *PostponedFunctionsContainer, postponeAllMatchOperations func(*Instance, bool) bool, ) ( aheadReplicas [](*Instance), equalReplicas [](*Instance), laterReplicas [](*Instance), cannotReplicateReplicas [](*Instance), candidateReplica *Instance, err error, )
RegroupReplicasPseudoGTID will choose a candidate replica of a given instance, and take its siblings using pseudo-gtid
func RegroupReplicasPseudoGTIDIncludingSubReplicasOfBinlogServers ¶
func RegroupReplicasPseudoGTIDIncludingSubReplicasOfBinlogServers( masterKey *InstanceKey, returnReplicaEvenOnFailureToRegroup bool, onCandidateReplicaChosen func(*Instance), postponedFunctionsContainer *PostponedFunctionsContainer, postponeAllMatchOperations func(*Instance, bool) bool, ) ( aheadReplicas [](*Instance), equalReplicas [](*Instance), laterReplicas [](*Instance), cannotReplicateReplicas [](*Instance), candidateReplica *Instance, err error, )
RegroupReplicasPseudoGTIDIncludingSubReplicasOfBinlogServers uses Pseugo-GTID to regroup replicas of given instance. The function also drill in to replicas of binlog servers that are replicating from given instance, and other recursive binlog servers, as long as they're in the same binlog-server-family.
func RelocateReplicas ¶
func RelocateReplicas(instanceKey, otherKey *InstanceKey, pattern string) (replicas [](*Instance), other *Instance, err error, errs []error)
RelocateReplicas will attempt moving replicas 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 RematchReplica ¶
func RematchReplica(instanceKey *InstanceKey, requireInstanceMaintenance bool) (*Instance, *BinlogCoordinates, error)
RematchReplica will re-match a replica to its master, using pseudo-gtid
func ReplaceAliasClusterName ¶
ReplaceAliasClusterName replaces alis mapping of one cluster name onto a new cluster name. Used in topology failover/recovery
func ReplaceClusterName ¶
ReplaceClusterName replaces all occurances of oldClusterName with newClusterName It is called after a master failover
func ResetHostnameResolveCache ¶
func ResetHostnameResolveCache() error
func ResetInstanceRelaylogCoordinatesHistory ¶
func ResetInstanceRelaylogCoordinatesHistory(instanceKey *InstanceKey) error
ResetInstanceRelaylogCoordinatesHistory forgets about the history of an instance. This action is desirable when relay logs become obsolete or irrelevant. Such is the case on `CHANGE MASTER TO`: servers gets compeltely new relay logs.
func ResolveHostname ¶
Attempt to resolve a hostname. This may return a database cached hostname or otherwise it may resolve the hostname via CNAME
func ResolveHostnameIPs ¶
func ResolveUnknownMasterHostnameResolves ¶
func ResolveUnknownMasterHostnameResolves() error
ResolveUnknownMasterHostnameResolves fixes missing hostname resolves based on hostname_resolve_history The use case is replicas 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 RestartReplicationQuick ¶
func RestartReplicationQuick(instanceKey *InstanceKey) error
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 SemicolonTerminated ¶
SemicolonTerminated is a utility function that makes sure a statement is terminated with a semicolon, if it isn't already
func SetClusterAlias ¶
SetClusterAlias will write (and override) a single cluster name mapping
func SetClusterAliasManualOverride ¶
SetClusterAliasManualOverride will write (and override) a single cluster name mapping
func SetMaintenanceOwner ¶
func SetMaintenanceOwner(owner string)
func ShowBinaryLogs ¶
func ShowBinaryLogs(instanceKey *InstanceKey) (binlogs []string, err error)
func ShowMasterStatus ¶
func ShowMasterStatus(instanceKey *InstanceKey) (masterStatusFound bool, executedGtidSet string, err error)
func SnapshotTopologies ¶
func SnapshotTopologies() error
SnapshotTopologies records topology graph for all existing topologies
func StartReplicas ¶
func StartReplicas(replicas [](*Instance))
StartReplicas will do concurrent start-replica
func TakeMasterHook ¶
Created this function to allow a hook to be called after a successful TakeMaster event
func UpdateClusterAliases ¶
func UpdateClusterAliases() error
UpdateClusterAliases writes down the cluster_alias table based on information gained from database_instance
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, partialSuccess bool) 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 ValidSecondsFromSeenToLastAttemptedCheck ¶
func ValidSecondsFromSeenToLastAttemptedCheck() uint
ValidSecondsFromSeenToLastAttemptedCheck returns the maximum allowed elapsed time between last_attempted_check to last_checked before we consider the instance as invalid.
func WriteClusterDomainName ¶
WriteClusterDomainName will write (and override) the domain name of a cluster
func WriteHostnameUnresolve ¶
func WriteHostnameUnresolve(instanceKey *InstanceKey, unresolvedHostname string) error
WriteHostnameUnresolve upserts an entry in hostname_unresolve
func WriteInstance ¶
WriteInstance stores an instance in the orchestrator backend
func WriteMasterPositionEquivalence ¶
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 AggregatedWriteBufferMetric ¶
type AggregatedWriteBufferMetric struct { InstanceWriteBufferSize int // config setting InstanceFlushIntervalMilliseconds int // config setting CountInstances int MaxInstances float64 MeanInstances float64 MedianInstances float64 P95Instances float64 MaxWaitSeconds float64 MeanWaitSeconds float64 MedianWaitSeconds float64 P95WaitSeconds float64 MaxWriteSeconds float64 MeanWriteSeconds float64 MedianWriteSeconds float64 P95WriteSeconds float64 }
func AggregatedSince ¶
func AggregatedSince(c *collection.Collection, t time.Time) AggregatedWriteBufferMetric
AggregatedSince returns the aggregated query metrics for the period given from the values provided.
type AnalysisCode ¶
type AnalysisCode string
type AnalysisInstanceType ¶
type AnalysisInstanceType string
const ( AnalysisInstanceTypeMaster AnalysisInstanceType = "master" AnalysisInstanceTypeCoMaster AnalysisInstanceType = "co-master" AnalysisInstanceTypeIntermediateMaster AnalysisInstanceType = "intermediate-master" AnalysisInstanceTypeGroupMember AnalysisInstanceType = "group-member" )
type AnalysisMap ¶
type AnalysisMap map[string](*ReplicationAnalysis)
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 ¶
func CorrelateBinlogCoordinates(instance *Instance, binlogCoordinates *BinlogCoordinates, otherInstance *Instance) (*BinlogCoordinates, int, error)
CorrelateBinlogCoordinates find out, if possible, the binlog coordinates of given otherInstance that correlate with given coordinates of given instance.
func CorrelateRelaylogCoordinates ¶
func CorrelateRelaylogCoordinates(instance *Instance, relaylogCoordinates *BinlogCoordinates, otherInstance *Instance) (instanceCoordinates, correlatedCoordinates, nextCoordinates *BinlogCoordinates, found bool, err error)
func FindLastPseudoGTIDEntry ¶
func FindLastPseudoGTIDEntry(instance *Instance, recordedInstanceRelayLogCoordinates BinlogCoordinates, maxBinlogCoordinates *BinlogCoordinates, exhaustiveSearch bool, expectedBinlogFormat *string) (instancePseudoGtidCoordinates *BinlogCoordinates, instancePseudoGtidText string, err 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 ¶
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 replica (instance) and another instance (other). 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 replica of "other".
func GetPreviousKnownRelayLogCoordinatesForInstance ¶
func GetPreviousKnownRelayLogCoordinatesForInstance(instance *Instance) (relayLogCoordinates *BinlogCoordinates, err error)
GetPreviousKnownRelayLogCoordinatesForInstance returns known relay log coordinates, that are not the exact current coordinates
func ParseBinlogCoordinates ¶
func ParseBinlogCoordinates(logFileLogPos string) (*BinlogCoordinates, error)
ParseInstanceKey will parse an InstanceKey from a string representation such as 127.0.0.1:3306
func SearchEntryInBinlog ¶
func SearchEntryInBinlog(pseudoGTIDRegexp *regexp.Regexp, instanceKey *InstanceKey, binlog string, entryText string, monotonicPseudoGTIDEntries bool, minBinlogCoordinates *BinlogCoordinates) (BinlogCoordinates, bool, error)
SearchEntryInBinlog Given a binlog entry text (query), search it in the given binary log of a given instance
func SearchEntryInInstanceBinlogs ¶
func SearchEntryInInstanceBinlogs(instance *Instance, entryText string, monotonicPseudoGTIDEntries bool, minBinlogCoordinates *BinlogCoordinates) (*BinlogCoordinates, error)
SearchEntryInInstanceBinlogs will search for a specific text entry within the binary logs of a given instance.
func SearchEventInRelayLogs ¶
func SearchEventInRelayLogs(searchEvent *BinlogEvent, instance *Instance, minBinlogCoordinates *BinlogCoordinates, recordedInstanceRelayLogCoordinates BinlogCoordinates) (binlogCoordinates, nextCoordinates *BinlogCoordinates, found bool, err error)
func (*BinlogCoordinates) Detach ¶
func (this *BinlogCoordinates) Detach() (detachedCoordinates BinlogCoordinates)
Detach returns a detahced form of coordinates
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) ExtractDetachedCoordinates ¶
func (this *BinlogCoordinates) ExtractDetachedCoordinates() (isDetached bool, detachedCoordinates BinlogCoordinates)
FileSmallerThan returns true if this coordinate's file is strictly smaller than the other's.
func (*BinlogCoordinates) FileNumber ¶
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 ¶
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) IsEmpty ¶
func (this *BinlogCoordinates) IsEmpty() bool
IsEmpty returns true if the log file is empty, unnamed
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 ¶
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) SmallerThanOrEquals ¶
func (this *BinlogCoordinates) SmallerThanOrEquals(other *BinlogCoordinates) bool
SmallerThanOrEquals returns true if this coordinate is the same or equal to the other one. We do NOT compare the type so we can not use this.Equals()
func (BinlogCoordinates) String ¶
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 GetLastExecutedEntryInRelayLogs ¶
func GetLastExecutedEntryInRelayLogs(instance *Instance, minBinlogCoordinates *BinlogCoordinates, recordedInstanceRelayLogCoordinates BinlogCoordinates) (binlogEvent *BinlogEvent, err error)
func ReadBinlogEventAtRelayLogCoordinates ¶
func ReadBinlogEventAtRelayLogCoordinates(instanceKey *InstanceKey, relaylogCoordinates *BinlogCoordinates) (binlogEvent *BinlogEvent, err error)
func (*BinlogEvent) Equals ¶
func (this *BinlogEvent) Equals(other *BinlogEvent) bool
func (*BinlogEvent) EqualsIgnoreCoordinates ¶
func (this *BinlogEvent) EqualsIgnoreCoordinates(other *BinlogEvent) bool
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 CandidateDatabaseInstance ¶
type CandidateDatabaseInstance struct { Hostname string Port int PromotionRule CandidatePromotionRule LastSuggestedString string PromotionRuleExpiry string // generated when retrieved from database for consistency reasons }
CandidateDatabaseInstance contains information about explicit promotion rules for an instance
func BulkReadCandidateDatabaseInstance ¶
func BulkReadCandidateDatabaseInstance() ([]CandidateDatabaseInstance, error)
BulkReadCandidateDatabaseInstance returns a slice of CandidateDatabaseInstance converted to JSON.
root@myorchestrator [orchestrator]> select * from candidate_database_instance; +-------------------+------+---------------------+----------+----------------+ | hostname | port | last_suggested | priority | promotion_rule | +-------------------+------+---------------------+----------+----------------+ | host1.example.com | 3306 | 2016-11-22 17:41:06 | 1 | prefer | | host2.example.com | 3306 | 2016-11-22 17:40:24 | 1 | prefer | +-------------------+------+---------------------+----------+----------------+ 2 rows in set (0.00 sec)
func NewCandidateDatabaseInstance ¶
func NewCandidateDatabaseInstance(instanceKey *InstanceKey, promotionRule CandidatePromotionRule) *CandidateDatabaseInstance
func (*CandidateDatabaseInstance) Key ¶
func (cdi *CandidateDatabaseInstance) Key() *InstanceKey
Key returns an instance key representing this candidate
func (*CandidateDatabaseInstance) String ¶
func (cdi *CandidateDatabaseInstance) String() string
String returns a string representation of the CandidateDatabaseInstance struct
func (*CandidateDatabaseInstance) WithCurrentTime ¶
func (cdi *CandidateDatabaseInstance) WithCurrentTime() *CandidateDatabaseInstance
type CandidatePromotionRule ¶
type CandidatePromotionRule string
CandidatePromotionRule describe the promotion preference/rule for an instance. It maps to promotion_rule column in candidate_database_instance
const ( MustPromoteRule CandidatePromotionRule = "must" PreferPromoteRule CandidatePromotionRule = "prefer" NeutralPromoteRule CandidatePromotionRule = "neutral" PreferNotPromoteRule CandidatePromotionRule = "prefer_not" MustNotPromoteRule CandidatePromotionRule = "must_not" )
func ParseCandidatePromotionRule ¶
func ParseCandidatePromotionRule(ruleName string) (CandidatePromotionRule, error)
ParseCandidatePromotionRule returns a CandidatePromotionRule by name. It returns an error if there is no known rule by the given name.
func (*CandidatePromotionRule) BetterThan ¶
func (this *CandidatePromotionRule) BetterThan(other CandidatePromotionRule) bool
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(clusterName string) ([]ClusterInfo, error)
ReadClustersInfo reads names of all known clusters and some aggregated info
func (*ClusterInfo) ApplyClusterAlias ¶
func (this *ClusterInfo) ApplyClusterAlias()
ApplyClusterAlias updates the given clusterInfo's ClusterAlias property
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)
ReadAllClusterPoolInstances returns all clusters-pools-insatnces associations
func ReadClusterPoolInstances ¶
func ReadClusterPoolInstances(clusterName string, pool string) (result [](*ClusterPoolInstance), err error)
ReadClusterPoolInstances reads cluster-pool-instance associationsfor given cluster and pool
type Downtime ¶
type Downtime struct { Key *InstanceKey Owner string Reason string Duration time.Duration BeginsAt time.Time EndsAt time.Time BeginsAtString string EndsAtString string }
func NewDowntime ¶
func ReadDowntime ¶
type HostnameRegistration ¶
type HostnameRegistration struct { CreatedAt time.Time Key InstanceKey Hostname string }
func NewHostnameDeregistration ¶
func NewHostnameDeregistration(instanceKey *InstanceKey) *HostnameRegistration
func NewHostnameRegistration ¶
func NewHostnameRegistration(instanceKey *InstanceKey, hostname string) *HostnameRegistration
func ReadAllHostnameUnresolvesRegistrations ¶
func ReadAllHostnameUnresolvesRegistrations() (registrations []HostnameRegistration, err error)
ReadAllHostnameUnresolves returns the content of the hostname_unresolve table
type HostnameResolve ¶
type HostnameResolve struct {
// contains filtered or unexported fields
}
func ReadAllHostnameResolves ¶
func ReadAllHostnameResolves() ([]HostnameResolve, error)
func (HostnameResolve) String ¶
func (this HostnameResolve) String() string
type HostnameUnresolve ¶
type HostnameUnresolve struct {
// contains filtered or unexported fields
}
func ReadAllHostnameUnresolves ¶
func ReadAllHostnameUnresolves() ([]HostnameUnresolve, error)
ReadAllHostnameUnresolves returns the content of the hostname_unresolve table
func (HostnameUnresolve) String ¶
func (this HostnameUnresolve) String() string
type Instance ¶
type Instance struct { Key InstanceKey InstanceAlias string Uptime uint ServerID uint ServerUUID string Version string VersionComment string FlavorName string ReadOnly bool Binlog_format string BinlogRowImage string LogBinEnabled bool LogSlaveUpdatesEnabled bool // for API backwards compatibility. Equals `LogReplicationUpdatesEnabled` LogReplicationUpdatesEnabled bool SelfBinlogCoordinates BinlogCoordinates MasterKey InstanceKey MasterUUID string AncestryUUID string IsDetachedMaster bool Slave_SQL_Running bool // for API backwards compatibility. Equals `ReplicationSQLThreadRuning` ReplicationSQLThreadRuning bool Slave_IO_Running bool // for API backwards compatibility. Equals `ReplicationIOThreadRuning` ReplicationIOThreadRuning bool ReplicationSQLThreadState ReplicationThreadState ReplicationIOThreadState ReplicationThreadState HasReplicationFilters bool GTIDMode string 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 GtidPurged string GtidErrant string SlaveLagSeconds sql.NullInt64 // for API backwards compatibility. Equals `ReplicationLagSeconds` ReplicationLagSeconds sql.NullInt64 SlaveHosts InstanceKeyMap // for API backwards compatibility. Equals `Replicas` Replicas InstanceKeyMap ClusterName string SuggestedClusterAlias string DataCenter string Region string PhysicalEnvironment string ReplicationDepth uint IsCoMaster bool HasReplicationCredentials bool ReplicationCredentialsAvailable bool SemiSyncAvailable bool // when both semi sync plugins (master & replica) are loaded SemiSyncEnforced bool SemiSyncMasterEnabled bool SemiSyncReplicaEnabled bool SemiSyncMasterTimeout uint64 SemiSyncMasterWaitForReplicaCount uint SemiSyncMasterStatus bool SemiSyncMasterClients uint SemiSyncReplicaStatus bool LastSeenTimestamp string IsLastCheckValid bool IsUpToDate bool IsRecentlyChecked bool SecondsSinceLastSeen sql.NullInt64 CountMySQLSnapshots int // Careful. IsCandidate and PromotionRule are used together // and probably need to be merged. IsCandidate's value may // be picked up from daabase_candidate_instance's value when // reading an instance from the db. IsCandidate bool PromotionRule CandidatePromotionRule IsDowntimed bool DowntimeReason string DowntimeOwner string DowntimeEndTimestamp string ElapsedDowntime time.Duration UnresolvedHostname string AllowTLS bool Problems []string LastDiscoveryLatency time.Duration // Group replication global variables ReplicationGroupName string ReplicationGroupIsSinglePrimary bool // Replication group members information. See // https://dev.mysql.com/doc/refman/8.0/en/replication-group-members-table.html for details. ReplicationGroupMemberState string ReplicationGroupMemberRole string // List of all known members of the same group ReplicationGroupMembers InstanceKeyMap // Primary of the replication group ReplicationGroupPrimaryInstanceKey InstanceKey // contains filtered or unexported fields }
Instance represents a database instance, including its current configuration & status. It presents important replication configuration and detailed replication status.
func ChangeMasterCredentials ¶
func ChangeMasterCredentials(instanceKey *InstanceKey, creds *ReplicationCredentials) (*Instance, error)
ChangeMasterCredentials issues a CHANGE MASTER TO... MASTER_USER=, MASTER_PASSWORD=...
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 DetachReplicaMasterHost ¶
func DetachReplicaMasterHost(instanceKey *InstanceKey) (*Instance, error)
DetachReplicaMasterHost detaches a replica from its master by corrupting the Master_Host (in such way that is reversible)
func DisableGTID ¶
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 ¶
func EnableGTID(instanceKey *InstanceKey) (*Instance, error)
EnableGTID will attempt to enable GTID-mode (either Oracle or MariaDB)
func EnableMasterSSL ¶
func EnableMasterSSL(instanceKey *InstanceKey) (*Instance, error)
EnableMasterSSL issues CHANGE MASTER TO MASTER_SSL=1
func ErrantGTIDResetMaster ¶
func ErrantGTIDResetMaster(instanceKey *InstanceKey) (instance *Instance, err error)
ErrantGTIDResetMaster will issue a safe RESET MASTER on a replica that replicates via GTID: It will make sure the gtid_purged set matches the executed set value as read just before the RESET. this will enable new replicas to be attached to given instance without complaints about missing/purged entries. This function requires that the instance does not have replicas.
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 ¶
func FlushBinaryLogsTo(instanceKey *InstanceKey, logFile string) (*Instance, error)
FlushBinaryLogsTo attempts to 'FLUSH BINARY LOGS' until given binary log is reached
func GetCandidateReplicaOfBinlogServerTopology ¶
func GetCandidateReplicaOfBinlogServerTopology(masterKey *InstanceKey) (candidateReplica *Instance, err error)
GetCandidateReplicaOfBinlogServerTopology chooses the best replica to promote given a (possibly dead) master
func GetClusterGhostReplicas ¶
GetClusterGhostReplicas returns a list of replicas that can serve as the connected servers for a [gh-ost](https://github.com/github/gh-ost) operation. A gh-ost operation prefers to talk to a RBR replica that has no children.
func GetClusterOSCReplicas ¶
GetClusterOSCReplicas returns a heuristic list of replicas which are fit as controll replicas for an OSC operation. These would be intermediate masters
func GetHeuristicClusterPoolInstances ¶
func GetHeuristicClusterPoolInstances(clusterName string, pool string) (result [](*Instance), err error)
GetHeuristicClusterPoolInstances returns instances of a cluster which are also pooled. If `pool` argument is empty, all pools are considered, otherwise, only instances of given pool are considered.
func GetInstanceMaster ¶
GetInstanceMaster synchronously reaches into the replication topology and retrieves master's data
func GetSortedReplicas ¶
func GetSortedReplicas(masterKey *InstanceKey, stopReplicationMethod StopReplicationMethod) (replicas [](*Instance), err error)
GetSortedReplicas reads list of replicas of a given master, and returns them sorted by exec coordinates (most up-to-date replica first).
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 replica 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 replica above its master, making it replica 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 replicas, 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 replicas (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 ¶
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 ¶
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 NewInstance ¶
func NewInstance() *Instance
func PurgeBinaryLogsTo ¶
func PurgeBinaryLogsTo(instanceKey *InstanceKey, logFile string, force bool) (*Instance, error)
PurgeBinaryLogsTo attempts to 'PURGE BINARY LOGS' until given binary log is reached
func PurgeBinaryLogsToLatest ¶
func PurgeBinaryLogsToLatest(instanceKey *InstanceKey, force bool) (*Instance, error)
PurgeBinaryLogsToLatest attempts to 'PURGE BINARY LOGS' until latest binary log
func ReadBinlogServerReplicaInstances ¶
func ReadBinlogServerReplicaInstances(masterKey *InstanceKey) ([](*Instance), error)
ReadBinlogServerReplicaInstances reads direct replicas 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 ReadClusterMaster ¶
ReadClusterMaster returns the master of this cluster. - if the cluster has co-masters, the/a writable one is returned - if the cluster has a single master, that master is retuened whether it is read-only or writable.
func ReadClusterNeutralPromotionRuleInstances ¶
func ReadClusterNeutralPromotionRuleInstances(clusterName string) (neutralInstances [](*Instance), err error)
ReadClusterNeutralPromotionRuleInstances reads cluster instances whose promotion-rule is marked as 'neutral'
func ReadClusterWriteableMaster ¶
ReadClusterWriteableMaster returns the/a writeable master of this cluster Typically, the cluster name indicates the master of the cluster. However, in circular master-master replication one master can assume the name of the cluster, and it is not guaranteed that it is the writeable one.
func ReadDowntimedInstances ¶
ReadDowntimedInstances returns all instances currently downtimed, potentially filtered by cluster
func ReadFuzzyInstance ¶
func ReadFuzzyInstance(fuzzyInstanceKey *InstanceKey) (*Instance, error)
ReadFuzzyInstance accepts a fuzzy instance key and expects to return a single instance. Multiple instances matching the fuzzy keys are not allowed.
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 ReadLostInRecoveryInstances ¶
ReadLostInRecoveryInstances returns all instances (potentially filtered by cluster) which are currently indicated as downtimed due to being lost during a topology recovery.
func ReadProblemInstances ¶
ReadProblemInstances reads all instances with problems
func ReadReplicaInstances ¶
func ReadReplicaInstances(masterKey *InstanceKey) ([](*Instance), error)
ReadReplicaInstances reads replicas of a given master
func ReadReplicaInstancesIncludingBinlogServerSubReplicas ¶
func ReadReplicaInstancesIncludingBinlogServerSubReplicas(masterKey *InstanceKey) ([](*Instance), error)
ReadReplicaInstancesIncludingBinlogServerSubReplicas returns a list of direct slves including any replicas of a binlog server replica
func ReadTopologyInstance ¶
func ReadTopologyInstance(instanceKey *InstanceKey) (*Instance, error)
ReadTopologyInstance collects information on the state of a MySQL server and writes the result synchronously to the orchestrator backend.
func ReadTopologyInstanceBufferable ¶
func ReadTopologyInstanceBufferable(instanceKey *InstanceKey, bufferWrites bool, latency *stopwatch.NamedStopwatch) (inst *Instance, err error)
ReadTopologyInstanceBufferable connects to a topology MySQL instance and collects information on the server and its replication state. It writes the information retrieved into orchestrator's backend. - writes are optionally buffered. - timing information can be collected for the stages performed.
func ReadUnseenInstances ¶
ReadUnseenInstances reads all instances which were not recently seen
func ReadWriteableClustersMasters ¶
ReadWriteableClustersMasters returns writeable masters of all clusters, but only one per cluster, in similar logic to ReadClusterWriteableMaster
func ReattachReplicaMasterHost ¶
func ReattachReplicaMasterHost(instanceKey *InstanceKey) (*Instance, error)
ReattachReplicaMasterHost reattaches a replica back onto its master by undoing a DetachReplicaMasterHost operation
func RefreshTopologyInstance ¶
func RefreshTopologyInstance(instanceKey *InstanceKey) (*Instance, error)
RefreshTopologyInstance will synchronuously re-read topology instance
func RelocateBelow ¶
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 ¶
removeBinlogServerInstances will remove all binlog servers from given lsit
func RemoveInstance ¶
func RemoveInstance(instances [](*Instance), instanceKey *InstanceKey) [](*Instance)
removeInstance will remove an instance from a list of instances
func RemoveNilInstances ¶
removeNilInstances
func Repoint ¶
func Repoint(instanceKey *InstanceKey, masterKey *InstanceKey, gtidHint OperationGTIDHint) (*Instance, error)
Repoint connects a replica 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 replica - masterKey is not nil: using Binlog servers (coordinates remain the same)
func RepointReplicas ¶
func RepointReplicas(instanceKey *InstanceKey, pattern string) ([](*Instance), error, []error)
RepointReplicas repoints all replicas of a given instance onto its existing master.
func RepointReplicasTo ¶
func RepointReplicasTo(instanceKey *InstanceKey, pattern string, belowKey *InstanceKey) ([](*Instance), error, []error)
RepointReplicasTo repoints replicas of a given instance (possibly filtered) onto another master. Binlog Server is the major use case
func RepointTo ¶
func RepointTo(replicas [](*Instance), belowKey *InstanceKey) ([](*Instance), error, []error)
RepointTo repoints list of replicas onto another master. Binlog Server is the major use case
func ResetMaster ¶
func ResetMaster(instanceKey *InstanceKey) (*Instance, error)
ResetMaster issues a RESET MASTER statement on given instance. Use with extreme care!
func ResetReplication ¶
func ResetReplication(instanceKey *InstanceKey) (*Instance, error)
ResetReplication resets a replica, breaking the replication
func ResetReplicationOperation ¶
func ResetReplicationOperation(instanceKey *InstanceKey) (*Instance, error)
ResetReplicationOperation will reset a replica
func RestartReplication ¶
func RestartReplication(instanceKey *InstanceKey) (instance *Instance, err error)
RestartReplication stops & starts replication on a given instance
func RetryInstanceFunction ¶
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 SetSemiSyncMaster ¶
func SetSemiSyncMaster(instanceKey *InstanceKey, enableMaster bool) (*Instance, error)
func SetSemiSyncReplica ¶
func SetSemiSyncReplica(instanceKey *InstanceKey, enableReplica bool) (*Instance, error)
func SkipQuery ¶
func SkipQuery(instanceKey *InstanceKey) (*Instance, error)
SkipQuery skip a single query in a failed replication instance
func SkipToNextBinaryLog ¶
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 StartReplication ¶
func StartReplication(instanceKey *InstanceKey) (*Instance, error)
StartReplication starts replication on a given instance.
func StartReplicationUntilMasterCoordinates ¶
func StartReplicationUntilMasterCoordinates(instanceKey *InstanceKey, masterCoordinates *BinlogCoordinates) (*Instance, error)
StartReplicationUntilMasterCoordinates issuesa START SLAVE UNTIL... statement on given instance
func StopReplicas ¶
func StopReplicas(replicas [](*Instance), stopReplicationMethod StopReplicationMethod, timeout time.Duration) [](*Instance)
StopReplicas will stop replication concurrently on given set of replicas. It will potentially do nothing, or attempt to stop _nicely_ or just stop normally, all according to stopReplicationMethod
func StopReplicasNicely ¶
StopReplicasNicely will attemt to stop all given replicas nicely, up to timeout
func StopReplication ¶
func StopReplication(instanceKey *InstanceKey) (*Instance, error)
StopReplication stops replication on a given instance
func StopReplicationNicely ¶
func StopReplicationNicely(instanceKey *InstanceKey, timeout time.Duration) (*Instance, error)
StopReplicationNicely stops a replica 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 replica is completely stopped.
func TakeMaster ¶
func TakeMaster(instanceKey *InstanceKey, allowTakingCoMaster bool) (*Instance, error)
TakeMaster will move an instance up the chain and cause its master to become its replica. It's almost a role change, just that other replicas of either 'instance' or its master are currently unaffected (they continue replicate without change) Note that the master must itself be a replica; however the grandparent does not necessarily have to be reachable and can in fact be dead.
func TakeSiblings ¶
func TakeSiblings(instanceKey *InstanceKey) (instance *Instance, takenSiblings int, err error)
TakeSiblings is a convenience method for turning siblings of a replica to be its subordinates. This operation is a syntatctic sugar on top relocate-replicas, which uses any available means to the objective: GTID, Pseudo-GTID, binlog servers, standard replication...
func WaitForExecBinlogCoordinatesToReach ¶
func WaitForExecBinlogCoordinatesToReach(instanceKey *InstanceKey, coordinates *BinlogCoordinates, maxWait time.Duration) (instance *Instance, exactMatch bool, err error)
func (*Instance) AddGroupMemberKey ¶
func (this *Instance) AddGroupMemberKey(groupMemberKey *InstanceKey)
AddGroupMemberKey adds a group member to the list of this instance's group members.
func (*Instance) AddReplicaKey ¶
func (this *Instance) AddReplicaKey(replicaKey *InstanceKey)
AddReplicaKey adds a replica to the list of this instance's replicas.
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) FlavorNameAndMajorVersion ¶
FlavorNameAndMajorVersion returns a string of the combined flavor and major version which is useful in some checks.
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 replica 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 ¶
IsBinlogServer checks whether this is any type of a binlog server (currently only maxscale)
func (*Instance) IsDescendantOf ¶
IsDescendantOf returns true if this is replication directly or indirectly from other
func (*Instance) IsMaster ¶
IsMaster makes simple heuristics to decide whether this instance is a master (not replicating from any other server), either via traditional async/semisync replication or group replication
func (*Instance) IsMasterOf ¶
IsReplicaOf returns true if this i supposed master of given replica
func (*Instance) IsOracleMySQL ¶
IsOracleMySQL checks whether this is an Oracle MySQL distribution
func (*Instance) IsReplica ¶
IsReplica makes simple heuristics to decide whether this instance is a replica of another instance
func (*Instance) IsReplicaOf ¶
IsReplicaOf returns true if this instance claims to replicate from given master
func (*Instance) IsReplicationGroupMember ¶
IsReplicationGroup checks whether the host thinks it is part of a known replication group. Notice that this might return True even if the group has decided to expel the member represented by this instance, as the instance might not know that under certain circumstances
func (*Instance) IsReplicationGroupPrimary ¶
func (*Instance) IsReplicationGroupSecondary ¶
func (*Instance) IsSmallerBinlogFormat ¶
IsSmallerBinlogFormat returns true when this instance's binlgo format is "smaller" than the other's, i.e. binary logs cannot flow from the other instance to this one
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 ¶
IsSmallerMajorVersionByString checks if this instance has a smaller major version number than given one
func (*Instance) LagStatusString ¶
LagStatusString returns a human readable representation of current lag
func (*Instance) MajorVersion ¶
MajorVersion returns this instance's major version number (e.g. for 5.5.36 it returns "5.5")
func (*Instance) MajorVersionString ¶
MajorVersion returns this instance's major version number (e.g. for 5.5.36 it returns "5.5")
func (*Instance) MarshalJSON ¶
func (*Instance) NextGTID ¶
NextGTID returns the next (Oracle) GTID to be executed. Useful for skipping queries
func (*Instance) ReplicaRunning ¶
ReplicaRunning returns true when this instance's status is of a replicating replica.
func (*Instance) ReplicationThreadsExist ¶
NoReplicationThreadRunning returns true when neither SQL nor IO threads are running (including the case where isn't even a replica)
func (*Instance) ReplicationThreadsStopped ¶
NoReplicationThreadRunning returns true when neither SQL nor IO threads are running (including the case where isn't even a replica)
func (*Instance) SQLThreadUpToDate ¶
SQLThreadUpToDate returns true when the instance had consumed all relay logs.
func (*Instance) StatusString ¶
StatusString returns a human readable description of this instance's status
func (*Instance) TabulatedDescription ¶
TabulatedDescription returns a simple tabulated string of various properties
type InstanceAnalysis ¶
type InstanceAnalysis struct {
// contains filtered or unexported fields
}
func NewInstanceAnalysis ¶
func NewInstanceAnalysis(instanceKey *InstanceKey, analysis AnalysisCode) *InstanceAnalysis
func (*InstanceAnalysis) String ¶
func (instanceAnalysis *InstanceAnalysis) String() string
type InstanceBinlogCoordinates ¶
type InstanceBinlogCoordinates struct { Key InstanceKey Coordinates BinlogCoordinates }
InstanceBinlogCoordinates is a convenice wrapper for instance key + binlog coordinates
func GetEquivalentMasterCoordinates ¶
func GetEquivalentMasterCoordinates(instanceCoordinates *InstanceBinlogCoordinates) (result [](*InstanceBinlogCoordinates), err error)
type InstanceKey ¶
InstanceKey is an instance indicator, identifued by hostname and port
func BulkReadInstance ¶
func BulkReadInstance() ([](*InstanceKey), error)
BulkReadInstance returns a list of all instances from the database
- I only need the Hostname and Port fields.
- I must use readInstancesByCondition to ensure all column settings are correct.
func FigureInstanceKey ¶
func FigureInstanceKey(instanceKey *InstanceKey, thisInstanceKey *InstanceKey) (*InstanceKey, error)
FigureInstanceKey tries to figure out a key
func GetHeuristicClusterDomainInstanceAttribute ¶
func GetHeuristicClusterDomainInstanceAttribute(clusterName string) (instanceKey *InstanceKey, err error)
GetHeuristicClusterDomainInstanceAttribute attempts detecting the cluster domain for the given cluster, and return the instance key associated as writer with that domain
func HeuristicallyApplyClusterDomainInstanceAttribute ¶
func HeuristicallyApplyClusterDomainInstanceAttribute(clusterName string) (instanceKey *InstanceKey, err error)
HeuristicallyApplyClusterDomainInstanceAttribute writes down the cluster-domain to master-hostname as a general attribute, by reading current topology and **trusting** it to be correct
func NewRawInstanceKeyStrings ¶
func NewRawInstanceKeyStrings(hostname string, port string) (*InstanceKey, error)
NewResolveInstanceKeyStrings creates and resolves a new instance key based on string params
func NewResolveInstanceKey ¶
func NewResolveInstanceKey(hostname string, port int) (instanceKey *InstanceKey, err error)
func NewResolveInstanceKeyStrings ¶
func NewResolveInstanceKeyStrings(hostname string, port string) (*InstanceKey, error)
NewResolveInstanceKeyStrings creates and resolves a new instance key based on string params
func ParseRawInstanceKey ¶
func ParseRawInstanceKey(hostPort string) (instanceKey *InstanceKey, err error)
func ParseResolveInstanceKey ¶
func ParseResolveInstanceKey(hostPort string) (instanceKey *InstanceKey, err error)
func ReadFuzzyInstanceKey ¶
func ReadFuzzyInstanceKey(fuzzyInstanceKey *InstanceKey) *InstanceKey
ReadFuzzyInstanceKey accepts a fuzzy instance key and expects to return a single, fully qualified, known instance key.
func ReadFuzzyInstanceKeyIfPossible ¶
func ReadFuzzyInstanceKeyIfPossible(fuzzyInstanceKey *InstanceKey) *InstanceKey
ReadFuzzyInstanceKeyIfPossible accepts a fuzzy instance key and hopes to return a single, fully qualified, known instance key, or else the original given key
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 checked) 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) DetachedKey ¶
func (this *InstanceKey) DetachedKey() *InstanceKey
DetachedKey returns an instance key whose hostname is detahced: invalid, but recoverable
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) IsDetached ¶
func (this *InstanceKey) IsDetached() bool
IsDetached returns 'true' when this hostname is logically "detached"
func (*InstanceKey) IsIPv4 ¶
func (this *InstanceKey) IsIPv4() bool
IsValid uses simple heuristics to see whether this key represents an actual instance
func (*InstanceKey) IsValid ¶
func (this *InstanceKey) IsValid() bool
IsValid uses simple heuristics to see whether this key represents an actual instance
func (*InstanceKey) ReattachedKey ¶
func (this *InstanceKey) ReattachedKey() *InstanceKey
ReattachedKey returns an instance key whose hostname is detahced: invalid, but recoverable
func (*InstanceKey) ResolveHostname ¶
func (this *InstanceKey) ResolveHostname() (*InstanceKey, error)
func (*InstanceKey) SmallerThan ¶
func (this *InstanceKey) SmallerThan(other *InstanceKey) bool
SmallerThan returns true if this key is dictionary-smaller than another. This is used for consistent sorting/ordering; there's nothing magical about it.
func (InstanceKey) String ¶
func (this InstanceKey) String() string
String returns a user-friendly string representation of this key
func (*InstanceKey) StringCode ¶
func (this *InstanceKey) StringCode() string
StringCode returns an official string representation of this key
type InstanceKeyMap ¶
type InstanceKeyMap map[InstanceKey]bool
InstanceKeyMap is a convenience struct for listing InstanceKey-s
func GetInstanceKeysByTag ¶
func GetInstanceKeysByTag(tag *Tag) (tagged *InstanceKeyMap, err error)
func GetInstanceKeysByTags ¶
func GetInstanceKeysByTags(tagsString string) (tagged *InstanceKeyMap, err error)
func NewInstanceKeyMap ¶
func NewInstanceKeyMap() *InstanceKeyMap
func Untag ¶
func Untag(instanceKey *InstanceKey, tag *Tag) (tagged *InstanceKeyMap, err error)
func (*InstanceKeyMap) AddInstances ¶
func (this *InstanceKeyMap) AddInstances(instances [](*Instance))
AddInstances adds keys of all given instances to this map
func (*InstanceKeyMap) AddKey ¶
func (this *InstanceKeyMap) AddKey(key InstanceKey)
AddKey adds a single key to this map
func (*InstanceKeyMap) AddKeys ¶
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) HasKey ¶
func (this *InstanceKeyMap) HasKey(key InstanceKey) bool
HasKey checks if given key is within the map
func (*InstanceKeyMap) Intersect ¶
func (this *InstanceKeyMap) Intersect(other *InstanceKeyMap) *InstanceKeyMap
Intersect returns a keymap which is the intersection of this and another map
func (InstanceKeyMap) MarshalJSON ¶
func (this InstanceKeyMap) MarshalJSON() ([]byte, error)
MarshalJSON will marshal this map as JSON
func (*InstanceKeyMap) ReadCommaDelimitedList ¶
func (this *InstanceKeyMap) ReadCommaDelimitedList(list string) error
ReadJson unmarshalls a json into this map
func (*InstanceKeyMap) ReadJson ¶
func (this *InstanceKeyMap) ReadJson(jsonString string) error
ReadJson unmarshalls a json into this map
func (*InstanceKeyMap) ToCommaDelimitedList ¶
func (this *InstanceKeyMap) ToCommaDelimitedList() string
ToCommaDelimitedList will export this map in comma delimited format
func (*InstanceKeyMap) ToJSON ¶
func (this *InstanceKeyMap) ToJSON() (string, error)
ToJSON will marshal this map as JSON
func (*InstanceKeyMap) ToJSONString ¶
func (this *InstanceKeyMap) ToJSONString() string
ToJSONString will marshal this map as JSON
func (*InstanceKeyMap) UnmarshalJSON ¶
func (this *InstanceKeyMap) UnmarshalJSON(b []byte) error
UnmarshalJSON reds this object from JSON
type InstanceTag ¶
type InstanceTag struct { Key InstanceKey T Tag }
type InstancesByCountReplicas ¶
type InstancesByCountReplicas [](*Instance)
InstancesByCountReplicas is a sortable type for Instance
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 InstancesSorterByExec ¶
type InstancesSorterByExec struct {
// contains filtered or unexported fields
}
InstancesSorterByExec sorts instances by executed binlog coordinates
func NewInstancesSorterByExec ¶
func NewInstancesSorterByExec(instances [](*Instance), dataCenter string) *InstancesSorterByExec
func (*InstancesSorterByExec) Len ¶
func (this *InstancesSorterByExec) Len() int
func (*InstancesSorterByExec) Less ¶
func (this *InstancesSorterByExec) Less(i, j int) bool
func (*InstancesSorterByExec) Swap ¶
func (this *InstancesSorterByExec) 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 MinimalInstance ¶
type MinimalInstance struct { Key InstanceKey MasterKey InstanceKey ClusterName string }
func ReadAllMinimalInstances ¶
func ReadAllMinimalInstances() ([]MinimalInstance, error)
ReadAllInstanceKeysMasterKeys
func (*MinimalInstance) ToInstance ¶
func (this *MinimalInstance) ToInstance() *Instance
type OperationGTIDHint ¶
type OperationGTIDHint string
type OracleGtidSet ¶
type OracleGtidSet struct {
GtidEntries [](*OracleGtidSetEntry)
}
OracleGtidSet represents a set of GTID ranges as depicted by Retrieved_Gtid_Set, Executed_Gtid_Set or @@gtid_purged.
func GetPreviousGTIDs ¶
func GetPreviousGTIDs(instanceKey *InstanceKey, binlog string) (previousGTIDs *OracleGtidSet, err error)
func NewOracleGtidSet ¶
func NewOracleGtidSet(gtidSet string) (res *OracleGtidSet, err error)
Example input: `230ea8ea-81e3-11e4-972a-e25ec4bd140a:1-10539, 316d193c-70e5-11e5-adb2-ecf4bb2262ff:1-8935:8984-6124596, 321f5c0d-70e5-11e5-adb2-ecf4bb2262ff:1-56`
func (*OracleGtidSet) Explode ¶
func (this *OracleGtidSet) Explode() (result [](*OracleGtidSetEntry))
String returns a user-friendly string representation of this entry
func (*OracleGtidSet) IsEmpty ¶
func (this *OracleGtidSet) IsEmpty() bool
func (*OracleGtidSet) RemoveUUID ¶
func (this *OracleGtidSet) RemoveUUID(uuid string) (removed bool)
RemoveUUID removes entries that belong to given UUID. By way of how this works there can only be one entry matching our UUID, but we generalize. We keep order of entries.
func (*OracleGtidSet) RetainUUID ¶
func (this *OracleGtidSet) RetainUUID(uuid string) (anythingRemoved bool)
RetainUUID retains only entries that belong to given UUID.
func (*OracleGtidSet) RetainUUIDs ¶
func (this *OracleGtidSet) RetainUUIDs(uuids []string) (anythingRemoved bool)
RetainUUIDs retains only entries that belong to given UUIDs.
func (*OracleGtidSet) SharedUUIDs ¶
func (this *OracleGtidSet) SharedUUIDs(other *OracleGtidSet) (shared []string)
SharedUUIDs returns UUIDs (range-less) that are shared between the two sets
func (*OracleGtidSet) String ¶
func (this *OracleGtidSet) String() string
type OracleGtidSetEntry ¶
OracleGtidSetEntry represents an entry in a set of GTID ranges, for example, the entry: "316d193c-70e5-11e5-adb2-ecf4bb2262ff:1-8935:8984-6124596" (may include gaps)
func NewOracleGtidSetEntry ¶
func NewOracleGtidSetEntry(gtidRangeString string) (*OracleGtidSetEntry, error)
NewOracleGtidSetEntry parses a single entry text
func (*OracleGtidSetEntry) Explode ¶
func (this *OracleGtidSetEntry) Explode() (result [](*OracleGtidSetEntry))
String returns a user-friendly string representation of this entry
func (*OracleGtidSetEntry) String ¶
func (this *OracleGtidSetEntry) String() string
String returns a user-friendly string representation of this entry
type PeerAnalysisMap ¶
PeerAnalysisMap indicates the number of peers agreeing on an analysis. Key of this map is a InstanceAnalysis.String()
func ReadPeerAnalysisMap ¶
func ReadPeerAnalysisMap() (peerAnalysisMap PeerAnalysisMap, err error)
ReadPeerAnalysisMap reads raft-peer failure analysis, and returns a PeerAnalysisMap, indicating how many peers see which analysis
type PoolInstancesMap ¶
type PoolInstancesMap map[string]([]*InstanceKey)
PoolInstancesMap lists instance keys per pool name
func ReadClusterPoolInstancesMap ¶
func ReadClusterPoolInstancesMap(clusterName string, pool string) (*PoolInstancesMap, error)
ReadClusterPoolInstancesMap returns association of pools-to-instances for a given cluster and potentially for a given pool.
type PoolInstancesSubmission ¶
type PoolInstancesSubmission struct { CreatedAt time.Time Pool string DelimitedInstances string RegisteredAt string }
func NewPoolInstancesSubmission ¶
func NewPoolInstancesSubmission(pool string, instances string) *PoolInstancesSubmission
func ReadAllPoolInstancesSubmissions ¶
func ReadAllPoolInstancesSubmissions() ([]PoolInstancesSubmission, error)
type PostponedFunctionsContainer ¶
type PostponedFunctionsContainer struct {
// contains filtered or unexported fields
}
func NewPostponedFunctionsContainer ¶
func NewPostponedFunctionsContainer() *PostponedFunctionsContainer
func (*PostponedFunctionsContainer) AddPostponedFunction ¶
func (this *PostponedFunctionsContainer) AddPostponedFunction(postponedFunction func() error, description string)
func (*PostponedFunctionsContainer) Descriptions ¶
func (this *PostponedFunctionsContainer) Descriptions() []string
func (*PostponedFunctionsContainer) Len ¶
func (this *PostponedFunctionsContainer) Len() int
func (*PostponedFunctionsContainer) Wait ¶
func (this *PostponedFunctionsContainer) Wait()
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)
type ReplicationAnalysis ¶
type ReplicationAnalysis struct { AnalyzedInstanceKey InstanceKey AnalyzedInstanceMasterKey InstanceKey ClusterDetails ClusterInfo AnalyzedInstanceDataCenter string AnalyzedInstanceRegion string AnalyzedInstancePhysicalEnvironment string AnalyzedInstanceBinlogCoordinates BinlogCoordinates IsMaster bool IsReplicationGroupMember bool IsCoMaster bool LastCheckValid bool LastCheckPartialSuccess bool CountReplicas uint CountValidReplicas uint CountValidReplicatingReplicas uint CountReplicasFailingToConnectToMaster uint CountDowntimedReplicas uint ReplicationDepth uint Replicas InstanceKeyMap SlaveHosts InstanceKeyMap // for backwards compatibility. Equals `Replicas` IsFailingToConnectToMaster bool Analysis AnalysisCode Description string StructureAnalysis []AnalysisCode IsDowntimed bool IsReplicasDowntimed bool // as good as downtimed because all replicas are downtimed AND analysis is all about the replicas (e.e. AllMasterReplicasNotReplicating) DowntimeEndTimestamp string DowntimeRemainingSeconds int IsBinlogServer bool PseudoGTIDImmediateTopology bool OracleGTIDImmediateTopology bool MariaDBGTIDImmediateTopology bool BinlogServerImmediateTopology bool SemiSyncMasterEnabled bool SemiSyncMasterStatus bool SemiSyncMasterWaitForReplicaCount uint SemiSyncMasterClients uint CountSemiSyncReplicasEnabled uint CountLoggingReplicas uint CountStatementBasedLoggingReplicas uint CountMixedBasedLoggingReplicas uint CountRowBasedLoggingReplicas uint CountDistinctMajorVersionsLoggingReplicas uint CountDelayedReplicas uint CountLaggingReplicas uint IsActionableRecovery bool ProcessingNodeHostname string ProcessingNodeToken string CountAdditionalAgreeingNodes int StartActivePeriod string SkippableDueToDowntime bool GTIDMode string MinReplicaGTIDMode string MaxReplicaGTIDMode string MaxReplicaGTIDErrant string CommandHint string IsReadOnly bool }
ReplicationAnalysis notes analysis on replication chain status, per instance
func GetReplicationAnalysis ¶
func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) ([]ReplicationAnalysis, error)
GetReplicationAnalysis will check for replication problems (dead master; unreachable master; etc)
func (*ReplicationAnalysis) AnalysisString ¶
func (this *ReplicationAnalysis) AnalysisString() string
AnalysisString returns a human friendly description of all analysis issues
func (*ReplicationAnalysis) GetAnalysisInstanceType ¶
func (this *ReplicationAnalysis) GetAnalysisInstanceType() AnalysisInstanceType
Get a string description of the analyzed instance type (master? co-master? intermediate-master?)
func (*ReplicationAnalysis) MarshalJSON ¶
func (this *ReplicationAnalysis) MarshalJSON() ([]byte, error)
func (*ReplicationAnalysis) ReadReplicaHostsFromString ¶
func (this *ReplicationAnalysis) ReadReplicaHostsFromString(replicaHostsString string) error
ReadReplicaHostsFromString parses and reads replica keys from comma delimited string
type ReplicationAnalysisChangelog ¶
type ReplicationAnalysisChangelog struct { AnalyzedInstanceKey InstanceKey Changelog []string }
func ReadReplicationAnalysisChangelog ¶
func ReadReplicationAnalysisChangelog() (res [](*ReplicationAnalysisChangelog), err error)
ReadReplicationAnalysisChangelog
type ReplicationCredentials ¶
type ReplicationCredentials struct { User string Password string SSLCert string SSLKey string SSLCaCert string }
func ReadReplicationCredentials ¶
func ReadReplicationCredentials(instanceKey *InstanceKey) (creds *ReplicationCredentials, err error)
Attempt to read and return replication credentials from the mysql.slave_master_info system table
type ReplicationThreadState ¶
type ReplicationThreadState int
func ReplicationThreadStateFromStatus ¶
func ReplicationThreadStateFromStatus(status string) ReplicationThreadState
func (*ReplicationThreadState) Exists ¶
func (this *ReplicationThreadState) Exists() bool
func (*ReplicationThreadState) IsRunning ¶
func (this *ReplicationThreadState) IsRunning() bool
func (*ReplicationThreadState) IsStopped ¶
func (this *ReplicationThreadState) IsStopped() bool
type StopReplicationMethod ¶
type StopReplicationMethod string
type Tag ¶
func ParseIntersectTags ¶
func ReadInstanceTags ¶
func ReadInstanceTags(instanceKey *InstanceKey) (tags [](*Tag), err error)
type WriteBufferMetric ¶
type WriteBufferMetric struct { Timestamp time.Time // time the metric was started Instances int // number of flushed instances WaitLatency time.Duration // waiting before flush WriteLatency time.Duration // time writing to backend }
Metric records query metrics of backend writes that go through a sized channel. It allows us to compare the time waiting to execute the query against the time needed to run it and in a "sized channel" the wait time may be significant and is good to measure.
func (WriteBufferMetric) When ¶
func (m WriteBufferMetric) When() time.Time
When records the timestamp of the start of the recording
Source Files ¶
- analysis.go
- analysis_dao.go
- audit.go
- audit_dao.go
- binlog.go
- candidate_database_instance.go
- candidate_database_instance_dao.go
- cluster.go
- cluster_alias.go
- cluster_alias_dao.go
- cluster_domain_dao.go
- downtime.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_topology_dao.go
- instance_utils.go
- maintenance.go
- maintenance_dao.go
- master_equivalence.go
- master_equivalence_dao.go
- minimal_instance.go
- oracle_gtid_set.go
- oracle_gtid_set_entry.go
- pool.go
- pool_dao.go
- postponed_functions.go
- process.go
- promotion_rule.go
- replication_thread_state.go
- resolve.go
- resolve_dao.go
- tag.go
- tag_dao.go
- write_buffer.go