Documentation ¶
Index ¶
- Constants
- func AddStatusPart()
- func MatchTable(tableName string, filter *binlogdatapb.Filter) (*binlogdatapb.Rule, error)
- func NewReplicaConnector(connParams *mysql.ConnParams) *replicaConnector
- func StatusSummary() (maxSecondsBehindMaster int64, binlogPlayersCount int32)
- type ControllerStatus
- type Engine
- func (vre *Engine) Close()
- func (vre *Engine) Exec(query string) (*sqltypes.Result, error)
- func (vre *Engine) InitDBConfig(dbcfgs *dbconfigs.DBConfigs)
- func (vre *Engine) IsOpen() bool
- func (vre *Engine) Open(ctx context.Context)
- func (vre *Engine) WaitForPos(ctx context.Context, id int, pos string) error
- type EngineStatus
- type HTTPStreamWriterMock
- type InsertGenerator
- type PrimaryKeyInfo
- type ReplicatorPlan
- type ShardSorter
- type TablePlan
- type VStreamerClient
- type VrLogStats
Constants ¶
const ExcludeStr = "exclude"
ExcludeStr is the filter value for excluding tables that match a rule. TODO(sougou): support this on vstreamer side also.
Variables ¶
This section is empty.
Functions ¶
func AddStatusPart ¶
func AddStatusPart()
AddStatusPart adds the vreplication status to the status page.
func MatchTable ¶
func MatchTable(tableName string, filter *binlogdatapb.Filter) (*binlogdatapb.Rule, error)
MatchTable is similar to tableMatches and buildPlan defined in vstreamer/planbuilder.go.
func NewReplicaConnector ¶
func NewReplicaConnector(connParams *mysql.ConnParams) *replicaConnector
NewReplicaConnector returns replica connector
This is used by binlog server to make vstream connection using the vstream connection, it will parse the events from binglog to fetch the corresponding GTID for required recovery time
func StatusSummary ¶
StatusSummary returns the summary status of vreplication.
Types ¶
type ControllerStatus ¶
type ControllerStatus struct { Index uint32 Source string SourceShard string StopPosition string LastPosition string Heartbeat int64 SecondsBehindMaster int64 Counts map[string]int64 Rates map[string][]float64 State string SourceTablet string Messages []string QueryCounts map[string]int64 PhaseTimings map[string]int64 CopyRowCount int64 CopyLoopCount int64 }
ControllerStatus contains a renderable status of a controller.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the engine for handling vreplication.
func NewEngine ¶
func NewEngine(config *tabletenv.TabletConfig, ts *topo.Server, cell string, mysqld mysqlctl.MysqlDaemon, lagThrottler *throttle.Throttler) *Engine
NewEngine creates a new Engine. A nil ts means that the Engine is disabled.
func NewTestEngine ¶
func NewTestEngine(ts *topo.Server, cell string, mysqld mysqlctl.MysqlDaemon, dbClientFactory func() binlogplayer.DBClient, dbname string, externalConfig map[string]*dbconfigs.DBConfigs) *Engine
NewTestEngine creates a new Engine for testing.
func (*Engine) Exec ¶
Exec executes the query and the related actions. Example insert statement: insert into _vt.vreplication
(workflow, source, pos, max_tps, max_replication_lag, time_updated, transaction_timestamp, state) values ('Resharding', 'keyspace:"ks" shard:"0" tables:"a" tables:"b" ', 'MariaDB/0-1-1083', 9223372036854775807, 9223372036854775807, 481823, 0, 'Running')`
Example update statement: update _vt.vreplication set state='Stopped', message='testing stop' where id=1 Example delete: delete from _vt.vreplication where id=1 Example select: select * from _vt.vreplication
func (*Engine) InitDBConfig ¶
InitDBConfig should be invoked after the db name is computed.
type EngineStatus ¶
type EngineStatus struct { IsOpen bool Controllers []*ControllerStatus }
EngineStatus contains a renderable status of the Engine.
type HTTPStreamWriterMock ¶
type HTTPStreamWriterMock struct {
// contains filtered or unexported fields
}
HTTPStreamWriterMock implements http.ResponseWriter and adds a channel to sync writes and reads
func NewHTTPStreamWriterMock ¶
func NewHTTPStreamWriterMock() *HTTPStreamWriterMock
NewHTTPStreamWriterMock returns a new HTTPStreamWriterMock
func (*HTTPStreamWriterMock) Flush ¶
func (w *HTTPStreamWriterMock) Flush()
Flush sends buffered data to the channel
func (*HTTPStreamWriterMock) Header ¶
func (w *HTTPStreamWriterMock) Header() http.Header
Header is a stub
func (*HTTPStreamWriterMock) Write ¶
func (w *HTTPStreamWriterMock) Write(data []byte) (int, error)
Write buffers sent data
func (*HTTPStreamWriterMock) WriteHeader ¶
func (w *HTTPStreamWriterMock) WriteHeader(statuscode int)
WriteHeader is a stub
type InsertGenerator ¶
type InsertGenerator struct {
// contains filtered or unexported fields
}
InsertGenerator generates a vreplication insert statement.
func NewInsertGenerator ¶
func NewInsertGenerator(state, dbname string) *InsertGenerator
NewInsertGenerator creates a new InsertGenerator.
func (*InsertGenerator) AddRow ¶
func (ig *InsertGenerator) AddRow(workflow string, bls *binlogdatapb.BinlogSource, pos, cell, tabletTypes string)
AddRow adds a row to the insert statement.
func (*InsertGenerator) String ¶
func (ig *InsertGenerator) String() string
String returns the generated statement.
type PrimaryKeyInfo ¶ added in v0.8.0
type PrimaryKeyInfo struct { Name string CharSet string Collation string DataType string ColumnType string }
PrimaryKeyInfo is used to store charset and collation for primary keys where applicable
type ReplicatorPlan ¶
type ReplicatorPlan struct { VStreamFilter *binlogdatapb.Filter TargetTables map[string]*TablePlan TablePlans map[string]*TablePlan PKInfoMap map[string][]*PrimaryKeyInfo }
ReplicatorPlan is the execution plan for the replicator. It contains plans for all the tables it's replicating. Every phase of vreplication builds its own instance of the ReplicatorPlan. This is because the plan depends on copyState, which changes on every iteration. The table plans within ReplicatorPlan will not be fully populated because all the information is not available initially. For simplicity, the ReplicatorPlan is immutable. Once we get the field info for a table from the stream response, we'll have all the necessary info to build the final plan. At that time, buildExecutionPlan is invoked, which will make a copy of the TablePlan from ReplicatorPlan, and fill the rest of the members, leaving the original plan unchanged. The constructor is buildReplicatorPlan in table_plan_builder.go
func (*ReplicatorPlan) MarshalJSON ¶
func (rp *ReplicatorPlan) MarshalJSON() ([]byte, error)
MarshalJSON performs a custom JSON Marshalling.
type ShardSorter ¶
type ShardSorter []string
ShardSorter implements a sort.Sort() function for sorting shard ranges
func (ShardSorter) Key ¶
func (s ShardSorter) Key(ind int) string
Key returns the prefix of a shard range
func (ShardSorter) Len ¶
func (s ShardSorter) Len() int
Len implements the required interface for a sorting function
func (ShardSorter) Less ¶
func (s ShardSorter) Less(i, j int) bool
Less implements the required interface for a sorting function
func (ShardSorter) Swap ¶
func (s ShardSorter) Swap(i, j int)
Swap implements the required interface for a sorting function
type TablePlan ¶
type TablePlan struct { // TargetName, SendRule will always be initialized. TargetName string SendRule *binlogdatapb.Rule // Lastpk will be initialized if it was specified, and // will be used for building the final plan after field info // is received. Lastpk *sqltypes.Result // BulkInsertFront, BulkInsertValues and BulkInsertOnDup are used // by vcopier. These three parts are combined to build bulk insert // statements. This is functionally equivalent to generating // multiple statements using the "Insert" construct, but much more // efficient for the copy phase. BulkInsertFront *sqlparser.ParsedQuery BulkInsertValues *sqlparser.ParsedQuery BulkInsertOnDup *sqlparser.ParsedQuery // Insert, Update and Delete are used by vplayer. // If the plan is an insertIgnore type, then Insert // and Update contain 'insert ignore' statements and // Delete is nil. Insert *sqlparser.ParsedQuery Update *sqlparser.ParsedQuery Delete *sqlparser.ParsedQuery Fields []*querypb.Field // PKReferences is used to check if an event changed // a primary key column (row move). PKReferences []string }
TablePlan is the execution plan for a table within a replicator. If the column names are not known at the time of plan building (like select *), then only TargetName, SendRule and Lastpk are initialized. When the stream returns the field info, those are used as column names to build the final plan. Lastpk comes from copyState. If it's set, then the generated plans are significantly different because any events that fall beyond Lastpk must be excluded. If column names were known upfront, then all fields of TablePlan are built except for Fields. This member is populated only after the field info is received from the stream. The ParsedQuery objects assume that a map of before and after values will be built based on the streaming rows. Before image values will be prefixed with a "b_", and after image values will be prefixed with a "a_". The TablePlan structure is used during all the phases of vreplication: catchup, copy, fastforward, or regular replication.
func (*TablePlan) MarshalJSON ¶
MarshalJSON performs a custom JSON Marshalling.
type VStreamerClient ¶
type VStreamerClient interface { Open(context.Context) error Close(context.Context) error // VStream streams VReplication events based on the specified filter. VStream(ctx context.Context, startPos string, tablePKs []*binlogdatapb.TableLastPK, filter *binlogdatapb.Filter, send func([]*binlogdatapb.VEvent) error) error // VStreamRows streams rows of a table from the specified starting point. VStreamRows(ctx context.Context, query string, lastpk *querypb.QueryResult, send func(*binlogdatapb.VStreamRowsResponse) error) error }
VStreamerClient exposes the core interface of a vstreamer
type VrLogStats ¶
type VrLogStats struct { Type string Detail string StartTime time.Time LogTime string DurationNs int64 }
VrLogStats collects attributes of a vreplication event for logging
func NewVrLogStats ¶
func NewVrLogStats(eventType string) *VrLogStats
NewVrLogStats should be called at the start of the event to be logged
func (*VrLogStats) Send ¶
func (stats *VrLogStats) Send(detail string)
Send records the log event, should be called on a stats object constructed by NewVrLogStats()