dbop

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrErrantTransactions = errors.New("detected errant transactions")
	ErrNoTopRunner        = errors.New("unable to determine the top runner")
	ErrTimeout            = errors.New("timeout")
)

Sentinel errors. To test these errors, use `errors.Is`.

Functions

func ConfigureMySQLOnDocker added in v0.9.0

func ConfigureMySQLOnDocker(pwd *password.MySQLPassword, port int) error

func RunMySQLOnDocker added in v0.9.0

func RunMySQLOnDocker(name string, port, xport int) error

func SetLogger

func SetLogger(log logr.Logger)

SetLogger configures MySQL driver logging to use `log`.

Types

type AccessInfo

type AccessInfo struct {
	Host     string `db:"Host"`
	Port     int    `db:"Port"`
	User     string `db:"User"`
	Password string `db:"Password"`
}

type CloneStatus

type CloneStatus struct {
	State sql.NullString `db:"state"`
}

CloneStatus defines the observed clone status of a MySQL instance

type GlobalVariables

type GlobalVariables struct {
	ExecutedGTID          string `db:"@@gtid_executed"`
	ReadOnly              bool   `db:"@@read_only"`
	SuperReadOnly         bool   `db:"@@super_read_only"`
	WaitForSlaveCount     int    `db:"@@rpl_semi_sync_master_wait_for_slave_count"`
	SemiSyncMasterEnabled bool   `db:"@@rpl_semi_sync_master_enabled"`
	SemiSyncSlaveEnabled  bool   `db:"@@rpl_semi_sync_slave_enabled"`
}

GlobalVariables defines the observed global variable values of a MySQL instance

type MySQLInstanceStatus

type MySQLInstanceStatus struct {
	IsErrant        bool
	GlobalVariables GlobalVariables
	ReplicaHosts    []ReplicaHost
	ReplicaStatus   *ReplicaStatus // may not be available
	CloneStatus     *CloneStatus   // may not be available
}

MySQLInstanceStatus defines the observed state of a MySQL instance

type Operator

type Operator interface {
	// Name is the name of the MySQL instance for which this operator works.
	Name() string

	// Close closes the underlying connections.
	Close() error

	// GetStatus reports the instance status.
	GetStatus(context.Context) (*MySQLInstanceStatus, error)

	// IsSubsetGTID returns true if set1 is a subset of set2.
	IsSubsetGTID(ctx context.Context, set1, set2 string) (bool, error)

	// FindTopRunner returns the index of the slice whose `GlobalVariables.ExecutedGtidSet`
	// is most advanced.  This may return ErrErrantTransactions for errant transactions
	// or ErrNoTopRunner if there is no such instance.
	FindTopRunner(context.Context, []*MySQLInstanceStatus) (int, error)

	// ConfigureReplica configures client-side replication.
	// If `symisync` is true, it enables client-side semi-synchronous replication.
	// In either case, it disables server-side semi-synchronous replication.
	ConfigureReplica(ctx context.Context, source AccessInfo, semisync bool) error

	// ConfigurePrimary configures server-side semi-synchronous replication.
	// For asynchronous replication, this method should not be called.
	ConfigurePrimary(ctx context.Context, waitForCount int) error

	// StopReplicaIOThread executes `STOP SLAVE IO_THREAD`.
	StopReplicaIOThread(context.Context) error

	// WaitForGTID waits for `mysqld` to execute all GTIDs in `gtidSet`.
	// If timeout happens, this return ErrTimeout.
	// If `timeoutSeconds` is zero, this will not timeout.
	WaitForGTID(ctx context.Context, gtidSet string, timeoutSeconds int) error

	// SetReadOnly makes the instance super_read_only if `true` is passed.
	// Otherwise, this stops the replication and makes the instance writable.
	SetReadOnly(context.Context, bool) error

	// KillConnections kills all connections except for ones from `localhost`
	// and ones for MOCO.
	KillConnections(context.Context) error
}

Operator represents a set of operations for a MySQL instance.

type OperatorFactory

type OperatorFactory interface {
	New(context.Context, *mocov1beta1.MySQLCluster, *password.MySQLPassword, int) (Operator, error)
	Cleanup()
}

OperatorFactory represents the factory for Operators.

func NewFactory

func NewFactory(r Resolver) OperatorFactory

func NewTestFactory

func NewTestFactory() OperatorFactory

type Process added in v0.8.2

type Process struct {
	ID   uint64 `db:"ID"`
	User string `db:"USER"`
	Host string `db:"HOST"`
}

Process represents a process in `information_schema.PROCESSLIST` table.

type ReplicaHost

type ReplicaHost struct {
	ServerID    int32  `db:"Server_id"`
	Host        string `db:"Host"`
	Port        int    `db:"Port"`
	SourceID    int32  `db:"Master_id"`
	ReplicaUUID string `db:"Slave_UUID"`

	// the following fields don't appear normally
	User     string `db:"User"`
	Password string `db:"Password"`
}

ReplicaHost defines the columns from `SHOW SLAVE HOSTS`

type ReplicaStatus

type ReplicaStatus struct {
	LastIoErrno      int    `db:"Last_IO_Errno"`
	LastIoError      string `db:"Last_IO_Error"`
	LastSQLErrno     int    `db:"Last_SQL_Errno"`
	LastSQLError     string `db:"Last_SQL_Error"`
	MasterHost       string `db:"Master_Host"`
	RetrievedGtidSet string `db:"Retrieved_Gtid_Set"`
	ExecutedGtidSet  string `db:"Executed_Gtid_Set"`
	SlaveIORunning   string `db:"Slave_IO_Running"`
	SlaveSQLRunning  string `db:"Slave_SQL_Running"`

	// All of variables from here are NOT used in MOCO's reconcile
	SlaveIOState              string        `db:"Slave_IO_State"`
	MasterUser                string        `db:"Master_User"`
	MasterPort                int           `db:"Master_Port"`
	ConnectRetry              int           `db:"Connect_Retry"`
	MasterLogFile             string        `db:"Master_Log_File"`
	ReadMasterLogPos          int           `db:"Read_Master_Log_Pos"`
	RelayLogFile              string        `db:"Relay_Log_File"`
	RelayLogPos               int           `db:"Relay_Log_Pos"`
	RelayMasterLogFile        string        `db:"Relay_Master_Log_File"`
	ReplicateDoDB             string        `db:"Replicate_Do_DB"`
	ReplicateIgnoreDB         string        `db:"Replicate_Ignore_DB"`
	ReplicateDoTable          string        `db:"Replicate_Do_Table"`
	ReplicateIgnoreTable      string        `db:"Replicate_Ignore_Table"`
	ReplicateWildDoTable      string        `db:"Replicate_Wild_Do_Table"`
	ReplicateWildIgnoreTable  string        `db:"Replicate_Wild_Ignore_Table"`
	LastErrno                 int           `db:"Last_Errno"`
	LastError                 string        `db:"Last_Error"`
	SkipCounter               int           `db:"Skip_Counter"`
	ExecMasterLogPos          int           `db:"Exec_Master_Log_Pos"`
	RelayLogSpace             int           `db:"Relay_Log_Space"`
	UntilCondition            string        `db:"Until_Condition"`
	UntilLogFile              string        `db:"Until_Log_File"`
	UntilLogPos               int           `db:"Until_Log_Pos"`
	MasterSSLAllowed          string        `db:"Master_SSL_Allowed"`
	MasterSSLCAFile           string        `db:"Master_SSL_CA_File"`
	MasterSSLCAPath           string        `db:"Master_SSL_CA_Path"`
	MasterSSLCert             string        `db:"Master_SSL_Cert"`
	MasterSSLCipher           string        `db:"Master_SSL_Cipher"`
	MasterSSLKey              string        `db:"Master_SSL_Key"`
	SecondsBehindMaster       sql.NullInt64 `db:"Seconds_Behind_Master"`
	MasterSSLVerifyServerCert string        `db:"Master_SSL_Verify_Server_Cert"`
	ReplicateIgnoreServerIds  string        `db:"Replicate_Ignore_Server_Ids"`
	MasterServerID            int           `db:"Master_Server_Id"`
	MasterUUID                string        `db:"Master_UUID"`
	MasterInfoFile            string        `db:"Master_Info_File"`
	SQLDelay                  int           `db:"SQL_Delay"`
	SQLRemainingDelay         sql.NullInt64 `db:"SQL_Remaining_Delay"`
	SlaveSQLRunningState      string        `db:"Slave_SQL_Running_State"`
	MasterRetryCount          int           `db:"Master_Retry_Count"`
	MasterBind                string        `db:"Master_Bind"`
	LastIOErrorTimestamp      string        `db:"Last_IO_Error_Timestamp"`
	LastSQLErrorTimestamp     string        `db:"Last_SQL_Error_Timestamp"`
	MasterSSLCrl              string        `db:"Master_SSL_Crl"`
	MasterSSLCrlpath          string        `db:"Master_SSL_Crlpath"`
	AutoPosition              string        `db:"Auto_Position"`
	ReplicateRewriteDB        string        `db:"Replicate_Rewrite_DB"`
	ChannelName               string        `db:"Channel_Name"`
	MasterTLSVersion          string        `db:"Master_TLS_Version"`
	Masterpublickeypath       string        `db:"Master_public_key_path"`
	Getmasterpublickey        string        `db:"Get_master_public_key"`
	NetworkNamespace          string        `db:"Network_Namespace"`
}

ReplicaStatus defines the observed state of a replica

func (*ReplicaStatus) IsRunning

func (rs *ReplicaStatus) IsRunning() bool

type Resolver

type Resolver interface {
	Resolve(context.Context, *mocov1beta1.MySQLCluster, int) (string, error)
}

Jump to

Keyboard shortcuts

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