Documentation
¶
Overview ¶
Package vtgate provides query routing rpc services for vttablets.
Index ¶
- Constants
- Variables
- func NewShardError(in error, target *querypb.Target) error
- func RegisterPluginInitializer(initializer func())
- type DynamicViperConfig
- type Executor
- func (e *Executor) AddWarningCount(name string, count int64)
- func (e *Executor) ClearPlans()
- func (e *Executor) Close()
- func (e *Executor) CloseSession(ctx context.Context, safeSession *econtext.SafeSession) error
- func (e *Executor) Commit(ctx context.Context, safeSession *econtext.SafeSession) error
- func (e *Executor) Environment() *vtenv.Environment
- func (e *Executor) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, method string, ...) (result *sqltypes.Result, err error)
- func (e *Executor) ExecuteLock(ctx context.Context, rs *srvtopo.ResolvedShard, query *querypb.BoundQuery, ...) (*sqltypes.Result, error)
- func (e *Executor) ExecuteMessageStream(ctx context.Context, rss []*srvtopo.ResolvedShard, tableName string, ...) error
- func (e *Executor) ExecuteMultiShard(ctx context.Context, primitive engine.Primitive, rss []*srvtopo.ResolvedShard, ...) (qr *sqltypes.Result, errs []error)
- func (e *Executor) ExecuteVStream(ctx context.Context, rss []*srvtopo.ResolvedShard, filter *binlogdatapb.Filter, ...) error
- func (e *Executor) ForEachPlan(each func(plan *engine.Plan) bool)
- func (e *Executor) MessageStream(ctx context.Context, keyspace string, shard string, ...) error
- func (e *Executor) ParseDestinationTarget(targetString string) (string, topodatapb.TabletType, key.ShardDestination, error)
- func (e *Executor) PlanPrepareStmt(ctx context.Context, safeSession *econtext.SafeSession, query string) (*engine.Plan, error)
- func (e *Executor) Plans() *PlanCache
- func (e *Executor) Prepare(ctx context.Context, method string, safeSession *econtext.SafeSession, ...) (fld []*querypb.Field, paramsCount uint16, err error)
- func (e *Executor) ReadTransaction(ctx context.Context, transactionID string) (*querypb.TransactionMetadata, error)
- func (e *Executor) ReleaseLock(ctx context.Context, session *econtext.SafeSession) error
- func (e *Executor) SaveVSchema(vschema *vindexes.VSchema, stats *VSchemaStats)
- func (e *Executor) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (e *Executor) SetQueryLogger(ql *streamlog.StreamLogger[*logstats.LogStats])
- func (e *Executor) SetVitessMetadata(ctx context.Context, name, value string) error
- func (e *Executor) ShowShards(ctx context.Context, filter *sqlparser.ShowFilter, ...) (*sqltypes.Result, error)
- func (e *Executor) ShowTablets(filter *sqlparser.ShowFilter) (*sqltypes.Result, error)
- func (e *Executor) ShowVitessMetadata(ctx context.Context, filter *sqlparser.ShowFilter) (*sqltypes.Result, error)
- func (e *Executor) ShowVitessReplicationStatus(ctx context.Context, filter *sqlparser.ShowFilter) (*sqltypes.Result, error)
- func (e *Executor) StreamExecute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, method string, ...) error
- func (e *Executor) StreamExecuteMulti(ctx context.Context, primitive engine.Primitive, query string, ...) []error
- func (e *Executor) UnresolvedTransactions(ctx context.Context, targets []*querypb.Target) ([]*querypb.TransactionMetadata, error)
- func (e *Executor) VSchema() *vindexes.VSchema
- func (e *Executor) VSchemaStats() *VSchemaStats
- func (e *Executor) WriteScatterStats(w http.ResponseWriter)
- type ExecutorConfig
- type Metrics
- type PlanCache
- type PlanCacheKey
- type RegisterVTGate
- type Resolver
- type ScatterConn
- func (stc *ScatterConn) Close() error
- func (stc *ScatterConn) ExecuteLock(ctx context.Context, rs *srvtopo.ResolvedShard, query *querypb.BoundQuery, ...) (*sqltypes.Result, error)
- func (stc *ScatterConn) ExecuteMultiShard(ctx context.Context, primitive engine.Primitive, rss []*srvtopo.ResolvedShard, ...) (qr *sqltypes.Result, errs []error)
- func (stc *ScatterConn) GetGatewayCacheStatus() TabletCacheStatusList
- func (stc *ScatterConn) GetHealthCheckCacheStatus() discovery.TabletsCacheStatusList
- func (stc *ScatterConn) MessageStream(ctx context.Context, rss []*srvtopo.ResolvedShard, name string, ...) error
- func (stc *ScatterConn) StreamExecuteMulti(ctx context.Context, primitive engine.Primitive, query string, ...) []error
- type SchemaInfo
- type StaticConfig
- type TabletCacheStatus
- type TabletCacheStatusList
- type TabletGateway
- func (gw *TabletGateway) CacheStatus() TabletCacheStatusList
- func (gw *TabletGateway) Close(_ context.Context) error
- func (gw *TabletGateway) DebugBalancerHandler(w http.ResponseWriter, r *http.Request)
- func (gw *TabletGateway) DefaultConnCollation() collations.ID
- func (gw *TabletGateway) GetServingKeyspaces() []string
- func (gw *TabletGateway) QueryServiceByAlias(ctx context.Context, alias *topodatapb.TabletAlias, target *querypb.Target) (queryservice.QueryService, error)
- func (gw *TabletGateway) RegisterStats()
- func (gw *TabletGateway) TabletsCacheStatus() discovery.TabletsCacheStatusList
- func (gw *TabletGateway) TabletsHealthyStatus() discovery.TabletsCacheStatusList
- func (gw *TabletGateway) WaitForTablets(ctx context.Context, tabletTypesToWait []topodatapb.TabletType) (err error)
- type TabletStatusAggregator
- type TxConn
- func (txc *TxConn) Begin(ctx context.Context, session *econtext.SafeSession, ...) error
- func (txc *TxConn) Commit(ctx context.Context, session *econtext.SafeSession) error
- func (txc *TxConn) ReadTransaction(ctx context.Context, transactionID string) (*querypb.TransactionMetadata, error)
- func (txc *TxConn) Release(ctx context.Context, session *econtext.SafeSession) error
- func (txc *TxConn) ReleaseAll(ctx context.Context, session *econtext.SafeSession) error
- func (txc *TxConn) ReleaseLock(ctx context.Context, session *econtext.SafeSession) error
- func (txc *TxConn) ResolveTransactions(ctx context.Context, target *querypb.Target) error
- func (txc *TxConn) Rollback(ctx context.Context, session *econtext.SafeSession) error
- func (txc *TxConn) UnresolvedTransactions(ctx context.Context, targets []*querypb.Target) ([]*querypb.TransactionMetadata, error)
- type VSchemaKeyspaceStats
- type VSchemaManager
- func (vm *VSchemaManager) GetCurrentSrvVschema() *vschemapb.SrvVSchema
- func (vm *VSchemaManager) Rebuild()
- func (vm *VSchemaManager) UpdateVSchema(ctx context.Context, ks *topo.KeyspaceVSchemaInfo, srv *vschemapb.SrvVSchema) error
- func (vm *VSchemaManager) VSchemaUpdate(v *vschemapb.SrvVSchema, err error) bool
- type VSchemaStats
- type VTGate
- func (vtg *VTGate) CloseSession(ctx context.Context, session *vtgatepb.Session) error
- func (vtg *VTGate) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, ...) (newSession *vtgatepb.Session, qr *sqltypes.Result, err error)
- func (vtg *VTGate) ExecuteBatch(ctx context.Context, session *vtgatepb.Session, sqlList []string, ...) (*vtgatepb.Session, []sqltypes.QueryResponse, error)
- func (vtg *VTGate) ExecuteMulti(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, ...) (newSession *vtgatepb.Session, qrs []*sqltypes.Result, err error)
- func (vtg *VTGate) Gateway() *TabletGateway
- func (vtg *VTGate) GetGatewayCacheStatus() TabletCacheStatusList
- func (vtg *VTGate) HandlePanic(err *error)
- func (vtg *VTGate) IsHealthy() error
- func (vtg *VTGate) Prepare(ctx context.Context, session *vtgatepb.Session, sql string) (newSession *vtgatepb.Session, fld []*querypb.Field, paramsCount uint16, ...)
- func (vtg *VTGate) StreamExecute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, ...) (*vtgatepb.Session, error)
- func (vtg *VTGate) StreamExecuteMulti(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, ...) (*vtgatepb.Session, error)
- func (vtg *VTGate) VSchemaStats() *VSchemaStats
- func (vtg *VTGate) VStream(ctx context.Context, tabletType topodatapb.TabletType, ...) error
Constants ¶
const ( Commit2pcCreateTransaction commitPhase = iota Commit2pcPrepare Commit2pcStartCommit Commit2pcPrepareCommit Commit2pcConclude )
const DebugTwoPc = false
const ( // ExecutorTemplate is the HTML template to display ExecutorStats. ExecutorTemplate = `` /* 2776-byte string literal not displayed */ )
const MaxBufferingRetries = 3
const MaxSkew = int64(2)
MaxSkew is the threshold for a skew to be detected. Since MySQL timestamps are in seconds we account for two round-offs: one for the actual event and another while accounting for the clock skew
const ( // StatusTemplate is the display part to use to show // a TabletCacheStatusList. StatusTemplate = `` /* 780-byte string literal not displayed */ )
const ( // VSchemaTemplate is the HTML template to display VSchemaStats. VSchemaTemplate = `` /* 864-byte string literal not displayed */ )
Variables ¶
var ( // QueryLogHandler is the debug UI path for exposing query logs QueryLogHandler = "/debug/querylog" // QueryLogzHandler is the debug UI path for exposing query logs QueryLogzHandler = "/debug/querylogz" // QueryzHandler is the debug UI path for exposing query plan stats QueryzHandler = "/debug/queryz" )
var ( // CellsToWatch is the list of cells the healthcheck operates over. If it is empty, only the local cell is watched CellsToWatch string )
var ErrStaleVSchema = errors.New("failed to update vschema as the session's version was stale; please try again")
The full SQL error that the user sees in their vtgate connection looks like this: failed to update vschema as the session's version was stale; please try again (errno 1105) (sqlstate HY000) during query: ALTER VSCHEMA DROP TABLE t864
var RegisterVTGates []RegisterVTGate
RegisterVTGates stores register funcs for VTGate server.
Functions ¶
func NewShardError ¶
NewShardError returns a new error with the shard info amended.
func RegisterPluginInitializer ¶
func RegisterPluginInitializer(initializer func())
RegisterPluginInitializer lets plugins register themselves to be init'ed at servenv.OnRun-time
Types ¶
type DynamicViperConfig ¶
type DynamicViperConfig struct {
// contains filtered or unexported fields
}
DynamicViperConfig is a dynamic config that uses viper.
func NewDynamicViperConfig ¶
func NewDynamicViperConfig() *DynamicViperConfig
NewDynamicViperConfig creates a new dynamic viper config
func (*DynamicViperConfig) DirectEnabled ¶
func (d *DynamicViperConfig) DirectEnabled() bool
func (*DynamicViperConfig) OnlineEnabled ¶
func (d *DynamicViperConfig) OnlineEnabled() bool
func (*DynamicViperConfig) TransactionMode ¶
func (d *DynamicViperConfig) TransactionMode() vtgatepb.TransactionMode
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor is the engine that executes queries by utilizing the abilities of the underlying vttablets.
func NewExecutor ¶
func NewExecutor( ctx context.Context, env *vtenv.Environment, serv srvtopo.Server, cell string, resolver *Resolver, eConfig ExecutorConfig, warnOnShardedOnly bool, plans *PlanCache, schemaTracker SchemaInfo, pv plancontext.PlannerVersion, ddlConfig dynamicconfig.DDL, ) *Executor
NewExecutor creates a new Executor.
func (*Executor) AddWarningCount ¶
func (*Executor) ClearPlans ¶
func (e *Executor) ClearPlans()
func (*Executor) CloseSession ¶
CloseSession releases the current connection, which rollbacks open transactions and closes reserved connections. It is called then the MySQL servers closes the connection to its client.
func (*Executor) Environment ¶
func (e *Executor) Environment() *vtenv.Environment
func (*Executor) Execute ¶
func (e *Executor) Execute( ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, method string, safeSession *econtext.SafeSession, sql string, bindVars map[string]*querypb.BindVariable, prepared bool, ) (result *sqltypes.Result, err error)
Execute executes a non-streaming query.
func (*Executor) ExecuteLock ¶
func (e *Executor) ExecuteLock(ctx context.Context, rs *srvtopo.ResolvedShard, query *querypb.BoundQuery, session *econtext.SafeSession, lockFuncType sqlparser.LockingFuncType) (*sqltypes.Result, error)
ExecuteLock implements the IExecutor interface
func (*Executor) ExecuteMessageStream ¶
func (e *Executor) ExecuteMessageStream(ctx context.Context, rss []*srvtopo.ResolvedShard, tableName string, callback func(reply *sqltypes.Result) error) error
ExecuteMessageStream implements the IExecutor interface
func (*Executor) ExecuteMultiShard ¶
func (e *Executor) ExecuteMultiShard(ctx context.Context, primitive engine.Primitive, rss []*srvtopo.ResolvedShard, queries []*querypb.BoundQuery, session *econtext.SafeSession, autocommit bool, ignoreMaxMemoryRows bool, resultsObserver econtext.ResultsObserver, fetchLastInsertID bool) (qr *sqltypes.Result, errs []error)
ExecuteMultiShard implements the IExecutor interface
func (*Executor) ExecuteVStream ¶
func (e *Executor) ExecuteVStream(ctx context.Context, rss []*srvtopo.ResolvedShard, filter *binlogdatapb.Filter, gtid string, callback func(evs []*binlogdatapb.VEvent) error) error
ExecuteVStream implements the IExecutor interface
func (*Executor) MessageStream ¶
func (e *Executor) MessageStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, name string, callback func(*sqltypes.Result) error) error
MessageStream is part of the vtgate service API. This is a V2 level API that's sent to the Resolver.
func (*Executor) ParseDestinationTarget ¶
func (e *Executor) ParseDestinationTarget(targetString string) (string, topodatapb.TabletType, key.ShardDestination, error)
ParseDestinationTarget parses destination target string and sets default keyspace if possible.
func (*Executor) PlanPrepareStmt ¶
func (e *Executor) PlanPrepareStmt(ctx context.Context, safeSession *econtext.SafeSession, query string) (*engine.Plan, error)
PlanPrepareStmt implements the IExecutor interface
func (*Executor) Prepare ¶
func (e *Executor) Prepare(ctx context.Context, method string, safeSession *econtext.SafeSession, sql string) (fld []*querypb.Field, paramsCount uint16, err error)
Prepare executes a prepare statements.
func (*Executor) ReadTransaction ¶
func (*Executor) ReleaseLock ¶
ReleaseLock implements the IExecutor interface
func (*Executor) SaveVSchema ¶
func (e *Executor) SaveVSchema(vschema *vindexes.VSchema, stats *VSchemaStats)
SaveVSchema updates the vschema and stats
func (*Executor) ServeHTTP ¶
func (e *Executor) ServeHTTP(response http.ResponseWriter, request *http.Request)
ServeHTTP shows the current plans in the query cache.
func (*Executor) SetQueryLogger ¶
func (e *Executor) SetQueryLogger(ql *streamlog.StreamLogger[*logstats.LogStats])
func (*Executor) SetVitessMetadata ¶
func (*Executor) ShowShards ¶
func (e *Executor) ShowShards(ctx context.Context, filter *sqlparser.ShowFilter, destTabletType topodatapb.TabletType) (*sqltypes.Result, error)
func (*Executor) ShowTablets ¶
func (*Executor) ShowVitessMetadata ¶
func (*Executor) ShowVitessReplicationStatus ¶
func (*Executor) StreamExecute ¶
func (e *Executor) StreamExecute( ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, method string, safeSession *econtext.SafeSession, sql string, bindVars map[string]*querypb.BindVariable, callback func(*sqltypes.Result) error, ) error
StreamExecute executes a streaming query.
func (*Executor) StreamExecuteMulti ¶
func (e *Executor) StreamExecuteMulti(ctx context.Context, primitive engine.Primitive, query string, rss []*srvtopo.ResolvedShard, vars []map[string]*querypb.BindVariable, session *econtext.SafeSession, autocommit bool, callback func(reply *sqltypes.Result) error, resultsObserver econtext.ResultsObserver, fetchLastInsertID bool) []error
StreamExecuteMulti implements the IExecutor interface
func (*Executor) UnresolvedTransactions ¶
func (*Executor) VSchemaStats ¶
func (e *Executor) VSchemaStats() *VSchemaStats
VSchemaStats returns the loaded vschema stats.
func (*Executor) WriteScatterStats ¶
func (e *Executor) WriteScatterStats(w http.ResponseWriter)
WriteScatterStats will write an html report to the provided response writer
type ExecutorConfig ¶
type ExecutorConfig struct { Name string Normalize bool StreamSize int // AllowScatter will fail planning if set to false and a plan contains any scatter queries AllowScatter bool WarmingReadsPercent int QueryLogToFile string }
Executor is the engine that executes queries by utilizing the abilities of the underlying vttablets.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Executor is the engine that executes queries by utilizing the abilities of the underlying vttablets.
func (*Metrics) GetExecutionMetrics ¶
type PlanCache ¶
type PlanCache = theine.Store[PlanCacheKey, *engine.Plan]
func DefaultPlanCache ¶
func DefaultPlanCache() *PlanCache
type PlanCacheKey ¶
type PlanCacheKey = theine.HashKey256
type RegisterVTGate ¶
type RegisterVTGate func(vtgateservice.VTGateService)
RegisterVTGate defines the type of registration mechanism.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver is the layer to resolve KeyspaceIds and KeyRanges to shards. It will try to re-resolve shards if ScatterConn returns retryable error, which may imply horizontal or vertical resharding happened. It is implemented using a srvtopo.Resolver.
func NewResolver ¶
func NewResolver(resolver *srvtopo.Resolver, serv srvtopo.Server, cell string, sc *ScatterConn) *Resolver
NewResolver creates a new Resolver.
func (*Resolver) GetGatewayCacheStatus ¶
func (res *Resolver) GetGatewayCacheStatus() TabletCacheStatusList
GetGatewayCacheStatus returns a displayable version of the Gateway cache.
type ScatterConn ¶
type ScatterConn struct {
// contains filtered or unexported fields
}
ScatterConn is used for executing queries across multiple shard level connections.
func NewScatterConn ¶
func NewScatterConn(statsName string, txConn *TxConn, gw *TabletGateway) *ScatterConn
NewScatterConn creates a new ScatterConn.
func (*ScatterConn) Close ¶
func (stc *ScatterConn) Close() error
Close closes the underlying Gateway.
func (*ScatterConn) ExecuteLock ¶
func (stc *ScatterConn) ExecuteLock(ctx context.Context, rs *srvtopo.ResolvedShard, query *querypb.BoundQuery, session *econtext.SafeSession, lockFuncType sqlparser.LockingFuncType) (*sqltypes.Result, error)
ExecuteLock performs the requested 'action' on the specified ResolvedShard. If the lock session already has a reserved connection, it reuses it. Otherwise open a new reserved connection. The action function must match the shardActionTransactionFunc signature.
It returns an error recorder in which each shard error is recorded positionally, i.e. if rss[2] had an error, then the error recorder will store that error in the second position.
func (*ScatterConn) ExecuteMultiShard ¶
func (stc *ScatterConn) ExecuteMultiShard( ctx context.Context, primitive engine.Primitive, rss []*srvtopo.ResolvedShard, queries []*querypb.BoundQuery, session *econtext.SafeSession, autocommit bool, ignoreMaxMemoryRows bool, resultsObserver econtext.ResultsObserver, fetchLastInsertID bool, ) (qr *sqltypes.Result, errs []error)
ExecuteMultiShard is like Execute, but each shard gets its own Sql Queries and BindVariables.
It always returns a non-nil query result and an array of shard errors which may be nil so that callers can optionally process a partially-successful operation.
func (*ScatterConn) GetGatewayCacheStatus ¶
func (stc *ScatterConn) GetGatewayCacheStatus() TabletCacheStatusList
GetGatewayCacheStatus returns a displayable version of the Gateway cache.
func (*ScatterConn) GetHealthCheckCacheStatus ¶
func (stc *ScatterConn) GetHealthCheckCacheStatus() discovery.TabletsCacheStatusList
GetHealthCheckCacheStatus returns a displayable version of the HealthCheck cache.
func (*ScatterConn) MessageStream ¶
func (stc *ScatterConn) MessageStream(ctx context.Context, rss []*srvtopo.ResolvedShard, name string, callback func(*sqltypes.Result) error) error
MessageStream streams messages from the specified shards. Note we guarantee the callback will not be called concurrently by multiple go routines, through processOneStreamingResult.
func (*ScatterConn) StreamExecuteMulti ¶
func (stc *ScatterConn) StreamExecuteMulti( ctx context.Context, primitive engine.Primitive, query string, rss []*srvtopo.ResolvedShard, bindVars []map[string]*querypb.BindVariable, session *econtext.SafeSession, autocommit bool, callback func(reply *sqltypes.Result) error, resultsObserver econtext.ResultsObserver, fetchLastInsertID bool, ) []error
StreamExecuteMulti is like StreamExecute, but each shard gets its own bindVars. If len(shards) is not equal to len(bindVars), the function panics. Note we guarantee the callback will not be called concurrently by multiple go routines, through processOneStreamingResult.
type SchemaInfo ¶
type SchemaInfo interface { Tables(ks string) map[string]*vindexes.TableInfo Views(ks string) map[string]sqlparser.TableStatement UDFs(ks string) []string }
SchemaInfo is an interface to schema tracker.
type StaticConfig ¶
type StaticConfig struct { OnlineDDLEnabled bool DirectDDLEnabled bool TxMode vtgatepb.TransactionMode }
StaticConfig is a static configuration for vtgate. It is used for tests and vtexplain_vtgate where we don't want the user to control certain configs.
func (*StaticConfig) DirectEnabled ¶
func (s *StaticConfig) DirectEnabled() bool
func (*StaticConfig) OnlineEnabled ¶
func (s *StaticConfig) OnlineEnabled() bool
func (*StaticConfig) TransactionMode ¶
func (s *StaticConfig) TransactionMode() vtgatepb.TransactionMode
type TabletCacheStatus ¶
type TabletCacheStatus struct { Keyspace string Shard string TabletType topodatapb.TabletType Name string Addr string QueryCount uint64 QueryError uint64 QPS float64 AvgLatency float64 // in milliseconds }
TabletCacheStatus contains the status per destination for a gateway.
func (*TabletCacheStatus) FormattedQPS ¶
func (tcs *TabletCacheStatus) FormattedQPS() string
FormattedQPS shows a 2 digit rounded value of QPS. Used in the HTML template above.
type TabletCacheStatusList ¶
type TabletCacheStatusList []*TabletCacheStatus
TabletCacheStatusList is a slice of TabletCacheStatus.
func (TabletCacheStatusList) Len ¶
func (gtcsl TabletCacheStatusList) Len() int
Len is part of sort.Interface.
func (TabletCacheStatusList) Less ¶
func (gtcsl TabletCacheStatusList) Less(i, j int) bool
Less is part of sort.Interface.
func (TabletCacheStatusList) Swap ¶
func (gtcsl TabletCacheStatusList) Swap(i, j int)
Swap is part of sort.Interface.
type TabletGateway ¶
type TabletGateway struct { queryservice.QueryService // contains filtered or unexported fields }
TabletGateway implements the Gateway interface. This implementation uses the new healthcheck module.
func NewTabletGateway ¶
func NewTabletGateway(ctx context.Context, hc discovery.HealthCheck, serv srvtopo.Server, localCell string) *TabletGateway
NewTabletGateway creates and returns a new TabletGateway
func (*TabletGateway) CacheStatus ¶
func (gw *TabletGateway) CacheStatus() TabletCacheStatusList
CacheStatus returns a list of TabletCacheStatus per keyspace/shard/tablet_type.
func (*TabletGateway) Close ¶
func (gw *TabletGateway) Close(_ context.Context) error
Close shuts down underlying connections. This function hides the inner implementation.
func (*TabletGateway) DebugBalancerHandler ¶
func (gw *TabletGateway) DebugBalancerHandler(w http.ResponseWriter, r *http.Request)
func (*TabletGateway) DefaultConnCollation ¶
func (gw *TabletGateway) DefaultConnCollation() collations.ID
DefaultConnCollation returns the default connection collation of this TabletGateway
func (*TabletGateway) GetServingKeyspaces ¶
func (gw *TabletGateway) GetServingKeyspaces() []string
GetServingKeyspaces returns list of serving keyspaces.
func (*TabletGateway) QueryServiceByAlias ¶
func (gw *TabletGateway) QueryServiceByAlias(ctx context.Context, alias *topodatapb.TabletAlias, target *querypb.Target) (queryservice.QueryService, error)
QueryServiceByAlias satisfies the Gateway interface
func (*TabletGateway) RegisterStats ¶
func (gw *TabletGateway) RegisterStats()
RegisterStats registers the stats to export the lag since the last refresh and the checksum of the topology
func (*TabletGateway) TabletsCacheStatus ¶
func (gw *TabletGateway) TabletsCacheStatus() discovery.TabletsCacheStatusList
TabletsCacheStatus returns a displayable version of the health check cache.
func (*TabletGateway) TabletsHealthyStatus ¶
func (gw *TabletGateway) TabletsHealthyStatus() discovery.TabletsCacheStatusList
TabletsHealthyStatus returns a displayable version of the health check healthy list.
func (*TabletGateway) WaitForTablets ¶
func (gw *TabletGateway) WaitForTablets(ctx context.Context, tabletTypesToWait []topodatapb.TabletType) (err error)
WaitForTablets is part of the Gateway interface.
type TabletStatusAggregator ¶
type TabletStatusAggregator struct { Keyspace string Shard string TabletType topodatapb.TabletType Name string // the alternative name of a tablet Addr string // the host:port of a tablet QueryCount uint64 QueryError uint64 // contains filtered or unexported fields }
TabletStatusAggregator tracks tablet status for a gateway.
func NewTabletStatusAggregator ¶
func NewTabletStatusAggregator(keyspace, shard string, tabletType topodatapb.TabletType, name string) *TabletStatusAggregator
NewTabletStatusAggregator creates a TabletStatusAggregator.
func (*TabletStatusAggregator) GetCacheStatus ¶
func (tsa *TabletStatusAggregator) GetCacheStatus() *TabletCacheStatus
GetCacheStatus returns a TabletCacheStatus representing the current gateway status.
func (*TabletStatusAggregator) UpdateQueryInfo ¶
func (tsa *TabletStatusAggregator) UpdateQueryInfo(addr string, tabletType topodatapb.TabletType, elapsed time.Duration, hasError bool)
UpdateQueryInfo updates the aggregator with the given information about a query.
type TxConn ¶
type TxConn struct {
// contains filtered or unexported fields
}
TxConn is used for executing transactional requests.
func NewTxConn ¶
func NewTxConn(gw *TabletGateway, txMode dynamicconfig.TxMode) *TxConn
NewTxConn builds a new TxConn.
func (*TxConn) Begin ¶
func (txc *TxConn) Begin(ctx context.Context, session *econtext.SafeSession, txAccessModes []sqlparser.TxAccessMode) error
Begin begins a new transaction. If one is already in progress, it commits it and starts a new one.
func (*TxConn) Commit ¶
Commit commits the current transaction. The type of commit can be best effort or 2pc depending on the session setting.
func (*TxConn) ReadTransaction ¶
func (*TxConn) ReleaseAll ¶
ReleaseAll releases all the shard sessions and lock session.
func (*TxConn) ReleaseLock ¶
ReleaseLock releases the reserved connection used for locking.
func (*TxConn) ResolveTransactions ¶
ResolveTransactions fetches all unresolved transactions and resolves them.
func (*TxConn) Rollback ¶
Rollback rolls back the current transaction. There are no retries on this operation.
func (*TxConn) UnresolvedTransactions ¶
type VSchemaKeyspaceStats ¶
type VSchemaKeyspaceStats struct { Keyspace string Sharded bool TableCount int VindexCount int VindexUnknownParamsCount int Error string }
VSchemaKeyspaceStats contains a rollup of the VSchema stats for a keyspace. It is used to display a table with the information in the status page.
type VSchemaManager ¶
type VSchemaManager struct {
// contains filtered or unexported fields
}
VSchemaManager is used to watch for updates to the vschema and to implement the DDL commands to add / remove vindexes
func (*VSchemaManager) GetCurrentSrvVschema ¶
func (vm *VSchemaManager) GetCurrentSrvVschema() *vschemapb.SrvVSchema
GetCurrentSrvVschema returns a copy of the latest SrvVschema from the topo watch
func (*VSchemaManager) Rebuild ¶
func (vm *VSchemaManager) Rebuild()
Rebuild will rebuild and publish the new vschema. This method should be called when the underlying schema has changed.
func (*VSchemaManager) UpdateVSchema ¶
func (vm *VSchemaManager) UpdateVSchema(ctx context.Context, ks *topo.KeyspaceVSchemaInfo, srv *vschemapb.SrvVSchema) error
UpdateVSchema propagates the updated vschema to the topo. The entry for the given keyspace is updated in the global topo, and the full SrvVSchema is updated in all known cells.
func (*VSchemaManager) VSchemaUpdate ¶
func (vm *VSchemaManager) VSchemaUpdate(v *vschemapb.SrvVSchema, err error) bool
VSchemaUpdate builds the VSchema from SrvVschema and call subscribers.
type VSchemaStats ¶
type VSchemaStats struct { Error string Keyspaces []*VSchemaKeyspaceStats }
VSchemaStats contains a rollup of the VSchema stats.
func NewVSchemaStats ¶
func NewVSchemaStats(vschema *vindexes.VSchema, errorMessage string) *VSchemaStats
NewVSchemaStats returns a new VSchemaStats from a VSchema.
type VTGate ¶
type VTGate struct {
// contains filtered or unexported fields
}
VTGate is the rpc interface to vtgate. Only one instance can be created. It implements vtgateservice.VTGateService VTGate exposes multiple generations of interfaces.
func Init ¶
func Init( ctx context.Context, env *vtenv.Environment, hc discovery.HealthCheck, serv srvtopo.Server, cell string, tabletTypesToWait []topodatapb.TabletType, pv plancontext.PlannerVersion, ) *VTGate
Init initializes VTGate server.
func (*VTGate) CloseSession ¶
CloseSession closes the session, rolling back any implicit transactions. This has the same effect as if a "rollback" statement was executed, but does not affect the query statistics.
func (*VTGate) Execute ¶
func (vtg *VTGate) Execute( ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable, prepared bool, ) (newSession *vtgatepb.Session, qr *sqltypes.Result, err error)
Execute executes a non-streaming query.
func (*VTGate) ExecuteBatch ¶
func (vtg *VTGate) ExecuteBatch(ctx context.Context, session *vtgatepb.Session, sqlList []string, bindVariablesList []map[string]*querypb.BindVariable) (*vtgatepb.Session, []sqltypes.QueryResponse, error)
ExecuteBatch executes a batch of queries.
func (*VTGate) ExecuteMulti ¶
func (vtg *VTGate) ExecuteMulti( ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sqlString string, ) (newSession *vtgatepb.Session, qrs []*sqltypes.Result, err error)
ExecuteMulti executes multiple non-streaming queries.
func (*VTGate) Gateway ¶
func (vtg *VTGate) Gateway() *TabletGateway
Gateway returns the current gateway implementation. Mostly used for tests.
func (*VTGate) GetGatewayCacheStatus ¶
func (vtg *VTGate) GetGatewayCacheStatus() TabletCacheStatusList
GetGatewayCacheStatus returns a displayable version of the Gateway cache.
func (*VTGate) HandlePanic ¶
HandlePanic recovers from panics, and logs / increment counters
func (*VTGate) IsHealthy ¶
IsHealthy returns nil if server is healthy. Otherwise, it returns an error indicating the reason.
func (*VTGate) Prepare ¶
func (vtg *VTGate) Prepare(ctx context.Context, session *vtgatepb.Session, sql string) (newSession *vtgatepb.Session, fld []*querypb.Field, paramsCount uint16, err error)
Prepare supports non-streaming prepare statement query with multi shards
func (*VTGate) StreamExecute ¶
func (vtg *VTGate) StreamExecute(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable, callback func(*sqltypes.Result) error) (*vtgatepb.Session, error)
StreamExecute executes a streaming query. Note we guarantee the callback will not be called concurrently by multiple go routines.
func (*VTGate) StreamExecuteMulti ¶
func (vtg *VTGate) StreamExecuteMulti(ctx context.Context, mysqlCtx vtgateservice.MySQLConnection, session *vtgatepb.Session, sqlString string, callback func(qr sqltypes.QueryResponse, more bool, firstPacket bool) error) (*vtgatepb.Session, error)
StreamExecuteMulti executes a streaming query. Note we guarantee the callback will not be called concurrently by multiple go routines.
func (*VTGate) VSchemaStats ¶
func (vtg *VTGate) VSchemaStats() *VSchemaStats
VSchemaStats returns the loaded vschema stats.
func (*VTGate) VStream ¶
func (vtg *VTGate) VStream(ctx context.Context, tabletType topodatapb.TabletType, vgtid *binlogdatapb.VGtid, filter *binlogdatapb.Filter, flags *vtgatepb.VStreamFlags, send func([]*binlogdatapb.VEvent) error) error
VStream streams binlog events.
Source Files
¶
- api.go
- debugenv.go
- executor.go
- executor_scatter_stats.go
- executor_stats.go
- plan_execute.go
- plugin_mysql_server.go
- plugin_mysql_server_unix.go
- production.go
- querylog.go
- querylogz.go
- queryz.go
- resolver.go
- scatter_conn.go
- static_config.go
- status.go
- tabletgateway.go
- tx_conn.go
- viper_config.go
- vschema_manager.go
- vschema_stats.go
- vstream_manager.go
- vtgate.go
Directories
¶
Path | Synopsis |
---|---|
Package buffer provides a buffer for PRIMARY traffic during failovers.
|
Package buffer provides a buffer for PRIMARY traffic during failovers. |
Package fakerpcvtgateconn provides a fake implementation of vtgateconn.Impl that doesn't do any RPC, but uses a local map to return results.
|
Package fakerpcvtgateconn provides a fake implementation of vtgateconn.Impl that doesn't do any RPC, but uses a local map to return results. |
Package grpcvtgateconn provides gRPC connectivity for VTGate.
|
Package grpcvtgateconn provides gRPC connectivity for VTGate. |
Package grpcvtgateservice provides the gRPC glue for vtgate
|
Package grpcvtgateservice provides the gRPC glue for vtgate |
operators
Package operators contains the operators used to plan queries.
|
Package operators contains the operators used to plan queries. |
Package vtgateservice provides to interface definition for the vtgate service
|
Package vtgateservice provides to interface definition for the vtgate service |