Documentation ¶
Index ¶
- Constants
- Variables
- func Backup(ctx context.Context, params BackupParams) error
- func ChooseBinlogsForIncrementalBackup(ctx context.Context, backupFromGTIDSet replication.GTIDSet, ...) (binaryLogsToBackup []string, incrementalBackupFromGTID string, ...)
- func CreateMysqldAndMycnf(tabletUID uint32, mysqlSocket string, mysqlPort int, ...) (*Mysqld, *Mycnf, error)
- func DefaultTabletDirAtRoot(dataRoot string, uid uint32) string
- func FindReplicas(mysqld MysqlDaemon) ([]string, error)
- func FormatRFC3339(t time.Time) string
- func GenerateInitialBinlogEntry() string
- func GetBackupDir(keyspace, shard string) string
- func GetColumns(dbName, table string, exec func(string, int, bool) (*sqltypes.Result, error)) ([]*querypb.Field, []string, error)
- func GetColumnsList(dbName, tableName string, ...) (string, error)
- func GetPermissions(mysqld MysqlDaemon) (*tabletmanagerdatapb.Permissions, error)
- func GetPrimaryKeyEquivalentColumns(ctx context.Context, exec func(string, int, bool) (*sqltypes.Result, error), ...) ([]string, string, error)
- func GetVersionString() (string, error)
- func IsValidIncrementalBakcup(baseGTIDSet replication.GTIDSet, purgedGTIDSet replication.GTIDSet, ...) bool
- func MycnfFile(uid uint32) string
- func OpenMysqldAndMycnf(tabletUID uint32, collationEnv *collations.Environment) (*Mysqld, *Mycnf, error)
- func ParseBackupName(dir string, name string) (backupTime *time.Time, alias *topodatapb.TabletAlias, err error)
- func ParseBinlogTimestamp(timestamp string) (time.Time, error)
- func ParseRFC3339(timestamp string) (time.Time, error)
- func ParseVersionString(version string) (flavor MySQLFlavor, ver ServerVersion, err error)
- func PopulateReparentJournal(timeCreatedNS int64, actionName, primaryAlias string, pos replication.Position) string
- func RegisterFlags()
- func ResolveTables(ctx context.Context, mysqld MysqlDaemon, dbName string, tables []string) ([]string, error)
- func RestoreWasInterrupted(cnf *Mycnf) bool
- func ShouldRestore(ctx context.Context, params RestoreParams) (bool, error)
- func TabletDir(uid uint32) string
- func TopLevelDirs() []string
- func WaitForReplicationStart(mysqld MysqlDaemon, replicaStartDeadline int) error
- type BackupEngine
- type BackupManifest
- func FindPITRPath(restoreToGTIDSet replication.GTIDSet, manifests [](*BackupManifest)) (shortestPath [](*BackupManifest), err error)
- func FindPITRToTimePath(restoreToTime time.Time, manifests [](*BackupManifest)) (shortestPath [](*BackupManifest), err error)
- func GetBackupManifest(ctx context.Context, backup backupstorage.BackupHandle) (*BackupManifest, error)
- func Restore(ctx context.Context, params RestoreParams) (*BackupManifest, error)
- type BackupManifestPath
- type BackupParams
- type BackupRestoreEngine
- type BackupResult
- type BuiltinBackupEngine
- func (be *BuiltinBackupEngine) ExecuteBackup(ctx context.Context, params BackupParams, bh backupstorage.BackupHandle) (BackupResult, error)
- func (be *BuiltinBackupEngine) ExecuteRestore(ctx context.Context, params RestoreParams, bh backupstorage.BackupHandle) (*BackupManifest, error)
- func (be *BuiltinBackupEngine) ShouldDrainForBackup(req *tabletmanagerdatapb.BackupRequest) bool
- type EmptyColumnsErr
- type FakeBackupEngine
- func (be *FakeBackupEngine) ExecuteBackup(ctx context.Context, params BackupParams, bh backupstorage.BackupHandle) (BackupResult, error)
- func (be *FakeBackupEngine) ExecuteRestore(ctx context.Context, params RestoreParams, bh backupstorage.BackupHandle) (*BackupManifest, error)
- func (be *FakeBackupEngine) ShouldDrainForBackup(req *tabletmanagerdatapb.BackupRequest) bool
- type FakeBackupEngineExecuteBackupCall
- type FakeBackupEngineExecuteBackupReturn
- type FakeBackupEngineExecuteRestoreCall
- type FakeBackupEngineExecuteRestoreReturn
- type FakeBackupHandle
- func (fbh *FakeBackupHandle) AbortBackup(ctx context.Context) error
- func (fbh *FakeBackupHandle) AddFile(ctx context.Context, filename string, filesize int64) (io.WriteCloser, error)
- func (fbh *FakeBackupHandle) Directory() string
- func (fbh *FakeBackupHandle) EndBackup(ctx context.Context) error
- func (fbh *FakeBackupHandle) Error() error
- func (fbh *FakeBackupHandle) HasErrors() bool
- func (fbh *FakeBackupHandle) Name() string
- func (fbh *FakeBackupHandle) ReadFile(ctx context.Context, filename string) (io.ReadCloser, error)
- func (fbh *FakeBackupHandle) RecordError(err error)
- type FakeBackupHandleAddFileCall
- type FakeBackupHandleAddFileReturn
- type FakeBackupHandleReadFileCall
- type FakeBackupStorage
- func (fbs *FakeBackupStorage) Close() error
- func (fbs *FakeBackupStorage) ListBackups(ctx context.Context, dir string) ([]backupstorage.BackupHandle, error)
- func (fbs *FakeBackupStorage) RemoveBackup(ctx context.Context, dir, name string) error
- func (fbs *FakeBackupStorage) StartBackup(ctx context.Context, dir, name string) (backupstorage.BackupHandle, error)
- func (fbs *FakeBackupStorage) WithParams(params backupstorage.Params) backupstorage.BackupStorage
- type FakeBackupStorageListBackupsCall
- type FakeBackupStorageListBackupsReturn
- type FakeBackupStorageRemoveBackupCall
- type FakeBackupStorageStartBackupCall
- type FakeBackupStorageStartBackupReturn
- type FakeMysqlDaemon
- func (fmd *FakeMysqlDaemon) ApplyBinlogFile(ctx context.Context, req *mysqlctlpb.ApplyBinlogFileRequest) error
- func (fmd *FakeMysqlDaemon) ApplySchemaChange(ctx context.Context, dbName string, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error)
- func (fmd *FakeMysqlDaemon) CheckSuperQueryList() error
- func (fmd *FakeMysqlDaemon) Close()
- func (fmd *FakeMysqlDaemon) CurrentPrimaryPositionLocked(pos replication.Position)
- func (fmd *FakeMysqlDaemon) ExecuteSuperQueryList(ctx context.Context, queryList []string) error
- func (fmd *FakeMysqlDaemon) FetchSuperQuery(ctx context.Context, query string) (*sqltypes.Result, error)
- func (fmd *FakeMysqlDaemon) FlushBinaryLogs(ctx context.Context) (err error)
- func (fmd *FakeMysqlDaemon) GetAllPrivsConnection(ctx context.Context) (*dbconnpool.DBConnection, error)
- func (fmd *FakeMysqlDaemon) GetAppConnection(ctx context.Context) (*dbconnpool.PooledDBConnection, error)
- func (fmd *FakeMysqlDaemon) GetBinaryLogs(ctx context.Context) (binaryLogs []string, err error)
- func (fmd *FakeMysqlDaemon) GetBinlogInformation(ctx context.Context) (binlogFormat string, logEnabled bool, logReplicaUpdate bool, ...)
- func (fmd *FakeMysqlDaemon) GetColumns(ctx context.Context, dbName, table string) ([]*querypb.Field, []string, error)
- func (fmd *FakeMysqlDaemon) GetDbaConnection(ctx context.Context) (*dbconnpool.DBConnection, error)
- func (fmd *FakeMysqlDaemon) GetGTIDMode(ctx context.Context) (gtidMode string, err error)
- func (fmd *FakeMysqlDaemon) GetGTIDPurged(ctx context.Context) (replication.Position, error)
- func (fmd *FakeMysqlDaemon) GetMysqlPort() (int32, error)
- func (fmd *FakeMysqlDaemon) GetPreviousGTIDs(ctx context.Context, binlog string) (previousGtids string, err error)
- func (fmd *FakeMysqlDaemon) GetPrimaryKeyColumns(ctx context.Context, dbName, table string) ([]string, error)
- func (fmd *FakeMysqlDaemon) GetPrimaryKeyEquivalentColumns(ctx context.Context, dbName, table string) ([]string, string, error)
- func (fmd *FakeMysqlDaemon) GetSchema(ctx context.Context, dbName string, ...) (*tabletmanagerdatapb.SchemaDefinition, error)
- func (fmd *FakeMysqlDaemon) GetServerID(ctx context.Context) (uint32, error)
- func (fmd *FakeMysqlDaemon) GetServerUUID(ctx context.Context) (string, error)
- func (fmd *FakeMysqlDaemon) GetVersionComment(ctx context.Context) (string, error)
- func (fmd *FakeMysqlDaemon) GetVersionString(ctx context.Context) (string, error)
- func (fmd *FakeMysqlDaemon) IsReadOnly() (bool, error)
- func (fmd *FakeMysqlDaemon) IsSuperReadOnly() (bool, error)
- func (fmd *FakeMysqlDaemon) PreflightSchemaChange(ctx context.Context, dbName string, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)
- func (fmd *FakeMysqlDaemon) PrimaryPosition() (replication.Position, error)
- func (fmd *FakeMysqlDaemon) PrimaryStatus(ctx context.Context) (replication.PrimaryStatus, error)
- func (fmd *FakeMysqlDaemon) Promote(hookExtraEnv map[string]string) (replication.Position, error)
- func (fmd *FakeMysqlDaemon) ReadBinlogFilesTimestamps(ctx context.Context, req *mysqlctlpb.ReadBinlogFilesTimestampsRequest) (*mysqlctlpb.ReadBinlogFilesTimestampsResponse, error)
- func (fmd *FakeMysqlDaemon) RefreshConfig(ctx context.Context, cnf *Mycnf) error
- func (fmd *FakeMysqlDaemon) ReinitConfig(ctx context.Context, cnf *Mycnf) error
- func (fmd *FakeMysqlDaemon) ReplicationStatus() (replication.ReplicationStatus, error)
- func (fmd *FakeMysqlDaemon) ResetReplication(ctx context.Context) error
- func (fmd *FakeMysqlDaemon) ResetReplicationParameters(ctx context.Context) error
- func (fmd *FakeMysqlDaemon) RestartReplication(hookExtraEnv map[string]string) error
- func (fmd *FakeMysqlDaemon) RunMysqlUpgrade(ctx context.Context) error
- func (fmd *FakeMysqlDaemon) SemiSyncClients() uint32
- func (fmd *FakeMysqlDaemon) SemiSyncEnabled() (primary, replica bool)
- func (fmd *FakeMysqlDaemon) SemiSyncExtensionLoaded() (bool, error)
- func (fmd *FakeMysqlDaemon) SemiSyncReplicationStatus() (bool, error)
- func (fmd *FakeMysqlDaemon) SemiSyncSettings() (timeout uint64, numReplicas uint32)
- func (fmd *FakeMysqlDaemon) SemiSyncStatus() (bool, bool)
- func (fmd *FakeMysqlDaemon) SetReadOnly(on bool) error
- func (fmd *FakeMysqlDaemon) SetReplicationPosition(ctx context.Context, pos replication.Position) error
- func (fmd *FakeMysqlDaemon) SetReplicationSource(ctx context.Context, host string, port int32, stopReplicationBefore bool, ...) error
- func (fmd *FakeMysqlDaemon) SetSemiSyncEnabled(primary, replica bool) error
- func (fmd *FakeMysqlDaemon) SetSuperReadOnly(on bool) (ResetSuperReadOnlyFunc, error)
- func (fmd *FakeMysqlDaemon) Shutdown(ctx context.Context, cnf *Mycnf, waitForMysqld bool, ...) error
- func (fmd *FakeMysqlDaemon) Start(ctx context.Context, cnf *Mycnf, mysqldArgs ...string) error
- func (fmd *FakeMysqlDaemon) StartReplication(hookExtraEnv map[string]string) error
- func (fmd *FakeMysqlDaemon) StartReplicationUntilAfter(ctx context.Context, pos replication.Position) error
- func (fmd *FakeMysqlDaemon) StopIOThread(ctx context.Context) error
- func (fmd *FakeMysqlDaemon) StopReplication(hookExtraEnv map[string]string) error
- func (fmd *FakeMysqlDaemon) Wait(ctx context.Context, cnf *Mycnf) error
- func (fmd *FakeMysqlDaemon) WaitForReparentJournal(ctx context.Context, timeCreatedNS int64) error
- func (fmd *FakeMysqlDaemon) WaitSourcePos(_ context.Context, pos replication.Position) error
- type FileEntry
- type IncrementalBackupDetails
- type ManifestHandleMap
- type MySQLFlavor
- type Mycnf
- type MysqlDaemon
- type Mysqld
- func (mysqld *Mysqld) ApplyBinlogFile(ctx context.Context, req *mysqlctlpb.ApplyBinlogFileRequest) error
- func (mysqld *Mysqld) ApplySchemaChange(ctx context.Context, dbName string, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error)
- func (mysqld *Mysqld) Close()
- func (mysqld *Mysqld) DisableRedoLog(ctx context.Context) error
- func (mysqld *Mysqld) EnableRedoLog(ctx context.Context) error
- func (mysqld *Mysqld) ExecuteSuperQuery(ctx context.Context, query string) error
- func (mysqld *Mysqld) ExecuteSuperQueryList(ctx context.Context, queryList []string) error
- func (mysqld *Mysqld) FetchSuperQuery(ctx context.Context, query string) (*sqltypes.Result, error)
- func (mysqld *Mysqld) FlushBinaryLogs(ctx context.Context) (err error)
- func (mysqld *Mysqld) GetAllPrivsConnection(ctx context.Context) (*dbconnpool.DBConnection, error)
- func (mysqld *Mysqld) GetAppConnection(ctx context.Context) (*dbconnpool.PooledDBConnection, error)
- func (mysqld *Mysqld) GetBinaryLogs(ctx context.Context) (binaryLogs []string, err error)
- func (mysqld *Mysqld) GetBinlogInformation(ctx context.Context) (string, bool, bool, string, error)
- func (mysqld *Mysqld) GetColumns(ctx context.Context, dbName, table string) ([]*querypb.Field, []string, error)
- func (mysqld *Mysqld) GetDbaConnection(ctx context.Context) (*dbconnpool.DBConnection, error)
- func (mysqld *Mysqld) GetGTIDMode(ctx context.Context) (string, error)
- func (mysqld *Mysqld) GetGTIDPurged(ctx context.Context) (replication.Position, error)
- func (mysqld *Mysqld) GetMysqlPort() (int32, error)
- func (mysqld *Mysqld) GetPreviousGTIDs(ctx context.Context, binlog string) (previousGtids string, err error)
- func (mysqld *Mysqld) GetPrimaryKeyColumns(ctx context.Context, dbName, table string) ([]string, error)
- func (mysqld *Mysqld) GetSchema(ctx context.Context, dbName string, ...) (*tabletmanagerdatapb.SchemaDefinition, error)
- func (mysqld *Mysqld) GetServerID(ctx context.Context) (uint32, error)
- func (mysqld *Mysqld) GetServerUUID(ctx context.Context) (string, error)
- func (mysqld *Mysqld) GetVersionComment(ctx context.Context) (string, error)
- func (mysqld *Mysqld) GetVersionString(ctx context.Context) (string, error)
- func (mysqld *Mysqld) Init(ctx context.Context, cnf *Mycnf, initDBSQLFile string) error
- func (mysqld *Mysqld) InitConfig(cnf *Mycnf) error
- func (mysqld *Mysqld) IsReadOnly() (bool, error)
- func (mysqld *Mysqld) IsSuperReadOnly() (bool, error)
- func (mysqld *Mysqld) OnTerm(f func())
- func (mysqld *Mysqld) PreflightSchemaChange(ctx context.Context, dbName string, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)
- func (mysqld *Mysqld) PrimaryPosition() (replication.Position, error)
- func (mysqld *Mysqld) PrimaryStatus(ctx context.Context) (replication.PrimaryStatus, error)
- func (mysqld *Mysqld) ProcessCanDisableRedoLog(ctx context.Context) (bool, error)
- func (mysqld *Mysqld) Promote(hookExtraEnv map[string]string) (replication.Position, error)
- func (mysqld *Mysqld) ReadBinlogFilesTimestamps(ctx context.Context, req *mysqlctlpb.ReadBinlogFilesTimestampsRequest) (*mysqlctlpb.ReadBinlogFilesTimestampsResponse, error)
- func (mysqld *Mysqld) RefreshConfig(ctx context.Context, cnf *Mycnf) error
- func (mysqld *Mysqld) ReinitConfig(ctx context.Context, cnf *Mycnf) error
- func (mysqld *Mysqld) ReplicationStatus() (replication.ReplicationStatus, error)
- func (mysqld *Mysqld) ResetReplication(ctx context.Context) error
- func (mysqld *Mysqld) ResetReplicationParameters(ctx context.Context) error
- func (mysqld *Mysqld) RestartReplication(hookExtraEnv map[string]string) error
- func (mysqld *Mysqld) RunMysqlUpgrade(ctx context.Context) error
- func (mysqld *Mysqld) SemiSyncClients() uint32
- func (mysqld *Mysqld) SemiSyncEnabled() (primary, replica bool)
- func (mysqld *Mysqld) SemiSyncExtensionLoaded() (bool, error)
- func (mysqld *Mysqld) SemiSyncReplicationStatus() (bool, error)
- func (mysqld *Mysqld) SemiSyncSettings() (timeout uint64, numReplicas uint32)
- func (mysqld *Mysqld) SemiSyncStatus() (primary, replica bool)
- func (mysqld *Mysqld) SetReadOnly(on bool) error
- func (mysqld *Mysqld) SetReplicationPosition(ctx context.Context, pos replication.Position) error
- func (mysqld *Mysqld) SetReplicationSource(ctx context.Context, host string, port int32, stopReplicationBefore bool, ...) error
- func (mysqld *Mysqld) SetSemiSyncEnabled(primary, replica bool) error
- func (mysqld *Mysqld) SetSuperReadOnly(on bool) (ResetSuperReadOnlyFunc, error)
- func (mysqld *Mysqld) Shutdown(ctx context.Context, cnf *Mycnf, waitForMysqld bool, ...) error
- func (mysqld *Mysqld) Start(ctx context.Context, cnf *Mycnf, mysqldArgs ...string) error
- func (mysqld *Mysqld) StartReplication(hookExtraEnv map[string]string) error
- func (mysqld *Mysqld) StartReplicationUntilAfter(ctx context.Context, targetPos replication.Position) error
- func (mysqld *Mysqld) StartSQLThreadUntilAfter(ctx context.Context, targetPos replication.Position) error
- func (mysqld *Mysqld) StopIOThread(ctx context.Context) error
- func (mysqld *Mysqld) StopReplication(hookExtraEnv map[string]string) error
- func (mysqld *Mysqld) StopSQLThread(ctx context.Context) error
- func (mysqld *Mysqld) Teardown(ctx context.Context, cnf *Mycnf, force bool, shutdownTimeout time.Duration) error
- func (mysqld *Mysqld) Wait(ctx context.Context, cnf *Mycnf) error
- func (mysqld *Mysqld) WaitForReparentJournal(ctx context.Context, timeCreatedNS int64) error
- func (mysqld *Mysqld) WaitSourcePos(ctx context.Context, targetPos replication.Position) error
- type ResetSuperReadOnlyFunc
- type RestoreEngine
- type RestoreParams
- type RestorePath
- type ServerVersion
- type XtrabackupEngine
- func (be *XtrabackupEngine) ExecuteBackup(ctx context.Context, params BackupParams, bh backupstorage.BackupHandle) (BackupResult, error)
- func (be *XtrabackupEngine) ExecuteRestore(ctx context.Context, params RestoreParams, bh backupstorage.BackupHandle) (*BackupManifest, error)
- func (be *XtrabackupEngine) ShouldDrainForBackup(req *tabletmanagerdatapb.BackupRequest) bool
Constants ¶
const ( // RestoreState is the name of the sentinel file used to detect whether a previous restore // terminated abnormally RestoreState = "restore_in_progress" // BackupTimestampFormat is the format in which we save BackupTime and FinishedTime BackupTimestampFormat = "2006-01-02.150405" )
const ( PgzipCompressor = "pgzip" PargzipCompressor = "pargzip" ZstdCompressor = "zstd" Lz4Compressor = "lz4" ExternalCompressor = "external" )
const ( GetColumnNamesQuery = `` /* 141-byte string literal not displayed */ GetFieldsQuery = "SELECT %s FROM %s WHERE 1 != 1" )
const (
AutoIncrementalFromPos = "auto"
)
Variables ¶
var ( // ErrNoBackup is returned when there is no backup. ErrNoBackup = errors.New("no available backup") // ErrNoCompleteBackup is returned when there is at least one backup, // but none of them are complete. ErrNoCompleteBackup = errors.New("backup(s) found but none are complete") EmptyBackupMessage = "no new data to backup, skipping it" )
var ( // CompressionEngineName specifies which compressor/decompressor to use CompressionEngineName = "pargzip" // ExternalCompressorCmd / ExternalDecompressorCmd specify the external commands compress/decompress the backups ExternalCompressorCmd string ExternalCompressorExt string ExternalDecompressorCmd string ManifestExternalDecompressorCmd string )
var ( // DisableActiveReparents is a flag to disable active // reparents for safety reasons. It is used in three places: // 1. in this file to skip registering the commands. // 2. in vtctld so it can be exported to the UI (different // package, that's why it's exported). That way we can disable // menu items there, using features. DisableActiveReparents bool // DbaIdleTimeout is how often we will refresh the DBA connpool connections DbaIdleTimeout = time.Minute // PoolDynamicHostnameResolution is whether we should retry DNS resolution of hostname targets // and reconnect if necessary PoolDynamicHostnameResolution time.Duration )
var BackupRestoreEngineMap = make(map[string]BackupRestoreEngine)
BackupRestoreEngineMap contains the registered implementations for BackupEngine and RestoreEngine.
var ( // BuiltinBackupMysqldTimeout is how long ExecuteBackup should wait for response from mysqld.Shutdown. // It can later be extended for other calls to mysqld during backup functions. // Exported for testing. BuiltinBackupMysqldTimeout = 10 * time.Minute )
Functions ¶
func Backup ¶
func Backup(ctx context.Context, params BackupParams) error
Backup is the main entry point for a backup: - uses the BackupStorage service to store a new backup - shuts down Mysqld during the backup - remember if we were replicating, restore the exact same state
func ChooseBinlogsForIncrementalBackup ¶ added in v0.16.0
func ChooseBinlogsForIncrementalBackup( ctx context.Context, backupFromGTIDSet replication.GTIDSet, purgedGTIDSet replication.GTIDSet, binaryLogs []string, pgtids func(ctx context.Context, binlog string) (gtids string, err error), ) ( binaryLogsToBackup []string, incrementalBackupFromGTID string, incrementalBackupToGTID string, err error, )
ChooseBinlogsForIncrementalBackup chooses which binary logs need to be backed up in an incremental backup, given a list of known binary logs, a function that returns the "Previous GTIDs" per binary log, and a position from which to backup (normally the position of last known backup) The function returns an error if the request could not be fulfilled: whether backup is not at all possible, or is empty.
func CreateMysqldAndMycnf ¶
func CreateMysqldAndMycnf(tabletUID uint32, mysqlSocket string, mysqlPort int, collationEnv *collations.Environment) (*Mysqld, *Mycnf, error)
CreateMysqldAndMycnf returns a Mysqld and a Mycnf object to use for working with a MySQL installation that hasn't been set up yet.
func DefaultTabletDirAtRoot ¶ added in v0.10.0
DefaultTabletDirAtRoot returns the default directory for a tablet given a UID and a VtDataRoot variable
func FindReplicas ¶
func FindReplicas(mysqld MysqlDaemon) ([]string, error)
FindReplicas gets IP addresses for all currently connected replicas.
func FormatRFC3339 ¶ added in v0.18.0
func GenerateInitialBinlogEntry ¶ added in v0.16.0
func GenerateInitialBinlogEntry() string
GenerateInitialBinlogEntry is used to create a binlog entry when a primary comes up and we need to get a MySQL position so that we can set it as the starting position for replicas to start MySQL Replication from.
func GetBackupDir ¶
GetBackupDir returns the directory where backups for the given keyspace/shard are (or will be) stored
func GetColumns ¶ added in v0.14.0
func GetColumnsList ¶ added in v0.14.0
func GetColumnsList(dbName, tableName string, exec func(string, int, bool) (*sqltypes.Result, error)) (string, error)
GetColumnsList returns the column names for a given table/view, using a query generating function. Returned values: - selectColumns: a string of comma delimited qualified names to be used in a SELECT query. e.g. "`id`, `name`, `val`" - err: error
func GetPermissions ¶
func GetPermissions(mysqld MysqlDaemon) (*tabletmanagerdatapb.Permissions, error)
GetPermissions lists the permissions on the mysqld. The rows are sorted in primary key order to help with comparing permissions between tablets.
func GetPrimaryKeyEquivalentColumns ¶ added in v0.19.0
func GetPrimaryKeyEquivalentColumns(ctx context.Context, exec func(string, int, bool) (*sqltypes.Result, error), dbName, table string) ([]string, string, error)
GetPrimaryKeyEquivalentColumns can be used if the table has no defined PRIMARY KEY. It will return the columns in a viable PRIMARY KEY equivalent (PKE) -- a NON-NULL UNIQUE KEY -- along with that index's name in the specified table. When multiple PKE indexes are available it will attempt to choose the most efficient one based on the column data types and the number of columns in the index. See here for the data type storage sizes:
https://dev.mysql.com/doc/refman/en/storage-requirements.html
If this function is used on a table that DOES have a defined PRIMARY KEY then it may return the columns for that index if it is likely the most efficient one amongst the available PKE indexes on the table.
func GetVersionString ¶ added in v0.8.0
GetVersionString runs mysqld --version and returns its output as a string
func IsValidIncrementalBakcup ¶ added in v0.16.0
func IsValidIncrementalBakcup(baseGTIDSet replication.GTIDSet, purgedGTIDSet replication.GTIDSet, manifest *BackupManifest) bool
IsValidIncrementalBakcup determines whether the given manifest can be used to extend a backup based on baseGTIDSet. The manifest must be able to pick up from baseGTIDSet, and must extend it by at least one entry.
func OpenMysqldAndMycnf ¶
func OpenMysqldAndMycnf(tabletUID uint32, collationEnv *collations.Environment) (*Mysqld, *Mycnf, error)
OpenMysqldAndMycnf returns a Mysqld and a Mycnf object to use for working with a MySQL installation that already exists. The Mycnf will be built based on the my.cnf file of the MySQL instance.
func ParseBackupName ¶ added in v0.11.0
func ParseBackupName(dir string, name string) (backupTime *time.Time, alias *topodatapb.TabletAlias, err error)
ParseBackupName parses the backup name for a given dir/name, according to the format generated by mysqlctl.Backup. An error is returned only if the backup name does not have the expected number of parts; errors parsing the timestamp and tablet alias are logged, and a nil value is returned for those fields in case of error.
func ParseBinlogTimestamp ¶ added in v0.18.0
func ParseVersionString ¶ added in v0.8.0
func ParseVersionString(version string) (flavor MySQLFlavor, ver ServerVersion, err error)
ParseVersionString parses the output of mysqld --version into a flavor and version
func PopulateReparentJournal ¶
func PopulateReparentJournal(timeCreatedNS int64, actionName, primaryAlias string, pos replication.Position) string
PopulateReparentJournal returns the SQL command to use to populate the reparent_journal table, as well as the time_created_ns value used.
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 ResolveTables ¶
func ResolveTables(ctx context.Context, mysqld MysqlDaemon, dbName string, tables []string) ([]string, error)
ResolveTables returns a list of actual tables+views matching a list of regexps
func RestoreWasInterrupted ¶
RestoreWasInterrupted tells us whether a previous restore was interrupted and we are now retrying it
func ShouldRestore ¶ added in v0.8.0
func ShouldRestore(ctx context.Context, params RestoreParams) (bool, error)
ShouldRestore checks whether a database with tables already exists and returns whether a restore action should be performed
func TopLevelDirs ¶
func TopLevelDirs() []string
TopLevelDirs returns the list of directories in the toplevel tablet directory that might be located in a different place.
func WaitForReplicationStart ¶
func WaitForReplicationStart(mysqld MysqlDaemon, replicaStartDeadline int) error
WaitForReplicationStart waits until the deadline for replication to start. This validates the current primary is correct and can be connected to.
Types ¶
type BackupEngine ¶
type BackupEngine interface { ExecuteBackup(ctx context.Context, params BackupParams, bh backupstorage.BackupHandle) (BackupResult, error) ShouldDrainForBackup(req *tabletmanagerdatapb.BackupRequest) bool }
BackupEngine is the interface to take a backup with a given engine.
func GetBackupEngine ¶
func GetBackupEngine() (BackupEngine, error)
GetBackupEngine returns the BackupEngine implementation that should be used to create new backups.
To restore a backup, you should instead get the appropriate RestoreEngine for a particular backup by calling GetRestoreEngine().
This must only be called after flags have been parsed.
type BackupManifest ¶
type BackupManifest struct { // BackupName is the name of the backup, which is also the name of the directory BackupName string // BackupMethod is the name of the backup engine that created this backup. // If this is empty, the backup engine is assumed to be "builtin" since that // was the only engine that ever left this field empty. All new backup // engines are required to set this field to the backup engine name. BackupMethod string // Position is the replication position at which the backup was taken. Position replication.Position // PurgedPosition stands for purged GTIDs, information that is necessary for PITR recovery. This is specific to MySQL56 PurgedPosition replication.Position // FromPosition is only applicable to incremental backups, and stands for the position from // which incremental changes are backed up. FromPosition replication.Position // FromBackup indicates the backup name on which this incremental backup is based, assumign this is an incremental backup with "auto" pos“ FromBackup string // Incremental indicates whether this is an incremental backup Incremental bool // BackupTime is when the backup was taken in UTC time (RFC 3339 format) BackupTime string // FinishedTime is the time (in RFC 3339 format, UTC) at which the backup finished, if known. // Some backups may not set this field if they were created before the field was added. FinishedTime string // ServerUUID identifies the server from which backup was taken ServerUUID string TabletAlias string Keyspace string Shard string // MySQLversion is the version of MySQL when the backup was taken. MySQLVersion string // UpgradeSafe indicates whether the backup is safe to use for an upgrade to a newer MySQL version UpgradeSafe bool // IncrementalDetails is nil for non-incremental backups IncrementalDetails *IncrementalBackupDetails }
BackupManifest defines the common fields in the MANIFEST file. All backup engines must include at least these fields. They are free to add their own custom fields by embedding this struct anonymously into their own custom struct, as long as their custom fields don't have conflicting names.
func FindPITRPath ¶ added in v0.16.0
func FindPITRPath(restoreToGTIDSet replication.GTIDSet, manifests [](*BackupManifest)) (shortestPath [](*BackupManifest), err error)
FindPITRPath evaluates the shortest path to recover a restoreToGTIDSet. The past is composed of: - a full backup, followed by: - zero or more incremental backups The path ends with restoreToGTIDSet or goes beyond it. No shorter path will do the same. The function returns an error when a path cannot be found.
func FindPITRToTimePath ¶ added in v0.18.0
func FindPITRToTimePath(restoreToTime time.Time, manifests [](*BackupManifest)) (shortestPath [](*BackupManifest), err error)
FindPITRToTimePath evaluates the shortest path to recover a restoreToGTIDSet. The past is composed of: - a full backup, followed by: - zero or more incremental backups The path ends with restoreToGTIDSet or goes beyond it. No shorter path will do the same. The function returns an error when a path cannot be found.
func GetBackupManifest ¶
func GetBackupManifest(ctx context.Context, backup backupstorage.BackupHandle) (*BackupManifest, error)
GetBackupManifest returns the common fields of the MANIFEST file for a given backup.
func Restore ¶
func Restore(ctx context.Context, params RestoreParams) (*BackupManifest, error)
Restore is the main entry point for backup restore. If there is no appropriate backup on the BackupStorage, Restore logs an error and returns ErrNoBackup. Any other error is returned.
func (*BackupManifest) HashKey ¶ added in v0.16.0
func (m *BackupManifest) HashKey() string
type BackupManifestPath ¶ added in v0.16.0
type BackupManifestPath []*BackupManifest
func (*BackupManifestPath) String ¶ added in v0.16.0
func (p *BackupManifestPath) String() string
type BackupParams ¶
type BackupParams struct { Cnf *Mycnf Mysqld MysqlDaemon Logger logutil.Logger // Concurrency is the value of -concurrency flag given to Backup command // It determines how many files are processed in parallel Concurrency int // Extra env variables used while stopping and starting mysqld HookExtraEnv map[string]string // TopoServer, Keyspace and Shard are used to discover primary tablet TopoServer *topo.Server // Keyspace and Shard are used to infer the directory where backups should be stored Keyspace string Shard string // TabletAlias is used along with backupTime to construct the backup name TabletAlias string // BackupTime is the time at which the backup is being started BackupTime time.Time // Position of last known backup. If non empty, then this value indicates the backup should be incremental // and as of this position IncrementalFromPos string // Stats let's backup engines report detailed backup timings. Stats backupstats.Stats // UpgradeSafe indicates whether the backup is safe for upgrade and created with innodb_fast_shutdown=0 UpgradeSafe bool // MysqlShutdownTimeout defines how long we wait during MySQL shutdown if that is part of the backup process. MysqlShutdownTimeout time.Duration }
BackupParams is the struct that holds all params passed to ExecuteBackup
func (*BackupParams) Copy ¶ added in v0.17.0
func (b *BackupParams) Copy() BackupParams
type BackupRestoreEngine ¶
type BackupRestoreEngine interface { BackupEngine RestoreEngine }
BackupRestoreEngine is a combination of BackupEngine and RestoreEngine.
type BackupResult ¶ added in v0.19.0
type BackupResult int
const ( BackupUnusable BackupResult = iota BackupEmpty BackupUsable )
type BuiltinBackupEngine ¶
type BuiltinBackupEngine struct { }
BuiltinBackupEngine encapsulates the logic of the builtin engine it implements the BackupEngine interface and contains all the logic required to implement a backup/restore by copying files from and to the correct location / storage bucket
func (*BuiltinBackupEngine) ExecuteBackup ¶
func (be *BuiltinBackupEngine) ExecuteBackup(ctx context.Context, params BackupParams, bh backupstorage.BackupHandle) (BackupResult, error)
ExecuteBackup runs a backup based on given params. This could be a full or incremental backup. The function returns a BackupResult that indicates the usability of the backup, and an overall error.
func (*BuiltinBackupEngine) ExecuteRestore ¶
func (be *BuiltinBackupEngine) ExecuteRestore(ctx context.Context, params RestoreParams, bh backupstorage.BackupHandle) (*BackupManifest, error)
ExecuteRestore restores from a backup. If the restore is successful we return the position from which replication should start otherwise an error is returned
func (*BuiltinBackupEngine) ShouldDrainForBackup ¶
func (be *BuiltinBackupEngine) ShouldDrainForBackup(req *tabletmanagerdatapb.BackupRequest) bool
ShouldDrainForBackup satisfies the BackupEngine interface backup requires query service to be stopped, hence true
type EmptyColumnsErr ¶ added in v0.15.4
type EmptyColumnsErr struct {
// contains filtered or unexported fields
}
func (EmptyColumnsErr) Error ¶ added in v0.15.4
func (e EmptyColumnsErr) Error() string
type FakeBackupEngine ¶ added in v0.17.0
type FakeBackupEngine struct { ExecuteBackupCalls []FakeBackupEngineExecuteBackupCall ExecuteBackupDuration time.Duration ExecuteBackupReturn FakeBackupEngineExecuteBackupReturn ExecuteRestoreCalls []FakeBackupEngineExecuteRestoreCall ExecuteRestoreDuration time.Duration ExecuteRestoreReturn FakeBackupEngineExecuteRestoreReturn ShouldDrainForBackupCalls int ShouldDrainForBackupReturn bool }
func (*FakeBackupEngine) ExecuteBackup ¶ added in v0.17.0
func (be *FakeBackupEngine) ExecuteBackup( ctx context.Context, params BackupParams, bh backupstorage.BackupHandle, ) (BackupResult, error)
func (*FakeBackupEngine) ExecuteRestore ¶ added in v0.17.0
func (be *FakeBackupEngine) ExecuteRestore( ctx context.Context, params RestoreParams, bh backupstorage.BackupHandle, ) (*BackupManifest, error)
func (*FakeBackupEngine) ShouldDrainForBackup ¶ added in v0.17.0
func (be *FakeBackupEngine) ShouldDrainForBackup(req *tabletmanagerdatapb.BackupRequest) bool
type FakeBackupEngineExecuteBackupCall ¶ added in v0.17.0
type FakeBackupEngineExecuteBackupCall struct { BackupParams BackupParams BackupHandle backupstorage.BackupHandle }
type FakeBackupEngineExecuteBackupReturn ¶ added in v0.17.0
type FakeBackupEngineExecuteBackupReturn struct { Res BackupResult Err error }
type FakeBackupEngineExecuteRestoreCall ¶ added in v0.17.0
type FakeBackupEngineExecuteRestoreCall struct { BackupHandle backupstorage.BackupHandle RestoreParams RestoreParams }
type FakeBackupEngineExecuteRestoreReturn ¶ added in v0.17.0
type FakeBackupEngineExecuteRestoreReturn struct { Manifest *BackupManifest Err error }
type FakeBackupHandle ¶ added in v0.17.0
type FakeBackupHandle struct { Dir string NameV string ReadOnly bool Errors concurrency.AllErrorRecorder AbortBackupCalls []context.Context AbortBackupReturn error AddFileCalls []FakeBackupHandleAddFileCall AddFileReturn FakeBackupHandleAddFileReturn EndBackupCalls []context.Context EndBackupReturn error ReadFileCalls []FakeBackupHandleReadFileCall ReadFileReturnF func(ctx context.Context, filename string) (io.ReadCloser, error) }
func (*FakeBackupHandle) AbortBackup ¶ added in v0.17.0
func (fbh *FakeBackupHandle) AbortBackup(ctx context.Context) error
func (*FakeBackupHandle) AddFile ¶ added in v0.17.0
func (fbh *FakeBackupHandle) AddFile(ctx context.Context, filename string, filesize int64) (io.WriteCloser, error)
func (*FakeBackupHandle) Directory ¶ added in v0.17.0
func (fbh *FakeBackupHandle) Directory() string
func (*FakeBackupHandle) EndBackup ¶ added in v0.17.0
func (fbh *FakeBackupHandle) EndBackup(ctx context.Context) error
func (*FakeBackupHandle) Error ¶ added in v0.17.0
func (fbh *FakeBackupHandle) Error() error
func (*FakeBackupHandle) HasErrors ¶ added in v0.17.0
func (fbh *FakeBackupHandle) HasErrors() bool
func (*FakeBackupHandle) Name ¶ added in v0.17.0
func (fbh *FakeBackupHandle) Name() string
func (*FakeBackupHandle) ReadFile ¶ added in v0.17.0
func (fbh *FakeBackupHandle) ReadFile(ctx context.Context, filename string) (io.ReadCloser, error)
func (*FakeBackupHandle) RecordError ¶ added in v0.17.0
func (fbh *FakeBackupHandle) RecordError(err error)
type FakeBackupHandleAddFileCall ¶ added in v0.17.0
type FakeBackupHandleAddFileReturn ¶ added in v0.17.0
type FakeBackupHandleAddFileReturn struct { WriteCloser io.WriteCloser Err error }
type FakeBackupHandleReadFileCall ¶ added in v0.17.0
type FakeBackupStorage ¶ added in v0.17.0
type FakeBackupStorage struct { CloseCalls int CloseReturn error ListBackupsCalls []FakeBackupStorageListBackupsCall ListBackupsReturn FakeBackupStorageListBackupsReturn RemoveBackupCalls []FakeBackupStorageRemoveBackupCall RemoveBackupReturn error RemoveBackupReturne error StartBackupCalls []FakeBackupStorageStartBackupCall StartBackupReturn FakeBackupStorageStartBackupReturn WithParamsCalls []backupstorage.Params WithParamsReturn backupstorage.BackupStorage }
func (*FakeBackupStorage) Close ¶ added in v0.17.0
func (fbs *FakeBackupStorage) Close() error
func (*FakeBackupStorage) ListBackups ¶ added in v0.17.0
func (fbs *FakeBackupStorage) ListBackups(ctx context.Context, dir string) ([]backupstorage.BackupHandle, error)
func (*FakeBackupStorage) RemoveBackup ¶ added in v0.17.0
func (fbs *FakeBackupStorage) RemoveBackup(ctx context.Context, dir, name string) error
func (*FakeBackupStorage) StartBackup ¶ added in v0.17.0
func (fbs *FakeBackupStorage) StartBackup(ctx context.Context, dir, name string) (backupstorage.BackupHandle, error)
func (*FakeBackupStorage) WithParams ¶ added in v0.17.0
func (fbs *FakeBackupStorage) WithParams(params backupstorage.Params) backupstorage.BackupStorage
type FakeBackupStorageListBackupsCall ¶ added in v0.17.0
type FakeBackupStorageListBackupsReturn ¶ added in v0.17.0
type FakeBackupStorageListBackupsReturn struct { BackupHandles []backupstorage.BackupHandle Err error }
type FakeBackupStorageRemoveBackupCall ¶ added in v0.17.0
type FakeBackupStorageStartBackupCall ¶ added in v0.17.0
type FakeBackupStorageStartBackupReturn ¶ added in v0.17.0
type FakeBackupStorageStartBackupReturn struct { BackupHandle backupstorage.BackupHandle Err error }
type FakeMysqlDaemon ¶ added in v0.17.0
type FakeMysqlDaemon struct { // Running is used by Start / Shutdown. Running bool // StartupTime is used to simulate mysqlds that take some time to // respond to a "start" command. It is used by Start. StartupTime time.Duration // ShutdownTime is used to simulate mysqlds that take some time // to respond to a "stop" request (i.e. a wedged systemd unit). // It is used by Shutdown. ShutdownTime time.Duration // MysqlPort will be returned by GetMysqlPort(). Set to -1 to // return an error. MysqlPort atomic.Int32 // Replicating is updated when calling StartReplication / // StopReplication (it is not used at all when calling // ReplicationStatus, it is the test owner responsibility //to have these two match) Replicating bool // IOThreadRunning is always true except in one testcase where // we want to test error handling during SetReplicationSource. IOThreadRunning bool // CurrentPrimaryPosition is returned by PrimaryPosition // and ReplicationStatus. CurrentPrimaryPosition replication.Position // CurrentSourceFilePosition is used to determine the executed // file based positioning of the replication source. CurrentSourceFilePosition replication.Position // ReplicationStatusError is used by ReplicationStatus. ReplicationStatusError error // StartReplicationError is used by StartReplication. StartReplicationError error // PromoteLag is the time for which Promote will stall. PromoteLag time.Duration // PrimaryStatusError is used by PrimaryStatus. PrimaryStatusError error // CurrentSourceHost is returned by ReplicationStatus. CurrentSourceHost string // CurrentSourcePort is returned by ReplicationStatus. CurrentSourcePort int32 // ReplicationLagSeconds is returned by ReplicationStatus. ReplicationLagSeconds uint32 // ReadOnly is the current value of the flag. ReadOnly bool // SuperReadOnly is the current value of the flag. SuperReadOnly atomic.Bool // SetReplicationPositionPos is matched against the input of // SetReplicationPosition. If it doesn't match, SetReplicationPosition // will return an error. SetReplicationPositionPos replication.Position // StartReplicationUntilAfterPos is matched against the input. StartReplicationUntilAfterPos replication.Position // SetReplicationSourceInputs are matched against the input of // SetReplicationSource (as "%v:%v"). If all of them don't // match, SetReplicationSource will return an error. SetReplicationSourceInputs []string // SetReplicationSourceError is used by SetReplicationSource. SetReplicationSourceError error // StopReplicationError error is used by StopReplication. StopReplicationError error // WaitPrimaryPositions is checked by WaitSourcePos, if the value // is found in it, then the function returns nil, else the // function returns an error. WaitPrimaryPositions []replication.Position // PromoteResult is returned by Promote. PromoteResult replication.Position // PromoteError is used by Promote. PromoteError error // SchemaFunc provides the return value for GetSchema. // If not defined, the "Schema" field will be used instead, see // below. SchemaFunc func() (*tabletmanagerdatapb.SchemaDefinition, error) // Schema will be returned by GetSchema. If nil we'll // return an error. Schema *tabletmanagerdatapb.SchemaDefinition // PreflightSchemaChangeResult will be returned by // PreflightSchemaChange. If nil we'll return an error. PreflightSchemaChangeResult []*tabletmanagerdatapb.SchemaChangeResult // ApplySchemaChangeResult will be returned by ApplySchemaChange. // If nil we'll return an error. ApplySchemaChangeResult *tabletmanagerdatapb.SchemaChangeResult // ExpectedExecuteSuperQueryList is what we expect // ExecuteSuperQueryList to be called with. If it doesn't // match, ExecuteSuperQueryList will return an error. // Note each string is just a substring if it begins with SUB, // so we support partial queries (useful when queries contain // data fields like timestamps). ExpectedExecuteSuperQueryList []string // ExpectedExecuteSuperQueryCurrent is the current index of the // queries we expect. ExpectedExecuteSuperQueryCurrent int // FetchSuperQueryResults is used by FetchSuperQuery. FetchSuperQueryMap map[string]*sqltypes.Result // SemiSyncPrimaryEnabled represents the state of rpl_semi_sync_master_enabled. SemiSyncPrimaryEnabled bool // SemiSyncReplicaEnabled represents the state of rpl_semi_sync_slave_enabled. SemiSyncReplicaEnabled bool // TimeoutHook is a func that can be called at the beginning of // any method to fake a timeout. // All a test needs to do is make it { return context.DeadlineExceeded }. TimeoutHook func() error // Version is the version that will be returned by GetVersionString. Version string // contains filtered or unexported fields }
FakeMysqlDaemon implements MysqlDaemon and allows the user to fake everything.
func NewFakeMysqlDaemon ¶ added in v0.17.0
func NewFakeMysqlDaemon(db *fakesqldb.DB) *FakeMysqlDaemon
NewFakeMysqlDaemon returns a FakeMysqlDaemon where mysqld appears to be running, based on a fakesqldb.DB. 'db' can be nil if the test doesn't use a database at all.
func (*FakeMysqlDaemon) ApplyBinlogFile ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) ApplyBinlogFile(ctx context.Context, req *mysqlctlpb.ApplyBinlogFileRequest) error
ApplyBinlogFile is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) ApplySchemaChange ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) ApplySchemaChange(ctx context.Context, dbName string, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error)
ApplySchemaChange is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) CheckSuperQueryList ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) CheckSuperQueryList() error
CheckSuperQueryList returns an error if all the queries we expected haven't been seen.
func (*FakeMysqlDaemon) Close ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) Close()
Close is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) CurrentPrimaryPositionLocked ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) CurrentPrimaryPositionLocked(pos replication.Position)
CurrentPrimaryPositionLocked is thread-safe.
func (*FakeMysqlDaemon) ExecuteSuperQueryList ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) ExecuteSuperQueryList(ctx context.Context, queryList []string) error
ExecuteSuperQueryList is part of the MysqlDaemon interface
func (*FakeMysqlDaemon) FetchSuperQuery ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) FetchSuperQuery(ctx context.Context, query string) (*sqltypes.Result, error)
FetchSuperQuery returns the results from the map, if any.
func (*FakeMysqlDaemon) FlushBinaryLogs ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) FlushBinaryLogs(ctx context.Context) (err error)
FlushBinaryLogs is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetAllPrivsConnection ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetAllPrivsConnection(ctx context.Context) (*dbconnpool.DBConnection, error)
GetAllPrivsConnection is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetAppConnection ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetAppConnection(ctx context.Context) (*dbconnpool.PooledDBConnection, error)
GetAppConnection is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetBinaryLogs ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetBinaryLogs(ctx context.Context) (binaryLogs []string, err error)
GetBinaryLogs is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetBinlogInformation ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetBinlogInformation(ctx context.Context) (binlogFormat string, logEnabled bool, logReplicaUpdate bool, binlogRowImage string, err error)
GetBinlogInformation is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetColumns ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetColumns(ctx context.Context, dbName, table string) ([]*querypb.Field, []string, error)
GetColumns is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetDbaConnection ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetDbaConnection(ctx context.Context) (*dbconnpool.DBConnection, error)
GetDbaConnection is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetGTIDMode ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetGTIDMode(ctx context.Context) (gtidMode string, err error)
GetGTIDMode is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetGTIDPurged ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetGTIDPurged(ctx context.Context) (replication.Position, error)
GetGTIDPurged is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetMysqlPort ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetMysqlPort() (int32, error)
GetMysqlPort is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetPreviousGTIDs ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetPreviousGTIDs(ctx context.Context, binlog string) (previousGtids string, err error)
GetPreviousGTIDs is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetPrimaryKeyColumns ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetPrimaryKeyColumns(ctx context.Context, dbName, table string) ([]string, error)
GetPrimaryKeyColumns is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetPrimaryKeyEquivalentColumns ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetPrimaryKeyEquivalentColumns(ctx context.Context, dbName, table string) ([]string, string, error)
GetPrimaryKeyEquivalentColumns is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetSchema ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetSchema(ctx context.Context, dbName string, request *tabletmanagerdatapb.GetSchemaRequest) (*tabletmanagerdatapb.SchemaDefinition, error)
GetSchema is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetServerID ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetServerID(ctx context.Context) (uint32, error)
GetServerID is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetServerUUID ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetServerUUID(ctx context.Context) (string, error)
GetServerUUID is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetVersionComment ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetVersionComment(ctx context.Context) (string, error)
GetVersionComment is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) GetVersionString ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) GetVersionString(ctx context.Context) (string, error)
GetVersionString is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) IsReadOnly ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) IsReadOnly() (bool, error)
IsReadOnly is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) IsSuperReadOnly ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) IsSuperReadOnly() (bool, error)
IsSuperReadOnly is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) PreflightSchemaChange ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) PreflightSchemaChange(ctx context.Context, dbName string, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)
PreflightSchemaChange is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) PrimaryPosition ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) PrimaryPosition() (replication.Position, error)
PrimaryPosition is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) PrimaryStatus ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) PrimaryStatus(ctx context.Context) (replication.PrimaryStatus, error)
PrimaryStatus is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) Promote ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) Promote(hookExtraEnv map[string]string) (replication.Position, error)
Promote is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) ReadBinlogFilesTimestamps ¶ added in v0.18.0
func (fmd *FakeMysqlDaemon) ReadBinlogFilesTimestamps(ctx context.Context, req *mysqlctlpb.ReadBinlogFilesTimestampsRequest) (*mysqlctlpb.ReadBinlogFilesTimestampsResponse, error)
ReadBinlogFilesTimestamps is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) RefreshConfig ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) RefreshConfig(ctx context.Context, cnf *Mycnf) error
RefreshConfig is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) ReinitConfig ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) ReinitConfig(ctx context.Context, cnf *Mycnf) error
ReinitConfig is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) ReplicationStatus ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) ReplicationStatus() (replication.ReplicationStatus, error)
ReplicationStatus is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) ResetReplication ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) ResetReplication(ctx context.Context) error
ResetReplication is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) ResetReplicationParameters ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) ResetReplicationParameters(ctx context.Context) error
ResetReplicationParameters is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) RestartReplication ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) RestartReplication(hookExtraEnv map[string]string) error
RestartReplication is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) RunMysqlUpgrade ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) RunMysqlUpgrade(ctx context.Context) error
RunMysqlUpgrade is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) SemiSyncClients ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) SemiSyncClients() uint32
SemiSyncClients is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) SemiSyncEnabled ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) SemiSyncEnabled() (primary, replica bool)
SemiSyncEnabled is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) SemiSyncExtensionLoaded ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) SemiSyncExtensionLoaded() (bool, error)
SemiSyncExtensionLoaded is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) SemiSyncReplicationStatus ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) SemiSyncReplicationStatus() (bool, error)
SemiSyncReplicationStatus is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) SemiSyncSettings ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) SemiSyncSettings() (timeout uint64, numReplicas uint32)
SemiSyncSettings is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) SemiSyncStatus ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) SemiSyncStatus() (bool, bool)
SemiSyncStatus is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) SetReadOnly ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) SetReadOnly(on bool) error
SetReadOnly is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) SetReplicationPosition ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) SetReplicationPosition(ctx context.Context, pos replication.Position) error
SetReplicationPosition is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) SetReplicationSource ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) SetReplicationSource(ctx context.Context, host string, port int32, stopReplicationBefore bool, startReplicationAfter bool) error
SetReplicationSource is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) SetSemiSyncEnabled ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) SetSemiSyncEnabled(primary, replica bool) error
SetSemiSyncEnabled is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) SetSuperReadOnly ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) SetSuperReadOnly(on bool) (ResetSuperReadOnlyFunc, error)
SetSuperReadOnly is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) Shutdown ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) Shutdown(ctx context.Context, cnf *Mycnf, waitForMysqld bool, mysqlShutdownTimeout time.Duration) error
Shutdown is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) StartReplication ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) StartReplication(hookExtraEnv map[string]string) error
StartReplication is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) StartReplicationUntilAfter ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) StartReplicationUntilAfter(ctx context.Context, pos replication.Position) error
StartReplicationUntilAfter is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) StopIOThread ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) StopIOThread(ctx context.Context) error
StopIOThread is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) StopReplication ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) StopReplication(hookExtraEnv map[string]string) error
StopReplication is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) Wait ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) Wait(ctx context.Context, cnf *Mycnf) error
Wait is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) WaitForReparentJournal ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) WaitForReparentJournal(ctx context.Context, timeCreatedNS int64) error
WaitForReparentJournal is part of the MysqlDaemon interface.
func (*FakeMysqlDaemon) WaitSourcePos ¶ added in v0.17.0
func (fmd *FakeMysqlDaemon) WaitSourcePos(_ context.Context, pos replication.Position) error
WaitSourcePos is part of the MysqlDaemon interface.
type FileEntry ¶
type FileEntry struct { // Base is one of: // - backupInnodbDataHomeDir for files that go into Mycnf.InnodbDataHomeDir // - backupInnodbLogGroupHomeDir for files that go into Mycnf.InnodbLogGroupHomeDir // - binLogDir for files that go in the binlog dir (base path of Mycnf.BinLogPath) // - backupData for files that go into Mycnf.DataDir Base string // Name is the file name, relative to Base Name string // Hash is the hash of the final data (transformed and // compressed if specified) stored in the BackupStorage. Hash string // ParentPath is an optional prefix to the Base path. If empty, it is ignored. Useful // for writing files in a temporary directory ParentPath string }
FileEntry is one file to backup
type IncrementalBackupDetails ¶ added in v0.18.0
type IncrementalBackupDetails struct { FirstTimestamp string FirstTimestampBinlog string LastTimestamp string LastTimestampBinlog string }
IncrementalBackupDetails lists some incremental backup specific information
type ManifestHandleMap ¶ added in v0.16.0
type ManifestHandleMap struct {
// contains filtered or unexported fields
}
ManifestHandleMap is a utility container to map manifests to handles, making it possible to search for, and iterate, handles based on manifests.
func NewManifestHandleMap ¶ added in v0.16.0
func NewManifestHandleMap() *ManifestHandleMap
func (*ManifestHandleMap) Handle ¶ added in v0.16.0
func (m *ManifestHandleMap) Handle(manifest *BackupManifest) (handle backupstorage.BackupHandle)
Handle returns the backup handles assigned to given manifest
func (*ManifestHandleMap) Handles ¶ added in v0.16.0
func (m *ManifestHandleMap) Handles(manifests []*BackupManifest) (handles []backupstorage.BackupHandle)
Handles returns an ordered list of handles, by given list of manifests
func (*ManifestHandleMap) Map ¶ added in v0.16.0
func (m *ManifestHandleMap) Map(manifest *BackupManifest, handle backupstorage.BackupHandle)
Map assigns a handle to a manifest
type MySQLFlavor ¶ added in v0.14.0
type MySQLFlavor string
const ( FlavorMySQL MySQLFlavor = "mysql" FlavorPercona MySQLFlavor = "percona" FlavorMariaDB MySQLFlavor = "mariadb" )
Flavor constants define the type of mysql flavor being used
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 // SecureFilePriv is the path for loading secure files // (used by vt software for bulk loading into tablet instances) SecureFilePriv string // SocketFile is the path to the local mysql.sock file. // (used by vt software to check server is running) SocketFile string // GeneralLogPath is the path to store general logs at, // if general-log is enabled. // (unused by vt software for now) GeneralLogPath 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) BinLogPath string // MasterInfoFile is the master.info file location. // Unused when vitess manages mysql config because we set // master_info_repository = TABLE and // relay_log_info_repository = TABLE // However it is possible to use custom cnf files with vitess // and to generate them using command-line flags, so we allow a way to set this property 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 Path string // the actual path that represents this mycnf // 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.
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.
func ReadMycnf ¶
ReadMycnf will read an existing my.cnf from disk, and update the passed in Mycnf object with values from the my.cnf on disk.
func (*Mycnf) RandomizeMysqlServerID ¶
RandomizeMysqlServerID generates a random MySQL server_id.
The value assigned to ServerID will be in the range [100, 2^31): - It avoids 0 because that's reserved for mysqlbinlog dumps. - It also avoids 1-99 because low numbers are used for fake connections. See NewBinlogConnection() in binlog/binlog_connection.go for more on that. - It avoids the 2^31 - 2^32-1 range, as there seems to be some confusion there. The main MySQL documentation at: http://dev.mysql.com/doc/refman/5.7/en/replication-options.html implies serverID is a full 32 bits number. The semi-sync log line at startup '[Note] Start semi-sync binlog_dump to slave ...' interprets the server_id as signed 32-bit (shows negative numbers for that range). Such an ID may also be responsible for a mysqld crash in semi-sync code, although we haven't been able to verify that yet. The issue for that is: https://github.com/vitessio/vitess/issues/2280
type MysqlDaemon ¶
type MysqlDaemon interface { // methods related to mysql running or not Start(ctx context.Context, cnf *Mycnf, mysqldArgs ...string) error Shutdown(ctx context.Context, cnf *Mycnf, waitForMysqld bool, mysqlShutdownTimeout time.Duration) error RunMysqlUpgrade(ctx context.Context) error ApplyBinlogFile(ctx context.Context, req *mysqlctlpb.ApplyBinlogFileRequest) error ReadBinlogFilesTimestamps(ctx context.Context, req *mysqlctlpb.ReadBinlogFilesTimestampsRequest) (*mysqlctlpb.ReadBinlogFilesTimestampsResponse, error) ReinitConfig(ctx context.Context, cnf *Mycnf) error Wait(ctx context.Context, cnf *Mycnf) error // GetMysqlPort returns the current port mysql is listening on. GetMysqlPort() (int32, error) // GetServerID returns the servers ID. GetServerID(ctx context.Context) (uint32, error) // GetServerUUID returns the servers UUID GetServerUUID(ctx context.Context) (string, error) // replication related methods StartReplication(hookExtraEnv map[string]string) error RestartReplication(hookExtraEnv map[string]string) error StartReplicationUntilAfter(ctx context.Context, pos replication.Position) error StopReplication(hookExtraEnv map[string]string) error StopIOThread(ctx context.Context) error ReplicationStatus() (replication.ReplicationStatus, error) PrimaryStatus(ctx context.Context) (replication.PrimaryStatus, error) GetGTIDPurged(ctx context.Context) (replication.Position, error) SetSemiSyncEnabled(source, replica bool) error SemiSyncEnabled() (source, replica bool) SemiSyncExtensionLoaded() (bool, error) SemiSyncStatus() (source, replica bool) SemiSyncClients() (count uint32) SemiSyncSettings() (timeout uint64, numReplicas uint32) SemiSyncReplicationStatus() (bool, error) ResetReplicationParameters(ctx context.Context) error GetBinlogInformation(ctx context.Context) (binlogFormat string, logEnabled bool, logReplicaUpdate bool, binlogRowImage string, err error) GetGTIDMode(ctx context.Context) (gtidMode string, err error) FlushBinaryLogs(ctx context.Context) (err error) GetBinaryLogs(ctx context.Context) (binaryLogs []string, err error) GetPreviousGTIDs(ctx context.Context, binlog string) (previousGtids string, err error) // reparenting related methods ResetReplication(ctx context.Context) error PrimaryPosition() (replication.Position, error) IsReadOnly() (bool, error) IsSuperReadOnly() (bool, error) SetReadOnly(on bool) error SetSuperReadOnly(on bool) (ResetSuperReadOnlyFunc, error) SetReplicationPosition(ctx context.Context, pos replication.Position) error SetReplicationSource(ctx context.Context, host string, port int32, stopReplicationBefore bool, startReplicationAfter bool) error WaitForReparentJournal(ctx context.Context, timeCreatedNS int64) error WaitSourcePos(context.Context, replication.Position) error // Promote makes the current server the primary. It will not change // the read_only state of the server. Promote(map[string]string) (replication.Position, error) // Schema related methods GetSchema(ctx context.Context, dbName string, request *tabletmanagerdatapb.GetSchemaRequest) (*tabletmanagerdatapb.SchemaDefinition, error) GetColumns(ctx context.Context, dbName, table string) ([]*querypb.Field, []string, error) GetPrimaryKeyColumns(ctx context.Context, dbName, table string) ([]string, error) PreflightSchemaChange(ctx context.Context, dbName string, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error) ApplySchemaChange(ctx context.Context, dbName string, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error) // GetAppConnection returns a app connection to be able to talk to the database. GetAppConnection(ctx context.Context) (*dbconnpool.PooledDBConnection, error) // GetDbaConnection returns a dba connection. GetDbaConnection(ctx context.Context) (*dbconnpool.DBConnection, error) // GetAllPrivsConnection returns an allprivs connection (for user with all privileges except SUPER). GetAllPrivsConnection(ctx context.Context) (*dbconnpool.DBConnection, error) // GetVersionString returns the database version as a string GetVersionString(ctx context.Context) (string, error) // GetVersionComment returns the version comment GetVersionComment(ctx context.Context) (string, error) // ExecuteSuperQueryList executes a list of queries, no result ExecuteSuperQueryList(ctx context.Context, queryList []string) error // FetchSuperQuery executes one query, returns the result FetchSuperQuery(ctx context.Context, query string) (*sqltypes.Result, error) // Close will close this instance of Mysqld. It will wait for all dba // queries to be finished. Close() }
MysqlDaemon is the interface we use for abstracting Mysqld.
type Mysqld ¶
type Mysqld struct {
// contains filtered or unexported fields
}
Mysqld is the object that represents a mysqld daemon running on this server.
func NewMysqld ¶
NewMysqld creates a Mysqld object based on the provided configuration and connection parameters.
func (*Mysqld) ApplyBinlogFile ¶ added in v0.17.0
func (mysqld *Mysqld) ApplyBinlogFile(ctx context.Context, req *mysqlctlpb.ApplyBinlogFileRequest) error
ApplyBinlogFile extracts a binary log file and applies it to MySQL. It is the equivalent of: $ mysqlbinlog --include-gtids binlog.file | mysql
func (*Mysqld) ApplySchemaChange ¶
func (mysqld *Mysqld) ApplySchemaChange(ctx context.Context, dbName string, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error)
ApplySchemaChange will apply the schema change to the given database.
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) DisableRedoLog ¶ added in v0.16.0
func (*Mysqld) EnableRedoLog ¶ added in v0.16.0
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) FetchSuperQuery ¶
FetchSuperQuery returns the results of executing a query as a super user.
func (*Mysqld) FlushBinaryLogs ¶ added in v0.16.0
FlushBinaryLogs is part of the MysqlDaemon interface.
func (*Mysqld) GetAllPrivsConnection ¶
func (mysqld *Mysqld) GetAllPrivsConnection(ctx context.Context) (*dbconnpool.DBConnection, error)
GetAllPrivsConnection creates a new DBConnection.
func (*Mysqld) GetAppConnection ¶
func (mysqld *Mysqld) GetAppConnection(ctx context.Context) (*dbconnpool.PooledDBConnection, error)
GetAppConnection returns a connection from the app pool. Recycle needs to be called on the result.
func (*Mysqld) GetBinaryLogs ¶ added in v0.16.0
GetBinaryLogs is part of the MysqlDaemon interface.
func (*Mysqld) GetBinlogInformation ¶ added in v0.14.0
GetBinlogInformation gets the binlog format, whether binlog is enabled and if updates on replica logging is enabled.
func (*Mysqld) GetColumns ¶
func (mysqld *Mysqld) GetColumns(ctx context.Context, dbName, table string) ([]*querypb.Field, []string, error)
GetColumns returns the columns of table.
func (*Mysqld) GetDbaConnection ¶
func (mysqld *Mysqld) GetDbaConnection(ctx context.Context) (*dbconnpool.DBConnection, error)
GetDbaConnection creates a new DBConnection.
func (*Mysqld) GetGTIDMode ¶ added in v0.14.0
GetGTIDMode gets the GTID mode for the server
func (*Mysqld) GetGTIDPurged ¶ added in v0.14.0
GetGTIDPurged returns the gtid purged statuses
func (*Mysqld) GetMysqlPort ¶
GetMysqlPort returns mysql port
func (*Mysqld) GetPreviousGTIDs ¶ added in v0.16.0
func (mysqld *Mysqld) GetPreviousGTIDs(ctx context.Context, binlog string) (previousGtids string, err error)
GetPreviousGTIDs is part of the MysqlDaemon interface.
func (*Mysqld) GetPrimaryKeyColumns ¶
func (mysqld *Mysqld) GetPrimaryKeyColumns(ctx context.Context, dbName, table string) ([]string, error)
GetPrimaryKeyColumns returns the primary key columns of table.
func (*Mysqld) GetSchema ¶
func (mysqld *Mysqld) GetSchema(ctx context.Context, dbName string, request *tabletmanagerdatapb.GetSchemaRequest) (*tabletmanagerdatapb.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) GetServerID ¶ added in v0.14.0
GetServerID returns mysql server id
func (*Mysqld) GetServerUUID ¶ added in v0.14.0
GetServerUUID returns mysql server uuid
func (*Mysqld) GetVersionComment ¶ added in v0.14.0
GetVersionComment gets the version comment.
func (*Mysqld) GetVersionString ¶ added in v0.12.1
GetVersionString is part of the MysqlExecutor interface.
func (*Mysqld) Init ¶
Init will create the default directory structure for the mysqld process, generate / configure a my.cnf file install a skeleton database, and apply the provided initial SQL file.
func (*Mysqld) InitConfig ¶
InitConfig will create the default directory structure for the mysqld process, generate / configure a my.cnf file.
func (*Mysqld) IsReadOnly ¶
IsReadOnly return true if the instance is read only
func (*Mysqld) IsSuperReadOnly ¶ added in v0.17.0
IsSuperReadOnly return true if the instance is super read only
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(ctx context.Context, dbName string, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)
PreflightSchemaChange checks the schema changes in "changes" by applying them to an intermediate database that has the same schema as the target database.
func (*Mysqld) PrimaryPosition ¶ added in v0.11.0
func (mysqld *Mysqld) PrimaryPosition() (replication.Position, error)
PrimaryPosition returns the primary replication position.
func (*Mysqld) PrimaryStatus ¶ added in v0.11.0
func (mysqld *Mysqld) PrimaryStatus(ctx context.Context) (replication.PrimaryStatus, error)
PrimaryStatus returns the primary replication statuses
func (*Mysqld) ProcessCanDisableRedoLog ¶ added in v0.16.0
func (*Mysqld) ReadBinlogFilesTimestamps ¶ added in v0.18.0
func (mysqld *Mysqld) ReadBinlogFilesTimestamps(ctx context.Context, req *mysqlctlpb.ReadBinlogFilesTimestampsRequest) (*mysqlctlpb.ReadBinlogFilesTimestampsResponse, error)
ReadBinlogFilesTimestamps reads all given binlog files via `mysqlbinlog` command and returns the first and last found transaction timestamps
func (*Mysqld) RefreshConfig ¶
RefreshConfig attempts to recreate the my.cnf from templates, and log and swap in to place if it's updated. It keeps a copy of the last version in case fallback is required. Should be called from a stable replica, server_id is not regenerated.
func (*Mysqld) ReinitConfig ¶
ReinitConfig updates the config file as if Mysqld is initializing. At the moment it only randomizes ServerID because it's not safe to restore a replica from a backup and then give it the same ServerID as before, MySQL can then skip transactions in the replication stream with the same server_id.
func (*Mysqld) ReplicationStatus ¶
func (mysqld *Mysqld) ReplicationStatus() (replication.ReplicationStatus, error)
ReplicationStatus returns the server replication status
func (*Mysqld) ResetReplication ¶
ResetReplication resets all replication for this host.
func (*Mysqld) ResetReplicationParameters ¶ added in v0.14.0
ResetReplicationParameters resets the replica replication parameters for this host.
func (*Mysqld) RestartReplication ¶
RestartReplication stops, resets and starts replication.
func (*Mysqld) RunMysqlUpgrade ¶
RunMysqlUpgrade will run the mysql_upgrade program on the current install. Will be called only when mysqld is running with no network and no grant tables.
func (*Mysqld) SemiSyncClients ¶ added in v0.14.0
SemiSyncClients returns the number of semi-sync clients for the primary.
func (*Mysqld) SemiSyncEnabled ¶
SemiSyncEnabled returns whether semi-sync is enabled for primary or replica. If the semi-sync plugin is not loaded, we assume semi-sync is disabled.
func (*Mysqld) SemiSyncExtensionLoaded ¶ added in v0.15.5
SemiSyncExtensionLoaded returns whether semi-sync plugins are loaded.
func (*Mysqld) SemiSyncReplicationStatus ¶
SemiSyncReplicationStatus returns whether semi-sync is currently used by replication.
func (*Mysqld) SemiSyncSettings ¶ added in v0.14.0
SemiSyncSettings returns the settings of semi-sync which includes the timeout and the number of replicas to wait for.
func (*Mysqld) SemiSyncStatus ¶ added in v0.14.0
SemiSyncStatus returns the current status of semi-sync for primary and replica.
func (*Mysqld) SetReadOnly ¶
SetReadOnly set/unset the read_only flag
func (*Mysqld) SetReplicationPosition ¶
SetReplicationPosition sets the replication position at which the replica will resume when its replication is started.
func (*Mysqld) SetReplicationSource ¶ added in v0.11.0
func (mysqld *Mysqld) SetReplicationSource(ctx context.Context, host string, port int32, stopReplicationBefore bool, startReplicationAfter bool) error
SetReplicationSource makes the provided host / port the primary. It optionally stops replication before, and starts it after.
func (*Mysqld) SetSemiSyncEnabled ¶
SetSemiSyncEnabled enables or disables semi-sync replication for primary and/or replica mode.
func (*Mysqld) SetSuperReadOnly ¶
func (mysqld *Mysqld) SetSuperReadOnly(on bool) (ResetSuperReadOnlyFunc, error)
SetSuperReadOnly set/unset the super_read_only flag. Returns a function which is called to set super_read_only back to its original value.
func (*Mysqld) Shutdown ¶
func (mysqld *Mysqld) Shutdown(ctx context.Context, cnf *Mycnf, waitForMysqld bool, shutdownTimeout time.Duration) error
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) 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. When waiting for mysqld to start, we will use the dba user.
func (*Mysqld) StartReplication ¶
StartReplication starts replication.
func (*Mysqld) StartReplicationUntilAfter ¶
func (mysqld *Mysqld) StartReplicationUntilAfter(ctx context.Context, targetPos replication.Position) error
StartReplicationUntilAfter starts replication until replication has come to `targetPos`, then it stops replication
func (*Mysqld) StartSQLThreadUntilAfter ¶ added in v0.13.2
func (mysqld *Mysqld) StartSQLThreadUntilAfter(ctx context.Context, targetPos replication.Position) error
StartSQLThreadUntilAfter starts replication's SQL thread(s) until replication has come to `targetPos`, then it stops it
func (*Mysqld) StopIOThread ¶
StopIOThread stops a replica's IO thread only.
func (*Mysqld) StopReplication ¶
StopReplication stops replication.
func (*Mysqld) StopSQLThread ¶ added in v0.13.2
StopSQLThread stops a replica's SQL thread(s) only.
func (*Mysqld) Teardown ¶
func (mysqld *Mysqld) Teardown(ctx context.Context, cnf *Mycnf, force bool, shutdownTimeout time.Duration) error
Teardown will shutdown the running daemon, and delete the root directory.
func (*Mysqld) Wait ¶
Wait returns nil when mysqld is up and accepting connections. It will use the dba credentials to try to connect. Use wait() with different credentials if needed.
func (*Mysqld) WaitForReparentJournal ¶
WaitForReparentJournal will wait until the context is done for the row in the reparent_journal table.
func (*Mysqld) WaitSourcePos ¶ added in v0.11.0
WaitSourcePos lets replicas wait for the given replication position to be reached.
type ResetSuperReadOnlyFunc ¶ added in v0.17.0
type ResetSuperReadOnlyFunc func() error
type RestoreEngine ¶
type RestoreEngine interface {
ExecuteRestore(ctx context.Context, params RestoreParams, bh backupstorage.BackupHandle) (*BackupManifest, error)
}
RestoreEngine is the interface to restore a backup with a given engine. Returns the manifest of a backup if successful, otherwise returns an error
func GetRestoreEngine ¶
func GetRestoreEngine(ctx context.Context, backup backupstorage.BackupHandle) (RestoreEngine, error)
GetRestoreEngine returns the RestoreEngine implementation to restore a given backup. It reads the MANIFEST file from the backup to check which engine was used to create it.
type RestoreParams ¶
type RestoreParams struct { Cnf *Mycnf Mysqld MysqlDaemon Logger logutil.Logger // Concurrency is the value of --restore_concurrency flag (init restore parameter) // It determines how many files are processed in parallel Concurrency int // Extra env variables for pre-restore and post-restore transform hooks HookExtraEnv map[string]string // DeleteBeforeRestore tells us whether existing data should be deleted before // restoring. This is always set to false when starting a tablet with -restore_from_backup, // but is set to true when executing a RestoreFromBackup command on an already running vttablet DeleteBeforeRestore bool // DbName is the name of the managed database / schema DbName string // Keyspace and Shard are used to infer the directory where backups are stored Keyspace string Shard string // StartTime: if non-zero, look for a backup that was taken at or before this time // Otherwise, find the most recent backup StartTime time.Time // RestoreToPos hints that a point in time recovery is requested, to recover up to the specific given pos. // When empty, the restore is a normal from full backup RestoreToPos replication.Position // RestoreToTimestamp hints that a point in time recovery is requested, to recover up to, and excluding, the // given timestamp. // RestoreToTimestamp and RestoreToPos are mutually exclusive. RestoreToTimestamp time.Time // When DryRun is set, no restore actually takes place; but some of its steps are validated. DryRun bool // Stats let's restore engines report detailed restore timings. Stats backupstats.Stats // MysqlShutdownTimeout defines how long we wait during MySQL shutdown if that is part of the backup process. MysqlShutdownTimeout time.Duration }
RestoreParams is the struct that holds all params passed to ExecuteRestore
func (*RestoreParams) Copy ¶ added in v0.17.0
func (p *RestoreParams) Copy() RestoreParams
func (*RestoreParams) IsIncrementalRecovery ¶ added in v0.16.0
func (p *RestoreParams) IsIncrementalRecovery() bool
type RestorePath ¶ added in v0.16.0
type RestorePath struct {
// contains filtered or unexported fields
}
RestorePath is an ordered sequence of backup handles & manifests, that can be used to restore from backup. The path could be empty, in which case it's invalid, there's no way to restore. Otherwise, the path consists of exactly one full backup, followed by zero or more incremental backups.
func FindBackupToRestore ¶
func FindBackupToRestore(ctx context.Context, params RestoreParams, bhs []backupstorage.BackupHandle) (restorePath *RestorePath, err error)
FindBackupToRestore returns a path, a sequence of backup handles, to be restored. The returned handles stand for valid backups with complete manifests.
func (*RestorePath) Add ¶ added in v0.16.0
func (p *RestorePath) Add(m *BackupManifest)
func (*RestorePath) FullBackupHandle ¶ added in v0.16.0
func (p *RestorePath) FullBackupHandle() backupstorage.BackupHandle
FullBackupHandle returns the single (if any) full backup handle, which is always the first handle in the sequence
func (*RestorePath) IncrementalBackupHandles ¶ added in v0.16.0
func (p *RestorePath) IncrementalBackupHandles() []backupstorage.BackupHandle
IncrementalBackupHandles returns an ordered list of backup handles comprising of the incremental (non-full) path
func (*RestorePath) IsEmpty ¶ added in v0.16.0
func (p *RestorePath) IsEmpty() bool
func (*RestorePath) Len ¶ added in v0.16.0
func (p *RestorePath) Len() int
func (*RestorePath) String ¶ added in v0.16.0
func (p *RestorePath) String() string
type ServerVersion ¶ added in v0.14.0
type ServerVersion struct {
Major, Minor, Patch int
}
type XtrabackupEngine ¶
type XtrabackupEngine struct { }
XtrabackupEngine encapsulates the logic of the xtrabackup engine it implements the BackupEngine interface and contains all the logic required to implement a backup/restore by invoking xtrabackup with the appropriate parameters
func (*XtrabackupEngine) ExecuteBackup ¶
func (be *XtrabackupEngine) ExecuteBackup(ctx context.Context, params BackupParams, bh backupstorage.BackupHandle) (BackupResult, error)
ExecuteBackup runs a backup based on given params. This could be a full or incremental backup. The function returns a BackupResult that indicates the usability of the backup, and an overall error.
func (*XtrabackupEngine) ExecuteRestore ¶
func (be *XtrabackupEngine) ExecuteRestore(ctx context.Context, params RestoreParams, bh backupstorage.BackupHandle) (*BackupManifest, error)
ExecuteRestore restores from a backup. Any error is returned.
func (*XtrabackupEngine) ShouldDrainForBackup ¶
func (be *XtrabackupEngine) ShouldDrainForBackup(req *tabletmanagerdatapb.BackupRequest) bool
ShouldDrainForBackup satisfies the BackupEngine interface xtrabackup can run while tablet is serving, hence false
Source Files ¶
- backup.go
- backupengine.go
- binlogs_gtid.go
- builtinbackupengine.go
- capabilityset.go
- cmd.go
- compression.go
- fakebackupengine.go
- fakebackupstorage.go
- fakemysqldaemon.go
- mycnf.go
- mycnf_flag.go
- mycnf_gen.go
- mysql_daemon.go
- mysqld.go
- permissions.go
- plugin_grpcmysqlctlclient.go
- query.go
- redo_log.go
- reparent.go
- replication.go
- schema.go
- version.go
- xtrabackupengine.go
Directories ¶
Path | Synopsis |
---|---|
Package azblobbackupstorage implements the BackupStorage interface for Azure Blob Storage
|
Package azblobbackupstorage implements the BackupStorage interface for Azure Blob Storage |
Package backupstats provides a Stats interface for backup and restore operations in the mysqlctl package.
|
Package backupstats provides a Stats interface for backup and restore operations in the mysqlctl package. |
Package backupstorage contains the interface and file system implementation of the backup system.
|
Package backupstorage contains the interface and file system implementation of the backup system. |
Package cephbackupstorage implements the BackupStorage interface for Ceph Cloud Storage.
|
Package cephbackupstorage implements the BackupStorage interface for Ceph Cloud Storage. |
Package filebackupstorage implements the BackupStorage interface for a local filesystem (which can be an NFS mount).
|
Package filebackupstorage implements the BackupStorage interface for a local filesystem (which can be an NFS mount). |
Package gcsbackupstorage implements the BackupStorage interface for Google Cloud Storage.
|
Package gcsbackupstorage implements the BackupStorage interface for Google Cloud Storage. |
Package grpcmysqlctlclient contains the gRPC1 version of the mysqlctl client protocol.
|
Package grpcmysqlctlclient contains the gRPC1 version of the mysqlctl client protocol. |
Package grpcmysqlctlserver contains the gRPC implementation of the server side of the remote execution of mysqlctl commands.
|
Package grpcmysqlctlserver contains the gRPC 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. |
Package mysqlctlproto provides utility functions for working with data structures in mysqlctl.proto.
|
Package mysqlctlproto provides utility functions for working with data structures in mysqlctl.proto. |
Package s3backupstorage implements the BackupStorage interface for AWS S3.
|
Package s3backupstorage implements the BackupStorage interface for AWS S3. |
Package tmutils contains helper methods to deal with the tabletmanagerdata proto3 structures.
|
Package tmutils contains helper methods to deal with the tabletmanagerdata proto3 structures. |