Documentation ¶
Index ¶
- Constants
- Variables
- func ExecOrchestrator(query string, args ...any) (sql.Result, error)
- func IsSQLite() bool
- func OpenDiscovery(host string, port int) (*sql.DB, error)
- func OpenOrchestrator() (db *sql.DB, err error)
- func OpenTopology(host string, port int) (*sql.DB, error)
- func QueryOrchestrator(query string, argsArray []any, onRow func(sqlutils.RowMap) error) error
- func SetupMySQLOrchestratorTLS(uri string) (string, error)
- func SetupMySQLTopologyTLS(uri string) (string, error)
- type Agent
- type DB
- type DummySQLResult
- type GroupMember
- type GroupView
- type MemberRole
- type MemberState
- type MockAgent
- func (m *MockAgent) BootstrapGroupLocked(instanceKey *inst.InstanceKey) error
- func (m *MockAgent) EXPECT() *MockAgentMockRecorder
- func (m *MockAgent) Failover(instance *inst.InstanceKey) error
- func (m *MockAgent) FetchApplierGTIDSet(instanceKey *inst.InstanceKey) (mysql.GTIDSet, error)
- func (m *MockAgent) FetchGroupView(alias string, instanceKey *inst.InstanceKey) (*GroupView, error)
- func (m *MockAgent) JoinGroupLocked(instanceKey, primaryKey *inst.InstanceKey) error
- func (m *MockAgent) RebootstrapGroupLocked(instanceKey *inst.InstanceKey, name string) error
- func (m *MockAgent) SetReadOnly(instanceKey *inst.InstanceKey, readOnly bool) error
- func (m *MockAgent) StopGroupLocked(instanceKey *inst.InstanceKey) error
- type MockAgentMockRecorder
- func (mr *MockAgentMockRecorder) BootstrapGroupLocked(instanceKey any) *gomock.Call
- func (mr *MockAgentMockRecorder) Failover(instance any) *gomock.Call
- func (mr *MockAgentMockRecorder) FetchApplierGTIDSet(instanceKey any) *gomock.Call
- func (mr *MockAgentMockRecorder) FetchGroupView(alias, instanceKey any) *gomock.Call
- func (mr *MockAgentMockRecorder) JoinGroupLocked(instanceKey, primaryKey any) *gomock.Call
- func (mr *MockAgentMockRecorder) RebootstrapGroupLocked(instanceKey, name any) *gomock.Call
- func (mr *MockAgentMockRecorder) SetReadOnly(instanceKey, readOnly any) *gomock.Call
- func (mr *MockAgentMockRecorder) StopGroupLocked(instanceKey any) *gomock.Call
- type SQLAgentImpl
- func (agent *SQLAgentImpl) BootstrapGroupLocked(instanceKey *inst.InstanceKey) error
- func (agent *SQLAgentImpl) Failover(instance *inst.InstanceKey) error
- func (agent *SQLAgentImpl) FetchApplierGTIDSet(instanceKey *inst.InstanceKey) (mysql.GTIDSet, error)
- func (agent *SQLAgentImpl) FetchGroupView(alias string, instanceKey *inst.InstanceKey) (*GroupView, error)
- func (agent *SQLAgentImpl) JoinGroupLocked(instanceKey *inst.InstanceKey, primaryInstanceKey *inst.InstanceKey) error
- func (agent *SQLAgentImpl) RebootstrapGroupLocked(instanceKey *inst.InstanceKey, name string) error
- func (agent *SQLAgentImpl) SetReadOnly(instanceKey *inst.InstanceKey, readOnly bool) error
- func (agent *SQLAgentImpl) StopGroupLocked(instanceKey *inst.InstanceKey) error
- type TestGroupState
Constants ¶
const Error1045 = "Access denied for user"
const Error3159 = "Error 3159:"
Variables ¶
var ( // ErrGroupSplitBrain is the error when mysql group is split-brain ErrGroupSplitBrain = errors.New("group has split brain") // ErrGroupBackoffError is either the transient error or network partition from the group ErrGroupBackoffError = errors.New("group backoff error") // ErrGroupOngoingBootstrap is the error when a bootstrap is in progress ErrGroupOngoingBootstrap = errors.New("group ongoing bootstrap") // ErrGroupInactive is the error when mysql group is inactive unexpectedly ErrGroupInactive = errors.New("group is inactive") // ErrInvalidInstance is the error when the instance key has empty hostname ErrInvalidInstance = errors.New("invalid mysql instance key") )
Functions ¶
func ExecOrchestrator ¶ added in v0.15.0
ExecOrchestrator will execute given query on the orchestrator backend database.
func OpenDiscovery ¶ added in v0.15.0
OpenDiscovery returns a DB instance to access a topology instance. It has lower read timeout than OpenTopology and is intended to be used with low-latency discovery queries.
func OpenOrchestrator ¶ added in v0.15.0
OpenTopology returns the DB instance for the orchestrator backed database
func OpenTopology ¶ added in v0.15.0
OpenTopology returns a DB instance to access a topology instance.
func QueryOrchestrator ¶ added in v0.15.0
QueryOrchestrator
func SetupMySQLOrchestratorTLS ¶ added in v0.15.0
SetupMySQLOrchestratorTLS creates a TLS configuration from the config supplied CA, Certificate, and Private key. Register the TLS config with the mysql drivers as the "orchestrator" config Modify the supplied URI to call the TLS config
func SetupMySQLTopologyTLS ¶ added in v0.15.0
SetupMySQLTopologyTLS creates a TLS configuration from the config supplied CA, Certificate, and Private key. Register the TLS config with the mysql drivers as the "topology" config Modify the supplied URI to call the TLS config
Types ¶
type Agent ¶
type Agent interface { // BootstrapGroupLocked bootstraps a mysql group // the caller should grab a lock before BootstrapGroupLocked(instanceKey *inst.InstanceKey) error // RebootstrapGroupLocked rebootstrap a group with an existing name RebootstrapGroupLocked(instanceKey *inst.InstanceKey, name string) error // StopGroupLocked stops a mysql group StopGroupLocked(instanceKey *inst.InstanceKey) error // JoinGroupLocked puts an instance into a mysql group based on primary instance // the caller should grab a lock before JoinGroupLocked(instanceKey *inst.InstanceKey, primaryKey *inst.InstanceKey) error // SetReadOnly set super_read_only variable // https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_super_read_only SetReadOnly(instanceKey *inst.InstanceKey, readOnly bool) error // FetchApplierGTIDSet fetches the GTID set from group_replication_applier channel FetchApplierGTIDSet(instanceKey *inst.InstanceKey) (mysql.GTIDSet, error) // Failover move the mysql primary to the node defined by memberUUID Failover(instance *inst.InstanceKey) error // FetchGroupView fetches group related information FetchGroupView(alias string, instanceKey *inst.InstanceKey) (*GroupView, error) }
Agent is used by vtgr to interact with Mysql
type DB ¶ added in v0.15.0
type DummySQLResult ¶ added in v0.15.0
type DummySQLResult struct { }
func (DummySQLResult) LastInsertId ¶ added in v0.15.0
func (dummyRes DummySQLResult) LastInsertId() (int64, error)
func (DummySQLResult) RowsAffected ¶ added in v0.15.0
func (dummyRes DummySQLResult) RowsAffected() (int64, error)
type GroupMember ¶
type GroupMember struct { HostName string Port int Role MemberRole State MemberState ReadOnly bool }
GroupMember represents a ROW we get from performance_schema
func NewGroupMember ¶
func NewGroupMember(state, role, host string, port int, readonly bool) *GroupMember
NewGroupMember creates a new GroupMember
type GroupView ¶
type GroupView struct { TabletAlias string MySQLHost string MySQLPort int GroupName string HeartbeatStaleness int UnresolvedMembers []*GroupMember }
GroupView is an instance's view for the group
func BuildGroupView ¶
func BuildGroupView(alias, groupName, host string, port int, readOnly bool, stalenessResult int, inputs []TestGroupState) *GroupView
BuildGroupView builds gruop view from input
func NewGroupView ¶
NewGroupView creates a new GroupView
func (*GroupView) CreateInstanceKey ¶
func (view *GroupView) CreateInstanceKey(member *GroupMember) inst.InstanceKey
CreateInstanceKey returns an InstanceKey based on group member input When the group is init for the first time, the hostname and port are not set, e.g., +---------------------------+-----------+-------------+-------------+--------------+-------------+ | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | +---------------------------+-----------+-------------+-------------+--------------+-------------+ | group_replication_applier | | | NULL | OFFLINE | | +---------------------------+-----------+-------------+-------------+--------------+-------------+ therefore we substitute with view's local hostname and port
func (*GroupView) GetPrimaryView ¶
GetPrimaryView returns the view of primary member
type MemberRole ¶
type MemberRole int
MemberRole is member role
const ( UNKNOWNROLE MemberRole = iota SECONDARY PRIMARY )
func (MemberRole) String ¶
func (role MemberRole) String() string
type MemberState ¶
type MemberState int
MemberState is member state
const ( UNKNOWNSTATE MemberState = iota OFFLINE UNREACHABLE RECOVERING ONLINE ERROR )
func (MemberState) String ¶
func (state MemberState) String() string
type MockAgent ¶
type MockAgent struct {
// contains filtered or unexported fields
}
MockAgent is a mock of Agent interface
func NewMockAgent ¶
func NewMockAgent(ctrl *gomock.Controller) *MockAgent
NewMockAgent creates a new mock instance
func (*MockAgent) BootstrapGroupLocked ¶
func (m *MockAgent) BootstrapGroupLocked(instanceKey *inst.InstanceKey) error
BootstrapGroupLocked mocks base method
func (*MockAgent) EXPECT ¶
func (m *MockAgent) EXPECT() *MockAgentMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockAgent) Failover ¶
func (m *MockAgent) Failover(instance *inst.InstanceKey) error
Failover mocks base method
func (*MockAgent) FetchApplierGTIDSet ¶
FetchApplierGTIDSet mocks base method
func (*MockAgent) FetchGroupView ¶
FetchGroupView mocks base method
func (*MockAgent) JoinGroupLocked ¶
func (m *MockAgent) JoinGroupLocked(instanceKey, primaryKey *inst.InstanceKey) error
JoinGroupLocked mocks base method
func (*MockAgent) RebootstrapGroupLocked ¶
func (m *MockAgent) RebootstrapGroupLocked(instanceKey *inst.InstanceKey, name string) error
RebootstrapGroupLocked mocks base method
func (*MockAgent) SetReadOnly ¶
func (m *MockAgent) SetReadOnly(instanceKey *inst.InstanceKey, readOnly bool) error
SetReadOnly mocks base method
func (*MockAgent) StopGroupLocked ¶
func (m *MockAgent) StopGroupLocked(instanceKey *inst.InstanceKey) error
StopGroupLocked mocks base method
type MockAgentMockRecorder ¶
type MockAgentMockRecorder struct {
// contains filtered or unexported fields
}
MockAgentMockRecorder is the mock recorder for MockAgent
func (*MockAgentMockRecorder) BootstrapGroupLocked ¶
func (mr *MockAgentMockRecorder) BootstrapGroupLocked(instanceKey any) *gomock.Call
BootstrapGroupLocked indicates an expected call of BootstrapGroupLocked
func (*MockAgentMockRecorder) Failover ¶
func (mr *MockAgentMockRecorder) Failover(instance any) *gomock.Call
Failover indicates an expected call of Failover
func (*MockAgentMockRecorder) FetchApplierGTIDSet ¶
func (mr *MockAgentMockRecorder) FetchApplierGTIDSet(instanceKey any) *gomock.Call
FetchApplierGTIDSet indicates an expected call of FetchApplierGTIDSet
func (*MockAgentMockRecorder) FetchGroupView ¶
func (mr *MockAgentMockRecorder) FetchGroupView(alias, instanceKey any) *gomock.Call
FetchGroupView indicates an expected call of FetchGroupView
func (*MockAgentMockRecorder) JoinGroupLocked ¶
func (mr *MockAgentMockRecorder) JoinGroupLocked(instanceKey, primaryKey any) *gomock.Call
JoinGroupLocked indicates an expected call of JoinGroupLocked
func (*MockAgentMockRecorder) RebootstrapGroupLocked ¶
func (mr *MockAgentMockRecorder) RebootstrapGroupLocked(instanceKey, name any) *gomock.Call
RebootstrapGroupLocked indicates an expected call of RebootstrapGroupLocked
func (*MockAgentMockRecorder) SetReadOnly ¶
func (mr *MockAgentMockRecorder) SetReadOnly(instanceKey, readOnly any) *gomock.Call
SetReadOnly indicates an expected call of SetReadOnly
func (*MockAgentMockRecorder) StopGroupLocked ¶
func (mr *MockAgentMockRecorder) StopGroupLocked(instanceKey any) *gomock.Call
StopGroupLocked indicates an expected call of StopGroupLocked
type SQLAgentImpl ¶
type SQLAgentImpl struct {
// contains filtered or unexported fields
}
SQLAgentImpl implements Agent
func (*SQLAgentImpl) BootstrapGroupLocked ¶
func (agent *SQLAgentImpl) BootstrapGroupLocked(instanceKey *inst.InstanceKey) error
BootstrapGroupLocked implements Agent interface
func (*SQLAgentImpl) Failover ¶
func (agent *SQLAgentImpl) Failover(instance *inst.InstanceKey) error
Failover implements Agent interface
func (*SQLAgentImpl) FetchApplierGTIDSet ¶
func (agent *SQLAgentImpl) FetchApplierGTIDSet(instanceKey *inst.InstanceKey) (mysql.GTIDSet, error)
FetchApplierGTIDSet implements Agent interface
func (*SQLAgentImpl) FetchGroupView ¶
func (agent *SQLAgentImpl) FetchGroupView(alias string, instanceKey *inst.InstanceKey) (*GroupView, error)
FetchGroupView implements Agent interface
func (*SQLAgentImpl) JoinGroupLocked ¶
func (agent *SQLAgentImpl) JoinGroupLocked(instanceKey *inst.InstanceKey, primaryInstanceKey *inst.InstanceKey) error
JoinGroupLocked implements Agent interface Note: caller should grab the lock before calling this
func (*SQLAgentImpl) RebootstrapGroupLocked ¶
func (agent *SQLAgentImpl) RebootstrapGroupLocked(instanceKey *inst.InstanceKey, name string) error
func (*SQLAgentImpl) SetReadOnly ¶
func (agent *SQLAgentImpl) SetReadOnly(instanceKey *inst.InstanceKey, readOnly bool) error
SetReadOnly implements Agent interface
func (*SQLAgentImpl) StopGroupLocked ¶
func (agent *SQLAgentImpl) StopGroupLocked(instanceKey *inst.InstanceKey) error
StopGroupLocked implements Agent interface
type TestGroupState ¶
type TestGroupState struct {
MemberHost, MemberPort, MemberState, MemberRole string
}
TestGroupState mocks a row from mysql