Documentation ¶
Overview ¶
Package vtgate provides query routing rpc services for vttablets.
Index ¶
- Constants
- Variables
- func RegisterPluginInitializer(initializer func())
- func StrsEquals(a, b []string) bool
- type Executor
- func (e *Executor) Execute(ctx context.Context, method string, safeSession *SafeSession, sql string, ...) (result *sqltypes.Result, err error)
- func (e *Executor) IsKeyspaceRangeBasedSharded(keyspace string) bool
- func (e *Executor) MessageAck(ctx context.Context, keyspace, name string, ids []*querypb.Value) (int64, error)
- func (e *Executor) MessageStream(ctx context.Context, keyspace string, shard string, ...) error
- func (e *Executor) ParseDestinationTarget(targetString string) (string, topodatapb.TabletType, key.Destination, error)
- func (e *Executor) Plans() *cache.LRUCache
- func (e *Executor) Prepare(ctx context.Context, method string, safeSession *SafeSession, sql string, ...) (fld []*querypb.Field, err error)
- func (e *Executor) SaveVSchema(vschema *vindexes.VSchema, stats *VSchemaStats)
- func (e *Executor) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (e *Executor) StreamExecute(ctx context.Context, method string, safeSession *SafeSession, sql string, ...) (err error)
- func (e *Executor) VSchema() *vindexes.VSchema
- func (e *Executor) VSchemaStats() *VSchemaStats
- func (e *Executor) WriteScatterStats(w http.ResponseWriter)
- type LogStats
- func (stats *LogStats) Context() context.Context
- func (stats *LogStats) ContextHTML() template.HTML
- func (stats *LogStats) EffectiveCaller() string
- func (stats *LogStats) ErrorStr() string
- func (stats *LogStats) EventTime() time.Time
- func (stats *LogStats) ImmediateCaller() string
- func (stats *LogStats) Logf(w io.Writer, params url.Values) error
- func (stats *LogStats) RemoteAddrUsername() (string, string)
- func (stats *LogStats) Send()
- func (stats *LogStats) TotalTime() time.Duration
- type RegisterVTGate
- type Resolver
- func (res *Resolver) Execute(ctx context.Context, sql string, bindVars map[string]*querypb.BindVariable, ...) (*sqltypes.Result, error)
- func (res *Resolver) ExecuteBatch(ctx context.Context, tabletType topodatapb.TabletType, asTransaction bool, ...) ([]sqltypes.Result, error)
- func (res *Resolver) ExecuteEntityIds(ctx context.Context, sql string, ...) (*sqltypes.Result, error)
- func (res *Resolver) GetGatewayCacheStatus() gateway.TabletCacheStatusList
- func (res *Resolver) MessageAckKeyspaceIds(ctx context.Context, keyspace, name string, ...) (int64, error)
- func (res *Resolver) MessageStream(ctx context.Context, keyspace string, shard string, ...) error
- func (res *Resolver) StreamExecute(ctx context.Context, sql string, bindVars map[string]*querypb.BindVariable, ...) error
- type SafeSession
- func (session *SafeSession) Append(shardSession *vtgatepb.Session_ShardSession, txMode vtgatepb.TransactionMode) error
- func (session *SafeSession) AutocommitApproval() bool
- func (session *SafeSession) ClearWarnings()
- func (session *SafeSession) Find(keyspace, shard string, tabletType topodatapb.TabletType) int64
- func (session *SafeSession) InTransaction() bool
- func (session *SafeSession) MustRollback() bool
- func (session *SafeSession) RecordWarning(warning *querypb.QueryWarning)
- func (session *SafeSession) Reset()
- func (session *SafeSession) SetAutocommittable(flag bool)
- func (session *SafeSession) SetCommitOrder(co vtgatepb.CommitOrder)
- func (session *SafeSession) SetRollback()
- func (session *SafeSession) SetUserDefinedVariable(key string, value *querypb.BindVariable)
- type ScatterConn
- func (stc *ScatterConn) Close() error
- func (stc *ScatterConn) Execute(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable, ...) (*sqltypes.Result, error)
- func (stc *ScatterConn) ExecuteBatch(ctx context.Context, batchRequest *scatterBatchRequest, ...) (qrs []sqltypes.Result, err error)
- func (stc *ScatterConn) ExecuteEntityIds(ctx context.Context, rss []*srvtopo.ResolvedShard, sqls []string, ...) (*sqltypes.Result, error)
- func (stc *ScatterConn) ExecuteMultiShard(ctx context.Context, rss []*srvtopo.ResolvedShard, ...) (qr *sqltypes.Result, errs []error)
- func (stc *ScatterConn) GetGatewayCacheStatus() gateway.TabletCacheStatusList
- func (stc *ScatterConn) MessageAck(ctx context.Context, rss []*srvtopo.ResolvedShard, values [][]*querypb.Value, ...) (int64, error)
- func (stc *ScatterConn) MessageStream(ctx context.Context, rss []*srvtopo.ResolvedShard, name string, ...) error
- func (stc *ScatterConn) StreamExecute(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable, ...) error
- func (stc *ScatterConn) StreamExecuteMulti(ctx context.Context, query string, rss []*srvtopo.ResolvedShard, ...) error
- type TxConn
- type VSchemaKeyspaceStats
- type VSchemaManager
- type VSchemaStats
- type VTGate
- func (vtg *VTGate) Begin(ctx context.Context, singledb bool) (*vtgatepb.Session, error)
- func (vtg *VTGate) Commit(ctx context.Context, twopc bool, session *vtgatepb.Session) error
- func (vtg *VTGate) Execute(ctx context.Context, session *vtgatepb.Session, sql string, ...) (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) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, ...) ([]sqltypes.Result, error)
- func (vtg *VTGate) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, ...) ([]sqltypes.Result, error)
- func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, sql string, ...) (*sqltypes.Result, error)
- func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, sql string, ...) (*sqltypes.Result, error)
- func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, sql string, ...) (*sqltypes.Result, error)
- func (vtg *VTGate) ExecuteShards(ctx context.Context, sql string, ...) (*sqltypes.Result, error)
- func (vtg *VTGate) Gateway() gateway.Gateway
- func (vtg *VTGate) GetGatewayCacheStatus() gateway.TabletCacheStatusList
- func (vtg *VTGate) GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error)
- func (vtg *VTGate) HandlePanic(err *error)
- func (vtg *VTGate) IsHealthy() error
- func (vtg *VTGate) MessageAck(ctx context.Context, keyspace string, name string, ids []*querypb.Value) (int64, error)
- func (vtg *VTGate) MessageAckKeyspaceIds(ctx context.Context, keyspace string, name string, ...) (int64, error)
- func (vtg *VTGate) MessageStream(ctx context.Context, keyspace string, shard string, ...) error
- func (vtg *VTGate) Prepare(ctx context.Context, session *vtgatepb.Session, sql string, ...) (newSession *vtgatepb.Session, fld []*querypb.Field, err error)
- func (vtg *VTGate) ResolveTransaction(ctx context.Context, dtid string) error
- func (vtg *VTGate) Rollback(ctx context.Context, session *vtgatepb.Session) error
- func (vtg *VTGate) StreamExecute(ctx context.Context, session *vtgatepb.Session, sql string, ...) error
- func (vtg *VTGate) StreamExecuteKeyRanges(ctx context.Context, sql string, ...) error
- func (vtg *VTGate) StreamExecuteKeyspaceIds(ctx context.Context, sql string, ...) error
- func (vtg *VTGate) StreamExecuteShards(ctx context.Context, sql string, ...) error
- func (vtg *VTGate) VSchemaStats() *VSchemaStats
- func (vtg *VTGate) VStream(ctx context.Context, tabletType topodatapb.TabletType, ...) error
Constants ¶
const ( // ExecutorTemplate is the HTML template to display ExecutorStats. ExecutorTemplate = `` /* 2779-byte string literal not displayed */ )
const ( // VSchemaTemplate is the HTML template to display VSchemaStats. VSchemaTemplate = `` /* 749-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" // QueryLogger enables streaming logging of queries QueryLogger = streamlog.New("VTGate", 10) )
var RegisterVTGates []RegisterVTGate
RegisterVTGates stores register funcs for VTGate server.
Functions ¶
func RegisterPluginInitializer ¶
func RegisterPluginInitializer(initializer func())
RegisterPluginInitializer lets plugins register themselves to be init'ed at servenv.OnRun-time
func StrsEquals ¶
StrsEquals compares contents of two string slices.
Types ¶
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, serv srvtopo.Server, cell, statsName string, resolver *Resolver, normalize bool, streamSize int, queryPlanCacheSize int64) *Executor
NewExecutor creates a new Executor.
func (*Executor) Execute ¶
func (e *Executor) Execute(ctx context.Context, method string, safeSession *SafeSession, sql string, bindVars map[string]*querypb.BindVariable) (result *sqltypes.Result, err error)
Execute executes a non-streaming query.
func (*Executor) IsKeyspaceRangeBasedSharded ¶
IsKeyspaceRangeBasedSharded returns true if the keyspace in the vschema is marked as sharded.
func (*Executor) MessageAck ¶
func (e *Executor) MessageAck(ctx context.Context, keyspace, name string, ids []*querypb.Value) (int64, error)
MessageAck acks messages. FIXME(alainjobart) the keyspace field here is not used for routing, but just for finding the table in the VSchema. If we don't find the table in the VSchema, we could just assume it's sharded (which would work for unsharded as well) and route it to the provided keyspace.
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.Destination, error)
ParseDestinationTarget parses destination target string and sets default keyspace if possible.
func (*Executor) Prepare ¶
func (e *Executor) Prepare(ctx context.Context, method string, safeSession *SafeSession, sql string, bindVars map[string]*querypb.BindVariable) (fld []*querypb.Field, err error)
Prepare executes a prepare statements.
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) StreamExecute ¶
func (e *Executor) StreamExecute(ctx context.Context, method string, safeSession *SafeSession, sql string, bindVars map[string]*querypb.BindVariable, target querypb.Target, callback func(*sqltypes.Result) error) (err error)
StreamExecute executes a streaming query.
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 LogStats ¶
type LogStats struct { Ctx context.Context Method string Target *querypb.Target StmtType string SQL string BindVariables map[string]*querypb.BindVariable StartTime time.Time EndTime time.Time ShardQueries uint32 RowsAffected uint64 PlanTime time.Duration ExecuteTime time.Duration CommitTime time.Duration Error error }
LogStats records the stats for a single vtgate query
func NewLogStats ¶
func NewLogStats(ctx context.Context, methodName, sql string, bindVars map[string]*querypb.BindVariable) *LogStats
NewLogStats constructs a new LogStats with supplied Method and ctx field values, and the StartTime field set to the present time.
func (*LogStats) ContextHTML ¶
ContextHTML returns the HTML version of the context that was used, or "". This is a method on LogStats instead of a field so that it doesn't need to be passed by value everywhere.
func (*LogStats) EffectiveCaller ¶
EffectiveCaller returns the effective caller stored in LogStats.Ctx
func (*LogStats) ImmediateCaller ¶
ImmediateCaller returns the immediate caller stored in LogStats.Ctx
func (*LogStats) Logf ¶
Logf formats the log record to the given writer, either as tab-separated list of logged fields or as JSON.
func (*LogStats) RemoteAddrUsername ¶
RemoteAddrUsername returns some parts of CallInfo if set
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) Execute ¶
func (res *Resolver) Execute( ctx context.Context, sql string, bindVars map[string]*querypb.BindVariable, keyspace string, tabletType topodatapb.TabletType, destination key.Destination, session *SafeSession, notInTransaction bool, options *querypb.ExecuteOptions, logStats *LogStats, canAutocommit bool, ) (*sqltypes.Result, error)
Execute executes a non-streaming query based on provided destination. It retries query if new keyspace/shards are re-resolved after a retryable error.
func (*Resolver) ExecuteBatch ¶
func (res *Resolver) ExecuteBatch( ctx context.Context, tabletType topodatapb.TabletType, asTransaction bool, session *vtgatepb.Session, options *querypb.ExecuteOptions, buildBatchRequest func() (*scatterBatchRequest, error), ) ([]sqltypes.Result, error)
ExecuteBatch executes a group of queries based on shards resolved by given func. It retries query if new keyspace/shards are re-resolved after a retryable error.
func (*Resolver) ExecuteEntityIds ¶
func (res *Resolver) ExecuteEntityIds( ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions, ) (*sqltypes.Result, error)
ExecuteEntityIds executes a non-streaming query based on given KeyspaceId map. It retries query if new keyspace/shards are re-resolved after a retryable error.
func (*Resolver) GetGatewayCacheStatus ¶
func (res *Resolver) GetGatewayCacheStatus() gateway.TabletCacheStatusList
GetGatewayCacheStatus returns a displayable version of the Gateway cache.
func (*Resolver) MessageAckKeyspaceIds ¶
func (res *Resolver) MessageAckKeyspaceIds(ctx context.Context, keyspace, name string, idKeyspaceIDs []*vtgatepb.IdKeyspaceId) (int64, error)
MessageAckKeyspaceIds routes message acks based on the associated keyspace ids.
func (*Resolver) MessageStream ¶
func (res *Resolver) MessageStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, name string, callback func(*sqltypes.Result) error) error
MessageStream streams messages.
func (*Resolver) StreamExecute ¶
func (res *Resolver) StreamExecute( ctx context.Context, sql string, bindVars map[string]*querypb.BindVariable, keyspace string, tabletType topodatapb.TabletType, destination key.Destination, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error, ) error
StreamExecute executes a streaming query on shards resolved by given func. This function currently temporarily enforces the restriction of executing on one shard since it cannot merge-sort the results to guarantee ordering of response which is needed for checkpointing. Note we guarantee the callback will not be called concurrently by multiple go routines.
type SafeSession ¶
SafeSession is a mutex-protected version of the Session. It is thread-safe if each thread only accesses one shard. (the use pattern is 'Find', if not found, then 'Append', for a single shard)
func NewAutocommitSession ¶
func NewAutocommitSession(sessn *vtgatepb.Session) *SafeSession
NewAutocommitSession returns a SafeSession based on the original session, but with autocommit enabled.
func NewSafeSession ¶
func NewSafeSession(sessn *vtgatepb.Session) *SafeSession
NewSafeSession returns a new SafeSession based on the Session
func (*SafeSession) Append ¶
func (session *SafeSession) Append(shardSession *vtgatepb.Session_ShardSession, txMode vtgatepb.TransactionMode) error
Append adds a new ShardSession
func (*SafeSession) AutocommitApproval ¶
func (session *SafeSession) AutocommitApproval() bool
AutocommitApproval returns true if we can perform a single round-trip autocommit. If so, the caller is responsible for committing their transaction.
func (*SafeSession) ClearWarnings ¶
func (session *SafeSession) ClearWarnings()
ClearWarnings removes all the warnings from the session
func (*SafeSession) Find ¶
func (session *SafeSession) Find(keyspace, shard string, tabletType topodatapb.TabletType) int64
Find returns the transactionId, if any, for a session
func (*SafeSession) InTransaction ¶
func (session *SafeSession) InTransaction() bool
InTransaction returns true if we are in a transaction
func (*SafeSession) MustRollback ¶
func (session *SafeSession) MustRollback() bool
MustRollback returns true if the transaction must be rolled back.
func (*SafeSession) RecordWarning ¶
func (session *SafeSession) RecordWarning(warning *querypb.QueryWarning)
RecordWarning stores the given warning in the session
func (*SafeSession) SetAutocommittable ¶
func (session *SafeSession) SetAutocommittable(flag bool)
SetAutocommittable sets the state to autocommitable if true. Otherwise, it's notAutocommitable.
func (*SafeSession) SetCommitOrder ¶
func (session *SafeSession) SetCommitOrder(co vtgatepb.CommitOrder)
SetCommitOrder sets the commit order.
func (*SafeSession) SetRollback ¶
func (session *SafeSession) SetRollback()
SetRollback sets the flag indicating that the transaction must be rolled back. The call is a no-op if the session is not in a transaction.
func (*SafeSession) SetUserDefinedVariable ¶
func (session *SafeSession) SetUserDefinedVariable(key string, value *querypb.BindVariable)
SetUserDefinedVariable sets the user defined variable in the session.
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 gateway.Gateway, hc discovery.HealthCheck) *ScatterConn
NewScatterConn creates a new ScatterConn.
func (*ScatterConn) Close ¶
func (stc *ScatterConn) Close() error
Close closes the underlying Gateway.
func (*ScatterConn) Execute ¶
func (stc *ScatterConn) Execute( ctx context.Context, query string, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard, tabletType topodatapb.TabletType, session *SafeSession, notInTransaction bool, options *querypb.ExecuteOptions, autocommit bool, ) (*sqltypes.Result, error)
Execute executes a non-streaming query on the specified shards.
func (*ScatterConn) ExecuteBatch ¶
func (stc *ScatterConn) ExecuteBatch( ctx context.Context, batchRequest *scatterBatchRequest, tabletType topodatapb.TabletType, asTransaction bool, session *SafeSession, options *querypb.ExecuteOptions) (qrs []sqltypes.Result, err error)
ExecuteBatch executes a batch of non-streaming queries on the specified shards.
func (*ScatterConn) ExecuteEntityIds ¶
func (stc *ScatterConn) ExecuteEntityIds( ctx context.Context, rss []*srvtopo.ResolvedShard, sqls []string, bindVars []map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, session *SafeSession, notInTransaction bool, options *querypb.ExecuteOptions, ) (*sqltypes.Result, error)
ExecuteEntityIds executes queries that are shard specific.
func (*ScatterConn) ExecuteMultiShard ¶
func (stc *ScatterConn) ExecuteMultiShard( ctx context.Context, rss []*srvtopo.ResolvedShard, queries []*querypb.BoundQuery, tabletType topodatapb.TabletType, session *SafeSession, notInTransaction bool, autocommit 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() gateway.TabletCacheStatusList
GetGatewayCacheStatus returns a displayable version of the Gateway cache.
func (*ScatterConn) MessageAck ¶
func (stc *ScatterConn) MessageAck(ctx context.Context, rss []*srvtopo.ResolvedShard, values [][]*querypb.Value, name string) (int64, error)
MessageAck acks messages across multiple shards.
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) StreamExecute ¶
func (stc *ScatterConn) StreamExecute( ctx context.Context, query string, bindVars map[string]*querypb.BindVariable, rss []*srvtopo.ResolvedShard, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(reply *sqltypes.Result) error, ) error
StreamExecute executes a streaming query on vttablet. The retry rules are the same. 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, query string, rss []*srvtopo.ResolvedShard, bindVars []map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(reply *sqltypes.Result) error, ) 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 TxConn ¶
type TxConn struct {
// contains filtered or unexported fields
}
TxConn is used for executing transactional requests.
func NewTxConn ¶
func NewTxConn(gw gateway.Gateway, txMode vtgatepb.TransactionMode) *TxConn
NewTxConn builds a new TxConn.
func (*TxConn) Begin ¶
func (txc *TxConn) Begin(ctx context.Context, session *SafeSession) error
Begin begins a new transaction. If one is already in progress, it commits it and starts a new one.
func (*TxConn) Commit ¶
func (txc *TxConn) Commit(ctx context.Context, session *SafeSession) error
Commit commits the current transaction. The type of commit can be best effort or 2pc depending on the session setting.
type VSchemaKeyspaceStats ¶
type VSchemaKeyspaceStats struct { Keyspace string Sharded bool TableCount int VindexCount 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) UpdateVSchema ¶
func (vm *VSchemaManager) UpdateVSchema(ctx context.Context, ksName string, vschema *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.
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. The V3 interface is the latest one, which is capable of processing queries with no additional hints. V2 functions require the keyspace id or keyrange to be specified. V1 functions require shard info. V0 functions are informational that return topo information. Often, 'V2' or 'legacy' is used to refer to all legacy versions of the API (V2, V1 and V0).
func Init ¶
func Init(ctx context.Context, hc discovery.HealthCheck, serv srvtopo.Server, cell string, retryCount int, tabletTypesToWait []topodatapb.TabletType) *VTGate
Init initializes VTGate server.
func (*VTGate) Execute ¶
func (vtg *VTGate) Execute(ctx context.Context, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (newSession *vtgatepb.Session, qr *sqltypes.Result, err error)
Execute executes a non-streaming query. This is a V3 function.
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. This is a V3 function.
func (*VTGate) ExecuteBatchKeyspaceIds ¶
func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, tabletType topodatapb.TabletType, asTransaction bool, session *vtgatepb.Session, options *querypb.ExecuteOptions) ([]sqltypes.Result, error)
ExecuteBatchKeyspaceIds executes a group of queries based on the specified keyspace ids. This is a legacy function.
func (*VTGate) ExecuteBatchShards ¶
func (vtg *VTGate) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, tabletType topodatapb.TabletType, asTransaction bool, session *vtgatepb.Session, options *querypb.ExecuteOptions) ([]sqltypes.Result, error)
ExecuteBatchShards executes a group of queries on the specified shards. This is a legacy function.
func (*VTGate) ExecuteEntityIds ¶
func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
ExecuteEntityIds excutes a non-streaming query based on given KeyspaceId map. This is a legacy function.
func (*VTGate) ExecuteKeyRanges ¶
func (vtg *VTGate) ExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, keyspace string, keyRanges []*topodatapb.KeyRange, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
ExecuteKeyRanges executes a non-streaming query based on the specified keyranges. This is a legacy function.
func (*VTGate) ExecuteKeyspaceIds ¶
func (vtg *VTGate) ExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, keyspace string, keyspaceIds [][]byte, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
ExecuteKeyspaceIds executes a non-streaming query based on the specified keyspace ids. This is a legacy function.
func (*VTGate) ExecuteShards ¶
func (vtg *VTGate) ExecuteShards(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, keyspace string, shards []string, tabletType topodatapb.TabletType, session *vtgatepb.Session, notInTransaction bool, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
ExecuteShards executes a non-streaming query on the specified shards. This is a legacy function.
func (*VTGate) GetGatewayCacheStatus ¶
func (vtg *VTGate) GetGatewayCacheStatus() gateway.TabletCacheStatusList
GetGatewayCacheStatus returns a displayable version of the Gateway cache.
func (*VTGate) GetSrvKeyspace ¶
func (vtg *VTGate) GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error)
GetSrvKeyspace is part of the vtgate service API.
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) MessageAck ¶
func (vtg *VTGate) MessageAck(ctx context.Context, keyspace string, name string, ids []*querypb.Value) (int64, error)
MessageAck is part of the vtgate service API. This is a V3 level API that's sent to the executor. The table name will be resolved using V3 rules, and the routing will make use of vindexes for sharded keyspaces. TODO(sougou): Deprecate this in favor of an SQL statement.
func (*VTGate) MessageAckKeyspaceIds ¶
func (vtg *VTGate) MessageAckKeyspaceIds(ctx context.Context, keyspace string, name string, idKeyspaceIDs []*vtgatepb.IdKeyspaceId) (int64, error)
MessageAckKeyspaceIds is part of the vtgate service API. It routes message acks based on the associated keyspace ids.
func (*VTGate) MessageStream ¶
func (vtg *VTGate) 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. Note we guarantee the callback will not be called concurrently by multiple go routines.
func (*VTGate) Prepare ¶
func (vtg *VTGate) Prepare(ctx context.Context, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (newSession *vtgatepb.Session, fld []*querypb.Field, err error)
Prepare supports non-streaming prepare statement query with multi shards
func (*VTGate) ResolveTransaction ¶
ResolveTransaction resolves the specified 2PC transaction.
func (*VTGate) StreamExecute ¶
func (vtg *VTGate) StreamExecute(ctx context.Context, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable, callback func(*sqltypes.Result) error) error
StreamExecute executes a streaming query. This is a V3 function. Note we guarantee the callback will not be called concurrently by multiple go routines.
func (*VTGate) StreamExecuteKeyRanges ¶
func (vtg *VTGate) StreamExecuteKeyRanges(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, keyspace string, keyRanges []*topodatapb.KeyRange, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error
StreamExecuteKeyRanges executes a streaming query on the specified KeyRanges. The KeyRanges are resolved to shards using the serving graph. This function currently temporarily enforces the restriction of executing on one shard since it cannot merge-sort the results to guarantee ordering of response which is needed for checkpointing. The api supports supplying multiple keyranges to make it future proof. This is a legacy function. Note we guarantee the callback will not be called concurrently by multiple go routines.
func (*VTGate) StreamExecuteKeyspaceIds ¶
func (vtg *VTGate) StreamExecuteKeyspaceIds(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, keyspace string, keyspaceIds [][]byte, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error
StreamExecuteKeyspaceIds executes a streaming query on the specified KeyspaceIds. The KeyspaceIds are resolved to shards using the serving graph. This function currently temporarily enforces the restriction of executing on one shard since it cannot merge-sort the results to guarantee ordering of response which is needed for checkpointing. The api supports supplying multiple KeyspaceIds to make it future proof. This is a legacy function. Note we guarantee the callback will not be called concurrently by multiple go routines.
func (*VTGate) StreamExecuteShards ¶
func (vtg *VTGate) StreamExecuteShards(ctx context.Context, sql string, bindVariables map[string]*querypb.BindVariable, keyspace string, shards []string, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) error
StreamExecuteShards executes a streaming query on the specified shards. This is a legacy function. 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, send func([]*binlogdatapb.VEvent) error) error
VStream streams binlog events.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package buffer provides a buffer for MASTER traffic during failovers.
|
Package buffer provides a buffer for MASTER 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 gateway contains the routing layer of vtgate.
|
Package gateway contains the routing layer of vtgate. |
Package gatewaytest contains a test suite to run against a Gateway object.
|
Package gatewaytest contains a test suite to run against a Gateway object. |
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 |
Package planbuilder allows you to build execution plans that describe how to fulfill a query that may span multiple keyspaces or shards.
|
Package planbuilder allows you to build execution plans that describe how to fulfill a query that may span multiple keyspaces or shards. |
Package vtgateservice provides to interface definition for the vtgate service
|
Package vtgateservice provides to interface definition for the vtgate service |