Documentation
¶
Index ¶
- Constants
- type Applier
- func (this *Applier) AlterGhost() error
- func (this *Applier) ApplyDMLEventQuery(dmlEvent *binlog.BinlogDMLEvent) error
- func (this *Applier) ApplyIterationInsertQuery() (chunkSize int64, rowsAffected int64, duration time.Duration, err error)
- func (this *Applier) CalculateNextIterationRangeEndValues() (hasFurtherRange bool, err error)
- func (this *Applier) CreateChangelogTable() error
- func (this *Applier) CreateGhostTable() error
- func (this *Applier) DropChangelogTable() error
- func (this *Applier) DropGhostTable() error
- func (this *Applier) DropOldTable() error
- func (this *Applier) ExpectProcess(sessionId int64, stateHint, infoHint string) error
- func (this *Applier) GrabVoluntaryLock(lockGrabbed chan<- error, okToRelease <-chan bool) error
- func (this *Applier) InitDBConnections() (err error)
- func (this *Applier) InitiateHeartbeat(heartbeatIntervalMilliseconds int64)
- func (this *Applier) IssueBlockingQueryOnVoluntaryLock(sessionIdChan chan int64) error
- func (this *Applier) LockTables() error
- func (this *Applier) MasterPosWait(binlogCoordinates *mysql.BinlogCoordinates) error
- func (this *Applier) ReadMigrationMaxValues(uniqueKey *sql.UniqueKey) error
- func (this *Applier) ReadMigrationMinValues(uniqueKey *sql.UniqueKey) error
- func (this *Applier) ReadMigrationRangeValues() error
- func (this *Applier) ShowStatusVariable(variableName string) (result int64, err error)
- func (this *Applier) StartSlaveSQLThread() error
- func (this *Applier) StopSlaveIOThread() error
- func (this *Applier) StopSlaveNicely() error
- func (this *Applier) SwapTablesAtomic(sessionIdChan chan int64) error
- func (this *Applier) SwapTablesQuickAndBumpy() error
- func (this *Applier) UnlockTables() error
- func (this *Applier) ValidateOrDropExistingTables() error
- func (this *Applier) WriteAndLogChangelog(hint, value string) (string, error)
- func (this *Applier) WriteChangelog(hint, value string) (string, error)
- func (this *Applier) WriteChangelogState(value string) (string, error)
- type BinlogEventListener
- type ChangelogState
- type EventsStreamer
- func (this *EventsStreamer) AddListener(async bool, databaseName string, tableName string, ...) (err error)
- func (this *EventsStreamer) GetCurrentBinlogCoordinates() *mysql.BinlogCoordinates
- func (this *EventsStreamer) GetReconnectBinlogCoordinates() *mysql.BinlogCoordinates
- func (this *EventsStreamer) InitDBConnections() (err error)
- func (this *EventsStreamer) StreamEvents(canStopStreaming func() bool) error
- type Inspector
- func (this *Inspector) CountTableRows() error
- func (this *Inspector) InitDBConnections() (err error)
- func (this *Inspector) InspectOriginalAndGhostTables() (err error)
- func (this *Inspector) InspectOriginalTable() (err error)
- func (this *Inspector) InspectTableColumnsAndUniqueKeys(tableName string) (columns *sql.ColumnList, uniqueKeys [](*sql.UniqueKey), err error)
- func (this *Inspector) ValidateOriginalTable() (err error)
- type Migrator
Constants ¶
const ( EventsChannelBufferSize = 1 ReconnectStreamerSleepSeconds = 5 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Applier ¶
type Applier struct {
// contains filtered or unexported fields
}
Applier reads data from the read-MySQL-server (typically a replica, but can be the master) It is used for gaining initial status and structure, and later also follow up on progress and changelog
func NewApplier ¶
func NewApplier() *Applier
func (*Applier) AlterGhost ¶
AlterGhost applies `alter` statement on ghost table
func (*Applier) ApplyDMLEventQuery ¶
func (this *Applier) ApplyDMLEventQuery(dmlEvent *binlog.BinlogDMLEvent) error
func (*Applier) ApplyIterationInsertQuery ¶
func (*Applier) CalculateNextIterationRangeEndValues ¶
CalculateNextIterationRangeEndValues reads the next-iteration-range-end unique key values, which will be used for copying the next chunk of rows. Ir returns "false" if there is no further chunk to work through, i.e. we're past the last chunk and are done with itrating the range (and this done with copying row chunks)
func (*Applier) CreateChangelogTable ¶
CreateChangelogTable creates the changelog table on the applier host
func (*Applier) CreateGhostTable ¶
CreateGhostTable creates the ghost table on the applier host
func (*Applier) DropChangelogTable ¶
DropChangelogTable drops the changelog table on the applier host
func (*Applier) DropGhostTable ¶
DropGhostTable drops the ghost table on the applier host
func (*Applier) DropOldTable ¶
DropOldTable drops the _Old table on the applier host
func (*Applier) ExpectProcess ¶
func (*Applier) GrabVoluntaryLock ¶
GrabVoluntaryLock gets a named lock (`GET_LOCK`) and listens on a okToRelease in order to release it
func (*Applier) InitDBConnections ¶
func (*Applier) InitiateHeartbeat ¶
InitiateHeartbeat creates a heartbeat cycle, writing to the changelog table. This is done asynchronously
func (*Applier) IssueBlockingQueryOnVoluntaryLock ¶
IssueBlockingQueryOnVoluntaryLock will SELECT on the original table using a conditional on a known to be occupied lock. This query is expected to block, and will further block the followup RENAME statement
func (*Applier) MasterPosWait ¶
func (this *Applier) MasterPosWait(binlogCoordinates *mysql.BinlogCoordinates) error
MasterPosWait is applicable with --test-on-replica
func (*Applier) ReadMigrationMaxValues ¶
ReadMigrationMinValues
func (*Applier) ReadMigrationMinValues ¶
ReadMigrationMinValues
func (*Applier) ReadMigrationRangeValues ¶
func (*Applier) ShowStatusVariable ¶
func (*Applier) StartSlaveSQLThread ¶ added in v0.7.16
StartSlaveSQLThread is applicable with --test-on-replica
func (*Applier) StopSlaveIOThread ¶
StopSlaveIOThread is applicable with --test-on-replica; it stops the IO thread, duh. We need to keep the SQL thread active so as to complete processing received events, and have them written to the binary log, so that we can then read them via streamer
func (*Applier) StopSlaveNicely ¶
func (*Applier) SwapTablesAtomic ¶
SwapTablesAtomic issues a single two-table RENAME statement to swap ghost table into original's place
func (*Applier) SwapTablesQuickAndBumpy ¶
SwapTablesQuickAndBumpy
func (*Applier) ValidateOrDropExistingTables ¶
func (*Applier) WriteAndLogChangelog ¶
func (*Applier) WriteChangelog ¶
WriteChangelog writes a value to the changelog table. It returns the hint as given, for convenience
type BinlogEventListener ¶
type BinlogEventListener struct {
// contains filtered or unexported fields
}
type ChangelogState ¶
type ChangelogState string
const ( TablesInPlace ChangelogState = "TablesInPlace" AllEventsUpToLockProcessed = "AllEventsUpToLockProcessed" )
type EventsStreamer ¶
type EventsStreamer struct {
// contains filtered or unexported fields
}
EventsStreamer reads data from binary logs and streams it on. It acts as a publisher, and interested parties may subscribe for per-table events.
func NewEventsStreamer ¶
func NewEventsStreamer() *EventsStreamer
func (*EventsStreamer) AddListener ¶
func (this *EventsStreamer) AddListener( async bool, databaseName string, tableName string, onDmlEvent func(event *binlog.BinlogDMLEvent) error) (err error)
func (*EventsStreamer) GetCurrentBinlogCoordinates ¶ added in v0.7.16
func (this *EventsStreamer) GetCurrentBinlogCoordinates() *mysql.BinlogCoordinates
func (*EventsStreamer) GetReconnectBinlogCoordinates ¶ added in v0.8.2
func (this *EventsStreamer) GetReconnectBinlogCoordinates() *mysql.BinlogCoordinates
func (*EventsStreamer) InitDBConnections ¶
func (this *EventsStreamer) InitDBConnections() (err error)
func (*EventsStreamer) StreamEvents ¶
func (this *EventsStreamer) StreamEvents(canStopStreaming func() bool) error
StreamEvents will begin streaming events. It will be blocking, so should be executed by a goroutine
type Inspector ¶
type Inspector struct {
// contains filtered or unexported fields
}
Inspector reads data from the read-MySQL-server (typically a replica, but can be the master) It is used for gaining initial status and structure, and later also follow up on progress and changelog
func NewInspector ¶
func NewInspector() *Inspector
func (*Inspector) CountTableRows ¶ added in v0.8.3
func (*Inspector) InitDBConnections ¶
func (*Inspector) InspectOriginalAndGhostTables ¶
InspectOriginalAndGhostTables compares original and ghost tables to see whether the migration makes sense and is valid. It extracts the list of shared columns and the chosen migration unique key