Documentation ¶
Index ¶
- Constants
- Variables
- func ConcurrentMap(concurrency, n int, fun MapFunc) error
- func MySQLReplicationLag(mysqld *Mysqld) health.Reporter
- func NewGoogleBinlogEvent(buf []byte) blproto.BinlogEvent
- func NewMariadbBinlogEvent(buf []byte) blproto.BinlogEvent
- func RegisterFlags()
- func SnapshotDir(uid uint32) string
- func TabletDir(uid uint32) string
- func TopLevelDirs() []string
- type FakeMysqlDaemon
- func (fmd *FakeMysqlDaemon) GetDbaConnection() (dbconnpool.PoolConnection, error)
- func (fmd *FakeMysqlDaemon) GetMasterAddr() (string, error)
- func (fmd *FakeMysqlDaemon) GetMysqlPort() (int, error)
- func (fmd *FakeMysqlDaemon) GetSchema(dbName string, tables, excludeTables []string, includeViews bool) (*proto.SchemaDefinition, error)
- func (fmd *FakeMysqlDaemon) SlaveStatus() (*proto.ReplicationStatus, error)
- func (fmd *FakeMysqlDaemon) StartSlave(hookExtraEnv map[string]string) error
- func (fmd *FakeMysqlDaemon) StopSlave(hookExtraEnv map[string]string) error
- type MapFunc
- type Mycnf
- type MysqlDaemon
- type MysqlFlavor
- type Mysqld
- func (mysqld *Mysqld) Addr() string
- func (mysqld *Mysqld) ApplySchemaChange(dbName string, change *proto.SchemaChange) (*proto.SchemaChangeResult, error)
- func (mysqld *Mysqld) BinlogInfo(pos proto.ReplicationPosition) (fileName string, filePos uint, err error)
- func (mysqld *Mysqld) BreakSlaves() error
- func (mysqld *Mysqld) CheckReplication(timeCheck int64) error
- func (mysqld *Mysqld) Close()
- func (mysqld *Mysqld) Cnf() *Mycnf
- func (mysqld *Mysqld) CreateSnapshot(logger logutil.Logger, dbName, sourceAddr string, ...) (snapshotManifestUrlPath string, slaveStartRequired, readOnly bool, err error)
- func (mysqld *Mysqld) DemoteMaster() (rp proto.ReplicationPosition, err error)
- func (mysqld *Mysqld) DisableBinlogPlayback() error
- func (mysqld *Mysqld) EnableBinlogPlayback() error
- func (mysqld *Mysqld) ExecuteMysqlCommand(sql string) error
- func (mysqld *Mysqld) ExecuteSuperQuery(query string) error
- func (mysqld *Mysqld) ExecuteSuperQueryList(queryList []string) error
- func (mysqld *Mysqld) FindSlaves() ([]string, error)
- func (mysqld *Mysqld) FindVtDatabases() ([]string, error)
- func (mysqld *Mysqld) GetColumns(dbName, table string) ([]string, error)
- func (mysqld *Mysqld) GetDbaConnection() (dbconnpool.PoolConnection, error)
- func (mysqld *Mysqld) GetMasterAddr() (string, error)
- func (mysqld *Mysqld) GetMysqlPort() (int, error)
- func (mysqld *Mysqld) GetPermissions() (*proto.Permissions, error)
- func (mysqld *Mysqld) GetPrimaryKeyColumns(dbName, table string) ([]string, error)
- func (mysqld *Mysqld) GetSchema(dbName string, tables, excludeTables []string, includeViews bool) (*proto.SchemaDefinition, error)
- func (mysqld *Mysqld) Init(mysqlWaitTime time.Duration, bootstrapArchive string, skipSchema bool) error
- func (mysqld *Mysqld) IpAddr() string
- func (mysqld *Mysqld) IsReadOnly() (bool, error)
- func (mysqld *Mysqld) MasterPosition() (rp proto.ReplicationPosition, err error)
- func (mysqld *Mysqld) OnTerm(f func())
- func (mysqld *Mysqld) PreflightSchemaChange(dbName string, change string) (*proto.SchemaChangeResult, error)
- func (mysqld *Mysqld) PromoteSlave(setReadWrite bool, hookExtraEnv map[string]string) (replicationStatus *proto.ReplicationStatus, ...)
- func (mysqld *Mysqld) ReparentPosition(slavePosition proto.ReplicationPosition) (rs *proto.ReplicationStatus, waitPosition proto.ReplicationPosition, ...)
- func (mysqld *Mysqld) ResolveTables(dbName string, tables []string) ([]string, error)
- func (mysqld *Mysqld) RestartSlave(replicationStatus *proto.ReplicationStatus, ...) error
- func (mysqld *Mysqld) RestoreFromSnapshot(logger logutil.Logger, snapshotManifest *SnapshotManifest, ...) error
- func (mysqld *Mysqld) SetReadOnly(on bool) error
- func (mysqld *Mysqld) Shutdown(waitForMysqld bool, mysqlWaitTime time.Duration) error
- func (mysqld *Mysqld) SlaveStatus() (*proto.ReplicationStatus, error)
- func (mysqld *Mysqld) SnapshotSourceEnd(slaveStartRequired, readOnly, deleteSnapshot bool, ...) error
- func (mysqld *Mysqld) Start(mysqlWaitTime time.Duration) error
- func (mysqld *Mysqld) StartReplicationCommands(status *proto.ReplicationStatus) ([]string, error)
- func (mysqld *Mysqld) StartSlave(hookExtraEnv map[string]string) error
- func (mysqld *Mysqld) StopSlave(hookExtraEnv map[string]string) error
- func (mysqld *Mysqld) Teardown(force bool) error
- func (mysqld *Mysqld) ValidateCloneTarget(hookExtraEnv map[string]string) error
- func (mysqld *Mysqld) ValidateSnapshotPath() error
- func (mysqld *Mysqld) WaitBlpPosition(bp *blproto.BlpPosition, waitTimeout time.Duration) error
- func (mysqld *Mysqld) WaitForSlave(maxLag int) (err error)
- func (mysqld *Mysqld) WaitForSlaveStart(slaveStartDeadline int) error
- func (mysqld *Mysqld) WaitMasterPos(targetPos proto.ReplicationPosition, waitTimeout time.Duration) error
- type SlaveConnection
- type SnapshotFile
- type SnapshotFiles
- type SnapshotManifest
- type SplitStrategy
Constants ¶
const ( SnapshotManifestFile = "snapshot_manifest.json" SnapshotURLPath = "/snapshot" )
const ( // BINLOG_CHECKSUM_ALG_OFF indicates that checksums are supported but off. BINLOG_CHECKSUM_ALG_OFF = 0 // BINLOG_CHECKSUM_ALG_UNDEF indicates that checksums are not supported. BINLOG_CHECKSUM_ALG_UNDEF = 255 )
const (
MysqlWaitTime = 120 * time.Second // default number of seconds to wait
)
const (
SlaveStartDeadline = 30
)
Variables ¶
var ( ErrNotSlave = errors.New("no slave status") ErrNotMaster = errors.New("no master status") )
Functions ¶
func ConcurrentMap ¶
ConcurrentMap applies fun in a concurrent manner on integers from 0 to n-1 (they are assumed to be indexes of some slice containing items to be processed). The first error returned by a fun application will returned (subsequent errors will only be logged). It will use concurrency goroutines.
func MySQLReplicationLag ¶
MySQLReplicationLag lag returns a reporter that reports the MySQL replication lag.
func NewGoogleBinlogEvent ¶
func NewGoogleBinlogEvent(buf []byte) blproto.BinlogEvent
func NewMariadbBinlogEvent ¶
func NewMariadbBinlogEvent(buf []byte) blproto.BinlogEvent
func RegisterFlags ¶
func RegisterFlags()
RegisterFlags registers the command line flags for specifying the values of a mycnf config file. See NewMycnfFromFlags to get the supported modes.
func SnapshotDir ¶
SnapshotDir returns the default directory for a tablet's snapshots
func TopLevelDirs ¶
func TopLevelDirs() []string
TopLevelDirs returns the list of directories in the toplevel tablet directory that might be located in a different place.
Types ¶
type FakeMysqlDaemon ¶
type FakeMysqlDaemon struct { // MasterAddr will be returned by GetMasterAddr(). Set to "" to return // ErrNotSlave, or to "ERROR" to return an error. MasterAddr string // MysqlPort will be returned by GetMysqlPort(). Set to -1 to // return an error. MysqlPort int // Replicating is updated when calling StopSlave Replicating bool // CurrentSlaveStatus is returned by SlaveStatus CurrentSlaveStatus *proto.ReplicationStatus // Schema that will be returned by GetSchema. If nil we'll // return an error. Schema *proto.SchemaDefinition // DbaConnectionFactory is the factory for making fake dba connection DbaConnectionFactory func() (dbconnpool.PoolConnection, error) }
FakeMysqlDaemon implements MysqlDaemon and allows the user to fake everything.
func (*FakeMysqlDaemon) GetDbaConnection ¶
func (fmd *FakeMysqlDaemon) GetDbaConnection() (dbconnpool.PoolConnection, error)
func (*FakeMysqlDaemon) GetMasterAddr ¶
func (fmd *FakeMysqlDaemon) GetMasterAddr() (string, error)
func (*FakeMysqlDaemon) GetMysqlPort ¶
func (fmd *FakeMysqlDaemon) GetMysqlPort() (int, error)
func (*FakeMysqlDaemon) GetSchema ¶
func (fmd *FakeMysqlDaemon) GetSchema(dbName string, tables, excludeTables []string, includeViews bool) (*proto.SchemaDefinition, error)
func (*FakeMysqlDaemon) SlaveStatus ¶
func (fmd *FakeMysqlDaemon) SlaveStatus() (*proto.ReplicationStatus, error)
func (*FakeMysqlDaemon) StartSlave ¶
func (fmd *FakeMysqlDaemon) StartSlave(hookExtraEnv map[string]string) error
type Mycnf ¶
type Mycnf struct { // ServerId is the unique id for this server. // Used to create a bunch of named directories. ServerId uint32 // MysqlPort is the port for the MySQL server running on this machine. // It is mainly used to communicate with topology server. MysqlPort int // DataDir is where the table files are // (used by vt software for Clone) DataDir string // InnodbDataHomeDir is the data directory for innodb. // (used by vt software for Clone) InnodbDataHomeDir string // InnodbLogGroupHomeDir is the logs directory for innodb. // (used by vt software for Clone) InnodbLogGroupHomeDir string // SocketFile is the path to the local mysql.sock file. // (used by vt software to check server is running) SocketFile string // ErrorLogPath is the path to store error logs at. // (unused by vt software for now) ErrorLogPath string // SlowLogPath is the slow query log path // (unused by vt software for now) SlowLogPath string // RelayLogPath is the path of the relay logs // (unused by vt software for now) RelayLogPath string // RelayLogIndexPath is the file name for the relay log index // (unused by vt software for now) RelayLogIndexPath string // RelayLogInfoPath is the file name for the relay log info file // (unused by vt software for now) RelayLogInfoPath string // BinLogPath is the base path for binlogs // (used by vt software for binlog streaming and rowcache invalidation) BinLogPath string // MasterInfoFile is the master.info file location. // (unused by vt software for now) MasterInfoFile string // PidFile is the mysql.pid file location // (used by vt software to check server is running) PidFile string // TmpDir is where to create temporary tables // (unused by vt software for now) TmpDir string // SlaveLoadTmpDir is where to create tmp files for replication // (unused by vt software for now) SlaveLoadTmpDir string // contains filtered or unexported fields }
Mycnf is a memory structure that contains a bunch of interesting parameters to start mysqld. It can be used to generate standard my.cnf files from a server id and mysql port. It can also be populated from an existing my.cnf, or by command line parameters. command line parameters.
func NewMycnf ¶
NewMycnf fills the Mycnf structure with vt root paths and derived values. This is used to fill out the cnfTemplate values and generate my.cnf. uid is a unique id for a particular tablet - it must be unique within the tabletservers deployed within a keyspace, lest there be collisions on disk. mysqldPort needs to be unique per instance per machine.
func NewMycnfFromFlags ¶
NewMycnfFromFlags creates a Mycnf object from the command line flags.
Multiple modes are supported:
- at least mycnf_server_id is set on the command line --> then we read all parameters from the command line, and not from any my.cnf file.
- mycnf_server_id is not passed in, but mycnf-file is passed in --> then we read that mycnf file
- mycnf_server_id and mycnf-file are not passed in: --> then we use the default location of the my.cnf file for the provided uid and read that my.cnf file.
RegisterCommandLineFlags should have been called before calling this, otherwise we'll panic.
type MysqlDaemon ¶
type MysqlDaemon interface { // GetMasterAddr returns the mysql master address, as shown by // 'show slave status'. GetMasterAddr() (string, error) // GetMysqlPort returns the current port mysql is listening on. GetMysqlPort() (int, error) // replication related methods StartSlave(hookExtraEnv map[string]string) error StopSlave(hookExtraEnv map[string]string) error SlaveStatus() (*proto.ReplicationStatus, error) // Schema related methods GetSchema(dbName string, tables, excludeTables []string, includeViews bool) (*proto.SchemaDefinition, error) // GetDbaConnection returns a connection to be able to talk // to the database as the admin user. GetDbaConnection() (dbconnpool.PoolConnection, error) }
MysqlDaemon is the interface we use for abstracting Mysqld.
type MysqlFlavor ¶
type MysqlFlavor interface { // VersionMatch returns true if the version string (from SELECT VERSION()) // represents a server that this flavor knows how to talk to. VersionMatch(version string) bool // MasterPosition returns the ReplicationPosition of a master. MasterPosition(mysqld *Mysqld) (proto.ReplicationPosition, error) // SlaveStatus returns the ReplicationStatus of a slave. SlaveStatus(mysqld *Mysqld) (*proto.ReplicationStatus, error) // PromoteSlaveCommands returns the commands to run to change // a slave into a master. PromoteSlaveCommands() []string // StartReplicationCommands returns the commands to start replicating from // a given master and position as specified in a ReplicationStatus. StartReplicationCommands(params *mysql.ConnectionParams, status *proto.ReplicationStatus) ([]string, error) // ParseGTID parses a GTID in the canonical format of this MySQL flavor into // a proto.GTID interface value. ParseGTID(string) (proto.GTID, error) // ParseReplicationPosition parses a replication position in the canonical // format of this MySQL flavor into a proto.ReplicationPosition struct. ParseReplicationPosition(string) (proto.ReplicationPosition, error) // SendBinlogDumpCommand sends the flavor-specific version of the // COM_BINLOG_DUMP command to start dumping raw binlog events over a slave // connection, starting at a given GTID. SendBinlogDumpCommand(mysqld *Mysqld, conn *SlaveConnection, startPos proto.ReplicationPosition) error // MakeBinlogEvent takes a raw packet from the MySQL binlog stream connection // and returns a BinlogEvent through which the packet can be examined. MakeBinlogEvent(buf []byte) blproto.BinlogEvent // WaitMasterPos waits until slave replication reaches at least targetPos. WaitMasterPos(mysqld *Mysqld, targetPos proto.ReplicationPosition, waitTimeout time.Duration) error // EnableBinlogPlayback prepares the server to play back events from a binlog stream. // Whatever it does for a given flavor, it must be idempotent. EnableBinlogPlayback(mysqld *Mysqld) error // DisableBinlogPlayback returns the server to the normal state after playback is done. // Whatever it does for a given flavor, it must be idempotent. DisableBinlogPlayback(mysqld *Mysqld) error }
MysqlFlavor is the abstract interface for a flavor.
type Mysqld ¶
type Mysqld struct { TabletDir string SnapshotDir string // contains filtered or unexported fields }
Mysqld is the object that represents a mysqld daemon running on this server.
func NewMysqld ¶
func NewMysqld(name string, config *Mycnf, dba, repl *mysql.ConnectionParams) *Mysqld
NewMysqld creates a Mysqld object based on the provided configuration and connection parameters. name is the base for stats exports, use 'Dba', except in tests
func (*Mysqld) ApplySchemaChange ¶
func (mysqld *Mysqld) ApplySchemaChange(dbName string, change *proto.SchemaChange) (*proto.SchemaChangeResult, error)
ApplySchemaChange will apply the schema change to the given database.
func (*Mysqld) BinlogInfo ¶
func (mysqld *Mysqld) BinlogInfo(pos proto.ReplicationPosition) (fileName string, filePos uint, err error)
mysql> SHOW BINLOG INFO FOR 5\G *************************** 1. row *************************** Log_name: vt-0000041983-bin.000001 Pos: 1194 Server_ID: 41983
BinlogInfo returns the filename and position for a Google MySQL group_id. This command only exists in Google MySQL.
func (*Mysqld) BreakSlaves ¶
Force all slaves to error and stop. This is extreme, but helpful for emergencies and tests. Insert a row, block the propagation of its subsequent delete and reinsert it. This forces a failure on slaves only.
func (*Mysqld) CheckReplication ¶
Check for the magic row inserted under controlled reparenting.
func (*Mysqld) Close ¶
func (mysqld *Mysqld) Close()
Close will close this instance of Mysqld. It will wait for all dba queries to be finished.
func (*Mysqld) CreateSnapshot ¶
func (mysqld *Mysqld) CreateSnapshot(logger logutil.Logger, dbName, sourceAddr string, allowHierarchicalReplication bool, concurrency int, serverMode bool, hookExtraEnv map[string]string) (snapshotManifestUrlPath string, slaveStartRequired, readOnly bool, err error)
This function runs on the machine acting as the source for the clone.
Check master/slave status and determine restore needs. If this instance is a slave, stop replication, otherwise place in read-only mode. Record replication position. Shutdown mysql Check paths for storing data
Depending on the serverMode flag, we do the following: serverMode = false:
Compress /vt/vt_[0-9a-f]+/data/vt_.+ Compute hash (of compressed files, as we serve .gz files here) Place in /vt/clone_src where they will be served by http server (not rpc) Restart mysql
serverMode = true:
Make symlinks for /vt/vt_[0-9a-f]+/data/vt_.+ to innodb files Compute hash (of uncompressed files, as we serve uncompressed files) Place symlinks in /vt/clone_src where they will be served by http server Leave mysql stopped, return slaveStartRequired, readOnly
func (*Mysqld) DemoteMaster ¶
func (mysqld *Mysqld) DemoteMaster() (rp proto.ReplicationPosition, err error)
if the master is still alive, then we need to demote it gracefully make it read-only, flush the writes and get the position
func (*Mysqld) DisableBinlogPlayback ¶
DisableBinlogPlayback returns the server to the normal state after streaming. Whatever it does for a given flavor, it must be idempotent.
func (*Mysqld) EnableBinlogPlayback ¶
EnableBinlogPlayback prepares the server to play back events from a binlog stream. Whatever it does for a given flavor, it must be idempotent.
func (*Mysqld) ExecuteMysqlCommand ¶
ExecuteMysqlCommand executes some SQL commands using a mysql command line interface process
func (*Mysqld) ExecuteSuperQuery ¶
ExecuteSuperQuery allows the user to execute a query as a super user.
func (*Mysqld) ExecuteSuperQueryList ¶
ExecuteSuperQueryList alows the user to execute queries as a super user.
func (*Mysqld) FindSlaves ¶
Get IP addresses for all currently connected slaves.
func (*Mysqld) FindVtDatabases ¶
func (*Mysqld) GetColumns ¶
GetColumns returns the columns of table.
func (*Mysqld) GetDbaConnection ¶
func (mysqld *Mysqld) GetDbaConnection() (dbconnpool.PoolConnection, error)
GetDbaConnection returns a connection from the dba pool. Recycle needs to be called on the result.
func (*Mysqld) GetMasterAddr ¶
func (*Mysqld) GetMysqlPort ¶
func (*Mysqld) GetPermissions ¶
func (mysqld *Mysqld) GetPermissions() (*proto.Permissions, error)
func (*Mysqld) GetPrimaryKeyColumns ¶
GetPrimaryKeyColumns returns the primary key columns of table.
func (*Mysqld) GetSchema ¶
func (mysqld *Mysqld) GetSchema(dbName string, tables, excludeTables []string, includeViews bool) (*proto.SchemaDefinition, error)
GetSchema returns the schema for database for tables listed in tables. If tables is empty, return the schema for all tables.
func (*Mysqld) Init ¶
func (mysqld *Mysqld) Init(mysqlWaitTime time.Duration, bootstrapArchive string, skipSchema bool) error
Init will create the default directory structure for the mysqld process, generate / configure a my.cnf file, unpack a skeleton database, and create some management tables.
func (*Mysqld) IsReadOnly ¶
func (*Mysqld) MasterPosition ¶
func (mysqld *Mysqld) MasterPosition() (rp proto.ReplicationPosition, err error)
func (*Mysqld) OnTerm ¶
func (mysqld *Mysqld) OnTerm(f func())
OnTerm registers a function to be called if mysqld terminates for any reason other than a call to Mysqld.Shutdown(). This only works if mysqld was actually started by calling Start() on this Mysqld instance.
func (*Mysqld) PreflightSchemaChange ¶
func (mysqld *Mysqld) PreflightSchemaChange(dbName string, change string) (*proto.SchemaChangeResult, error)
PreflightSchemaChange will apply the schema change to a fake database that has the same schema as the target database, see if it works.
func (*Mysqld) PromoteSlave ¶
func (mysqld *Mysqld) PromoteSlave(setReadWrite bool, hookExtraEnv map[string]string) (replicationStatus *proto.ReplicationStatus, waitPosition proto.ReplicationPosition, timePromoted int64, err error)
setReadWrite: set the new master in read-write mode.
replicationState: info slaves need to reparent themselves waitPosition: slaves can wait for this position when restarting replication timePromoted: this timestamp (unix nanoseconds) is inserted into _vt.replication_log to verify the replication config
func (*Mysqld) ReparentPosition ¶
func (mysqld *Mysqld) ReparentPosition(slavePosition proto.ReplicationPosition) (rs *proto.ReplicationStatus, waitPosition proto.ReplicationPosition, reparentTime int64, err error)
Return a replication state that will reparent a slave to the correct master for a specified position.
func (*Mysqld) ResolveTables ¶
ResolveTables returns a list of actual tables+views matching a list of regexps
func (*Mysqld) RestartSlave ¶
func (mysqld *Mysqld) RestartSlave(replicationStatus *proto.ReplicationStatus, waitPosition proto.ReplicationPosition, timeCheck int64) error
func (*Mysqld) RestoreFromSnapshot ¶
func (mysqld *Mysqld) RestoreFromSnapshot(logger logutil.Logger, snapshotManifest *SnapshotManifest, fetchConcurrency, fetchRetryCount int, dontWaitForSlaveStart bool, hookExtraEnv map[string]string) error
This piece runs on the presumably empty machine acting as the target in the create replica action.
validate target (self) shutdown_mysql() create temp data directory /vt/target/vt_<keyspace> copy compressed data files via HTTP verify hash of compressed files uncompress into /vt/vt_<target-uid>/data/vt_<keyspace> start_mysql() clean up compressed files
func (*Mysqld) SetReadOnly ¶
func (*Mysqld) Shutdown ¶
Shutdown will stop the mysqld daemon that is running in the background.
waitForMysqld: should the function block until mysqld has stopped? This can actually take a *long* time if the buffer cache needs to be fully flushed - on the order of 20-30 minutes.
If a mysqlctld address is provided in a flag, Shutdown will run remotely.
func (*Mysqld) SlaveStatus ¶
func (mysqld *Mysqld) SlaveStatus() (*proto.ReplicationStatus, error)
func (*Mysqld) SnapshotSourceEnd ¶
func (*Mysqld) Start ¶
Start will start the mysql daemon, either by running the 'mysqld_start' hook, or by running mysqld_safe in the background. If a mysqlctld address is provided in a flag, Start will run remotely.
func (*Mysqld) StartReplicationCommands ¶
func (mysqld *Mysqld) StartReplicationCommands(status *proto.ReplicationStatus) ([]string, error)
func (*Mysqld) ValidateCloneTarget ¶
func (*Mysqld) ValidateSnapshotPath ¶
Helper function to make sure we can write to the local snapshot area, before we actually do any action (can be used for both partial and full snapshots)
func (*Mysqld) WaitBlpPosition ¶
WaitBlpPosition will wait for the filtered replication to reach at least the provided position.
func (*Mysqld) WaitForSlave ¶
func (*Mysqld) WaitForSlaveStart ¶
func (*Mysqld) WaitMasterPos ¶
type SlaveConnection ¶
type SlaveConnection struct { *mysql.Connection // contains filtered or unexported fields }
SlaveConnection represents a connection to mysqld that pretends to be a slave connecting for replication. Each such connection must identify itself to mysqld with a server ID that is unique both among other SlaveConnections and among actual slaves in the topology.
func NewSlaveConnection ¶
func NewSlaveConnection(mysqld *Mysqld) (*SlaveConnection, error)
NewSlaveConnection creates a new slave connection to the mysqld instance. It uses a pools.IDPool to ensure that the server IDs used to connect are unique within this process. This is done with the assumptions that:
- No other processes are making fake slave connections to our mysqld.
- No real slave servers will have IDs in the range 1-N where N is the peak number of concurrent fake slave connections we will ever make.
func (*SlaveConnection) Close ¶
func (sc *SlaveConnection) Close()
Close closes the slave connection, which also signals an ongoing dump started with StartBinlogDump() to stop and close its BinlogEvent channel. The ID for the slave connection is recycled back into the pool.
func (*SlaveConnection) StartBinlogDump ¶
func (sc *SlaveConnection) StartBinlogDump(startPos proto.ReplicationPosition) (<-chan blproto.BinlogEvent, error)
StartBinlogDump requests a replication binlog dump from the master mysqld and then immediately returns a channel on which received binlog events will be sent. The stream will continue, waiting for new events if necessary, until the connection is closed, either by the master or by calling SlaveConnection.Close(). At that point, the channel will also be closed.
type SnapshotFile ¶
SnapshotFile describes a file to serve. 'Path' is the path component of the URL. SnapshotManifest.Addr is the host+port component of the URL. If path ends in '.gz', it is compressed. Size and Hash are computed on the Path itself if TableName is set, this file belongs to that table
type SnapshotFiles ¶
type SnapshotFiles []SnapshotFile
func (SnapshotFiles) Len ¶
func (s SnapshotFiles) Len() int
sort.Interface we sort by descending file size
func (SnapshotFiles) Less ¶
func (s SnapshotFiles) Less(i, j int) bool
func (SnapshotFiles) Swap ¶
func (s SnapshotFiles) Swap(i, j int)
type SnapshotManifest ¶
type SnapshotManifest struct { Addr string // this is the address of the tabletserver, not mysql DbName string Files SnapshotFiles ReplicationStatus *proto.ReplicationStatus MasterPosition proto.ReplicationPosition }
a SnapshotManifest describes multiple SnapshotFiles and where to get them from.
func ReadSnapshotManifest ¶
func ReadSnapshotManifest(filename string) (*SnapshotManifest, error)
type SplitStrategy ¶
type SplitStrategy struct { // PopulateBlpCheckpoint will drive the population of the blp_checkpoint table PopulateBlpCheckpoint bool // DontStartBinlogPlayer will delay starting the binlog replication DontStartBinlogPlayer bool // SkipSetSourceShards will not set the source shards at the end of restore SkipSetSourceShards bool }
SplitStrategy is the configuration for a split clone.
func NewSplitStrategy ¶
func NewSplitStrategy(logger logutil.Logger, argsStr string) (*SplitStrategy, error)
func (*SplitStrategy) String ¶
func (strategy *SplitStrategy) String() string
Source Files ¶
- binlog_event.go
- clone.go
- fileutil.go
- health.go
- mycnf.go
- mycnf_flag.go
- mycnf_gen.go
- mysql_daemon.go
- mysql_flavor.go
- mysql_flavor_google.go
- mysql_flavor_mariadb.go
- mysqld.go
- permissions.go
- plugin_gorpcmysqlctlclient.go
- query.go
- reparent.go
- replication.go
- schema.go
- slave_connection.go
- split_strategy.go
- utils.go
Directories ¶
Path | Synopsis |
---|---|
Package gorpcmysqlctlclient contains the go rpc version of the mysqlctl client protocol.
|
Package gorpcmysqlctlclient contains the go rpc version of the mysqlctl client protocol. |
Package gorpcmysqlctlserver contains the Go RPC implementation of the server side of the remote execution of mysqlctl commands.
|
Package gorpcmysqlctlserver contains the Go RPC implementation of the server side of the remote execution of mysqlctl commands. |
Package mysqlctlclient contains the generic client side of the remote mysqlctl protocol.
|
Package mysqlctlclient contains the generic client side of the remote mysqlctl protocol. |