Documentation ¶
Overview ¶
Package heartbeat contains a writer and reader of heartbeats for a master-replica cluster. This is similar to Percona's pt-heartbeat, and is meant to supplement the information returned from SHOW SLAVE STATUS. In some circumstances, lag returned from SHOW SLAVE STATUS is incorrect and is at best only at 1 second resolution. The heartbeat package directly tests replication by writing a record with a timestamp on the master, and comparing that timestamp after reading it on the replica. This happens at the interval defined by heartbeat_interval. Note: the lag reported will be affected by clock drift, so it is recommended to run ntpd or similar.
The data collected by the heartbeat package is made available in /debug/vars in counters prefixed by Heartbeat*. It's additionally used as a source for healthchecks and will impact the serving state of a tablet, if enabled. The heartbeat interval is purposefully kept distinct from the health check interval because lag measurement requires more frequent polling that the healthcheck typically is configured for.
Index ¶
- Constants
- Variables
- func GhostBinaryFileName() (fileName string, isOverride bool)
- func PTOSCFileName() (fileName string, isOverride bool)
- func RandomHash() string
- func ReadableTimestamp() string
- func ToReadableTimestamp(t time.Time) string
- type Executor
- func (e *Executor) Close()
- func (e *Executor) ExecuteWithGhost(ctx context.Context, onlineDDL *schema.OnlineDDL) error
- func (e *Executor) ExecuteWithPTOSC(ctx context.Context, onlineDDL *schema.OnlineDDL) error
- func (e *Executor) InitDBConfig(keyspace, shard, dbName string)
- func (e *Executor) OnSchemaMigrationStatus(ctx context.Context, uuidParam, statusParam, dryrunParam string) (err error)
- func (e *Executor) Open() error
- func (e *Executor) VExec(ctx context.Context, vx *vexec.TabletVExec) (qr *querypb.QueryResult, err error)
Constants ¶
const (
// SchemaMigrationsTableName is used by VExec interceptor to call the correct handler
SchemaMigrationsTableName = "schema_migrations"
)
Variables ¶
var ( // ErrExecutorNotWritableTablet is generated when executor is asked to run gh-ost on a read-only server ErrExecutorNotWritableTablet = errors.New("Cannot run gh-ost migration on non-writable tablet") // ErrExecutorMigrationAlreadyRunning is generated when an attempt is made to run an operation that conflicts with a running migration ErrExecutorMigrationAlreadyRunning = errors.New("Cannot run gh-ost migration since a migration is already running") // ErrMigrationNotFound is returned by readMigration when given UUI cannot be found ErrMigrationNotFound = errors.New("Migration not found") )
Functions ¶
func GhostBinaryFileName ¶
GhostBinaryFileName returns the full path+name of the gh-ost binary
func PTOSCFileName ¶
PTOSCFileName returns the full path+name of the pt-online-schema-change binary Note that vttablet does not include pt-online-schema-change
func ReadableTimestamp ¶
func ReadableTimestamp() string
ReadableTimestamp returns a timestamp, in seconds resolution, that is human readable (as opposed to unix timestamp which is just a number), and which corresponds to the time now. Example: for Aug 25 2020, 16:04:25 we return "20200825160425"
func ToReadableTimestamp ¶
ToReadableTimestamp returns a timestamp, in seconds resolution, that is human readable (as opposed to unix timestamp which is just a number) Example: for Aug 25 2020, 16:04:25 we return "20200825160425"
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor wraps and manages the execution of a gh-ost migration.
func NewExecutor ¶
func NewExecutor(env tabletenv.Env, ts *topo.Server, tabletTypeFunc func() topodatapb.TabletType) *Executor
NewExecutor creates a new gh-ost executor.
func (*Executor) ExecuteWithGhost ¶
ExecuteWithGhost validates and runs a gh-ost process. Validation included testing the backend MySQL server and the gh-ost binary itself Execution runs first a dry run, then an actual migration
func (*Executor) ExecuteWithPTOSC ¶
ExecuteWithPTOSC validates and runs a pt-online-schema-change process. Validation included testing the backend MySQL server and the pt-online-schema-change binary itself Execution runs first a dry run, then an actual migration
func (*Executor) InitDBConfig ¶
InitDBConfig initializes keysapce
func (*Executor) OnSchemaMigrationStatus ¶
func (e *Executor) OnSchemaMigrationStatus(ctx context.Context, uuidParam, statusParam, dryrunParam string) (err error)
OnSchemaMigrationStatus is called by TabletServer's API, which is invoked by a running gh-ost migration's hooks.
func (*Executor) VExec ¶
func (e *Executor) VExec(ctx context.Context, vx *vexec.TabletVExec) (qr *querypb.QueryResult, err error)
VExec is called by a VExec invocation