controller

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Code generated by MockGen. DO NOT EDIT. Source: go/vt/vtgr/controller/refresh.go

Index

Constants

View Source
const (
	// DiagnoseTypeError represents an DiagnoseTypeError status
	DiagnoseTypeError DiagnoseType = "error"
	// DiagnoseTypeHealthy represents everything is DiagnoseTypeHealthy
	DiagnoseTypeHealthy = "Healthy"
	// DiagnoseTypeShardHasNoGroup represents the cluster has not init yet
	DiagnoseTypeShardHasNoGroup = "ShardHasNoGroup"
	// DiagnoseTypeShardHasInactiveGroup represents the status where we have a group name but no member in it
	DiagnoseTypeShardHasInactiveGroup = "ShardHasInactiveGroup"
	// DiagnoseTypeInsufficientGroupSize represents the cluster has insufficient group members
	DiagnoseTypeInsufficientGroupSize = "InsufficientGroupSize"
	// DiagnoseTypeReadOnlyShard represents the cluster who has a read only node
	DiagnoseTypeReadOnlyShard = "ReadOnlyShard"
	// DiagnoseTypeUnreachablePrimary represents the primary tablet is unreachable
	DiagnoseTypeUnreachablePrimary = "UnreachablePrimary"
	// DiagnoseTypeWrongPrimaryTablet represents the primary tablet is incorrect based on mysql group
	DiagnoseTypeWrongPrimaryTablet = "WrongPrimaryTablet"
	// DiagnoseTypeUnconnectedReplica represents cluster with primary tablet, but a node is not connected to it
	DiagnoseTypeUnconnectedReplica = "UnconnectedReplica"
	// DiagnoseTypeBackoffError represents a transient error e.g., the primary is unreachable
	DiagnoseTypeBackoffError = "BackoffError"
	// DiagnoseTypeBootstrapBackoff represents an ongoing bootstrap
	DiagnoseTypeBootstrapBackoff = "BootstrapBackoff"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DiagnoseType

type DiagnoseType string

DiagnoseType is the types of Diagnose result

type GRShard

type GRShard struct {
	KeyspaceShard *topo.KeyspaceShard

	// lock prevents multiple go routine fights with each other
	sync.Mutex
	// contains filtered or unexported fields
}

GRShard stores the information about a Vitess shard that's running MySQL GR

func NewGRShard

func NewGRShard(
	keyspace, shard string,
	cells []string,
	tmc GRTmcClient,
	ts GRTopo,
	dbAgent db.Agent,
	config *config.VTGRConfig,
	localDbPort int,
	isActive bool) *GRShard

NewGRShard creates a new GRShard

func (*GRShard) Diagnose

func (shard *GRShard) Diagnose(ctx context.Context) (DiagnoseType, error)

Diagnose the shard in the following order: TODO: use FSM to make sure the status transition is correct 1. if the shard has a group that every node agreed on 2. if the group has any active (online / recovering) member 3. if the shard has initialized a Vitess primary 4. if primary tablet is reachable 5. if Vitess primary and mysql primary reconciled 6. if we have enough group members 7. if the primary node has read_only=OFF 8. if there is a node that is not in Mysql group

func (*GRShard) Failover

func (shard *GRShard) Failover(ctx context.Context) error

Failover takes a shard and find an node with largest GTID as the mysql primary of the group

func (*GRShard) GetCurrentShardStatuses

func (shard *GRShard) GetCurrentShardStatuses() ShardStatus

GetCurrentShardStatuses returns the status collector has

func (*GRShard) GetUnlock

func (shard *GRShard) GetUnlock() func(*error)

GetUnlock returns the unlock function for the shard for testing

func (*GRShard) LockShard

func (shard *GRShard) LockShard(ctx context.Context, action string) (context.Context, error)

LockShard locks the keyspace-shard on topo server to prevent others from executing conflicting actions.

func (*GRShard) OverrideRebootstrapGroupSize added in v0.13.0

func (shard *GRShard) OverrideRebootstrapGroupSize(groupSize int) error

OverrideRebootstrapGroupSize force override the group expectedBootstrapSize used in safety check for rebootstrap

func (*GRShard) Repair

func (shard *GRShard) Repair(ctx context.Context, status DiagnoseType) (RepairResultCode, error)

Repair tries to fix shard based on the diagnose type

func (*GRShard) ScanAndRepairShard

func (shard *GRShard) ScanAndRepairShard(ctx context.Context)

ScanAndRepairShard scans a particular shard by first Diagnose the shard with info from grShard and then repair the probelm if the shard is unhealthy

func (*GRShard) SetIsActive

func (shard *GRShard) SetIsActive(isActive bool)

SetIsActive sets isActive for the shard

func (*GRShard) UnlockShard

func (shard *GRShard) UnlockShard()

UnlockShard unlocks the keyspace-shard on topo server and set the unlock function to nil in the container

func (*GRShard) UpdateTabletsInShardWithLock

func (shard *GRShard) UpdateTabletsInShardWithLock(ctx context.Context)

UpdateTabletsInShardWithLock updates the shard instances with a lock

type GRTmcClient

type GRTmcClient interface {
	ChangeType(ctx context.Context, tablet *topodatapb.Tablet, dbType topodatapb.TabletType, semiSync bool) error
	Ping(ctx context.Context, tablet *topodatapb.Tablet) error
}

GRTmcClient is VTGR wrapper for tmc client

type GRTopo

type GRTopo interface {
	GetShardNames(ctx context.Context, keyspace string) ([]string, error)
	GetShard(ctx context.Context, keyspace, shard string) (*topo.ShardInfo, error)
	GetTabletMapForShardByCell(ctx context.Context, keyspace, shard string, cells []string) (map[string]*topo.TabletInfo, error)
	LockShard(ctx context.Context, keyspace, shard, action string) (context.Context, func(*error), error)
}

GRTopo is VTGR wrapper for topo server

type MockGRTmcClient

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

MockGRTmcClient is a mock of GRTmcClient interface.

func NewMockGRTmcClient

func NewMockGRTmcClient(ctrl *gomock.Controller) *MockGRTmcClient

NewMockGRTmcClient creates a new mock instance.

func (*MockGRTmcClient) ChangeType

func (m *MockGRTmcClient) ChangeType(ctx context.Context, tablet *topodata.Tablet, dbType topodata.TabletType, semiSync bool) error

ChangeType mocks base method.

func (*MockGRTmcClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockGRTmcClient) Ping

func (m *MockGRTmcClient) Ping(ctx context.Context, tablet *topodata.Tablet) error

Ping mocks base method.

type MockGRTmcClientMockRecorder

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

MockGRTmcClientMockRecorder is the mock recorder for MockGRTmcClient.

func (*MockGRTmcClientMockRecorder) ChangeType

func (mr *MockGRTmcClientMockRecorder) ChangeType(ctx, tablet, dbType any) *gomock.Call

ChangeType indicates an expected call of ChangeType.

func (*MockGRTmcClientMockRecorder) Ping

func (mr *MockGRTmcClientMockRecorder) Ping(ctx, tablet any) *gomock.Call

Ping indicates an expected call of Ping.

type MockGRTopo

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

MockGRTopo is a mock of GRTopo interface.

func NewMockGRTopo

func NewMockGRTopo(ctrl *gomock.Controller) *MockGRTopo

NewMockGRTopo creates a new mock instance.

func (*MockGRTopo) EXPECT

func (m *MockGRTopo) EXPECT() *MockGRTopoMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockGRTopo) GetShard added in v0.13.0

func (m *MockGRTopo) GetShard(ctx context.Context, keyspace, shard string) (*topo.ShardInfo, error)

GetShard mocks base method.

func (*MockGRTopo) GetShardNames

func (m *MockGRTopo) GetShardNames(ctx context.Context, keyspace string) ([]string, error)

GetShardNames mocks base method.

func (*MockGRTopo) GetTabletMapForShardByCell

func (m *MockGRTopo) GetTabletMapForShardByCell(ctx context.Context, keyspace, shard string, cells []string) (map[string]*topo.TabletInfo, error)

GetTabletMapForShardByCell mocks base method.

func (*MockGRTopo) LockShard

func (m *MockGRTopo) LockShard(ctx context.Context, keyspace, shard, action string) (context.Context, func(*error), error)

LockShard mocks base method.

type MockGRTopoMockRecorder

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

MockGRTopoMockRecorder is the mock recorder for MockGRTopo.

func (*MockGRTopoMockRecorder) GetShard added in v0.13.0

func (mr *MockGRTopoMockRecorder) GetShard(ctx, keyspace, shard any) *gomock.Call

GetShard indicates an expected call of GetShard.

func (*MockGRTopoMockRecorder) GetShardNames

func (mr *MockGRTopoMockRecorder) GetShardNames(ctx, keyspace any) *gomock.Call

GetShardNames indicates an expected call of GetShardNames.

func (*MockGRTopoMockRecorder) GetTabletMapForShardByCell

func (mr *MockGRTopoMockRecorder) GetTabletMapForShardByCell(ctx, keyspace, shard, cells any) *gomock.Call

GetTabletMapForShardByCell indicates an expected call of GetTabletMapForShardByCell.

func (*MockGRTopoMockRecorder) LockShard

func (mr *MockGRTopoMockRecorder) LockShard(ctx, keyspace, shard, action any) *gomock.Call

LockShard indicates an expected call of LockShard.

type RepairResultCode

type RepairResultCode string

RepairResultCode is the code for repair

const (
	// Success means successfully repaired
	Success RepairResultCode = "Success"
	// Fail means failed to repaire
	Fail RepairResultCode = "Fail"
	// Noop means do nothing
	Noop RepairResultCode = "Noop"
)

type ResolvedView

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

ResolvedView is the resolved view

type SQLGroup

type SQLGroup struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SQLGroup contains views from all the nodes within the shard

func NewSQLGroup

func NewSQLGroup(size int, singlePrimary bool, keyspace, shard string) *SQLGroup

NewSQLGroup creates a new SQLGroup

func (*SQLGroup) GetGroupName

func (group *SQLGroup) GetGroupName() string

GetGroupName returns the group name

func (*SQLGroup) GetOnlineGroupInfo

func (group *SQLGroup) GetOnlineGroupInfo() (int, bool)

GetOnlineGroupInfo returns number of online members in the group and also if the primary is read only

func (*SQLGroup) GetPrimary

func (group *SQLGroup) GetPrimary() (string, int, bool)

GetPrimary returns the hostname, port of the primary that everyone agreed on isActive bool indicates if there is any node in the group whose primary is "ONLINE"

func (*SQLGroup) GetStatus

func (group *SQLGroup) GetStatus(instanceKey *inst.InstanceKey) *db.GroupMember

GetStatus returns GroupMember status for given a host

func (*SQLGroup) GetViews

func (group *SQLGroup) GetViews() []*db.GroupView

GetViews returns views from everyone in the group

func (*SQLGroup) IsAllOfflineOrError

func (group *SQLGroup) IsAllOfflineOrError() bool

IsAllOfflineOrError returns true if all the nodes are in offline mode

func (*SQLGroup) IsSafeToBootstrap

func (group *SQLGroup) IsSafeToBootstrap() bool

IsSafeToBootstrap checks if it is safe to bootstrap a mysql group

func (*SQLGroup) IsSafeToRebootstrap added in v0.13.0

func (group *SQLGroup) IsSafeToRebootstrap() bool

IsSafeToRebootstrap checks if it is safe to rebootstrap a group It does not check group size as IsSafeToBootstrap, since when we reach here it means VTGR already checked there were group expectedBootstrapSize number of nodes in topo server, therefore we just rebootstrap as long as we can reach all the nodes in topo server

func (*SQLGroup) IsUnconnectedReplica

func (group *SQLGroup) IsUnconnectedReplica(instanceKey *inst.InstanceKey) bool

IsUnconnectedReplica checks if the node is connected to a group

func (*SQLGroup) Resolve

func (group *SQLGroup) Resolve() error

Resolve merges the views into a map

func (*SQLGroup) ToString

func (group *SQLGroup) ToString() string

ToString returns a string representatino of the sql group

type ShardStatus

type ShardStatus struct {
	Keyspace       string
	Shard          string
	Instances      []string
	Unreachables   []string
	Problematics   []string
	Primary        string
	DiagnoseResult DiagnoseType
}

ShardStatus is used for debugging purpose to get current status of a shard

Jump to

Keyboard shortcuts

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