vtgate

package
v3.0.0-rc.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2018 License: Apache-2.0 Imports: 63 Imported by: 0

Documentation

Overview

Package vtgate provides query routing rpc services for vttablets.

Index

Constants

View Source
const (
	// ExecutorTemplate is the HTML template to display ExecutorStats.
	ExecutorTemplate = `` /* 2713-byte string literal not displayed */

)
View Source
const (
	// VSchemaTemplate is the HTML template to display VSchemaStats.
	VSchemaTemplate = `` /* 749-byte string literal not displayed */

)

Variables

View Source
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)
)
View Source
var RegisterL2VTGates []RegisterL2VTGate

RegisterL2VTGates stores register funcs for L2VTGate server.

View Source
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

func StrsEquals(a, b []string) bool

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, legacyAutocommit bool) *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

func (e *Executor) IsKeyspaceRangeBasedSharded(keyspace string) bool

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) Plans

func (e *Executor) Plans() *cache.LRUCache

Plans returns the LRU plan cache

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) VSchema

func (e *Executor) VSchema() *vindexes.VSchema

VSchema returns the VSchema.

func (*Executor) VSchemaStats

func (e *Executor) VSchemaStats() *VSchemaStats

VSchemaStats returns the loaded vschema stats.

type L2VTGate

type L2VTGate struct {
	queryservice.QueryService
	// contains filtered or unexported fields
}

L2VTGate implements queryservice.QueryService and forwards queries to the underlying gateway.

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) Context

func (stats *LogStats) Context() context.Context

Context returns the context used by LogStats.

func (*LogStats) ContextHTML

func (stats *LogStats) ContextHTML() template.HTML

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

func (stats *LogStats) EffectiveCaller() string

EffectiveCaller returns the effective caller stored in LogStats.Ctx

func (*LogStats) ErrorStr

func (stats *LogStats) ErrorStr() string

ErrorStr returns the error string or ""

func (*LogStats) EventTime

func (stats *LogStats) EventTime() time.Time

EventTime returns the time the event was created.

func (*LogStats) ImmediateCaller

func (stats *LogStats) ImmediateCaller() string

ImmediateCaller returns the immediate caller stored in LogStats.Ctx

func (*LogStats) Logf

func (stats *LogStats) Logf(w io.Writer, params url.Values) error

Logf formats the log record to the given writer, either as tab-separated list of logged fields or as JSON.

func (*LogStats) RemoteAddrUsername

func (stats *LogStats) RemoteAddrUsername() (string, string)

RemoteAddrUsername returns some parts of CallInfo if set

func (*LogStats) Send

func (stats *LogStats) Send()

Send finalizes a record and sends it

func (*LogStats) TotalTime

func (stats *LogStats) TotalTime() time.Duration

TotalTime returns how long this query has been running

type RegisterL2VTGate

type RegisterL2VTGate func(queryservice.QueryService)

RegisterL2VTGate defines the type of registration mechanism.

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 *vtgatepb.Session,
	notInTransaction bool,
	options *querypb.ExecuteOptions,
	logStats *LogStats,
) (*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 mutiple go routines.

func (*Resolver) UpdateStream

func (res *Resolver) UpdateStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, tabletType topodatapb.TabletType, timestamp int64, event *querypb.EventToken, callback func(*querypb.StreamEvent, int64) error) error

UpdateStream streams the events. TODO(alainjobart): Implement the multi-shards merge code.

type SafeSession

type SafeSession struct {
	*vtgatepb.Session
	// contains filtered or unexported fields
}

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 commiting 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) Reset

func (session *SafeSession) Reset()

Reset clears the session

func (*SafeSession) SetAutocommitable

func (session *SafeSession) SetAutocommitable(flag bool)

SetAutocommitable sets the state to autocommitable if true. Otherwise, it's notAutocommitable.

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.

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,
) (*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 mutiple go routines, through processOneStreamingResult.

func (*ScatterConn) SplitQuery

func (stc *ScatterConn) SplitQuery(
	ctx context.Context,
	sql string,
	bindVariables map[string]*querypb.BindVariable,
	splitColumns []string,
	perShardSplitCount int64,
	numRowsPerQueryPart int64,
	algorithm querypb.SplitQueryRequest_Algorithm,
	rss []*srvtopo.ResolvedShard,
	querySplitToQueryPartFunc func(
		querySplit *querypb.QuerySplit, rs *srvtopo.ResolvedShard) (*vtgatepb.SplitQueryResponse_Part, error)) ([]*vtgatepb.SplitQueryResponse_Part, error)

SplitQuery scatters a SplitQuery request to the shards whose names are given in 'shards'. For every set of *querypb.QuerySplit's received from a shard, it applies the given 'querySplitToPartFunc' function to convert each *querypb.QuerySplit into a 'SplitQueryResponse_Part' message. Finally, it aggregates the obtained SplitQueryResponse_Parts across all shards and returns the resulting slice.

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 mutiple 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 mutiple go routines, through processOneStreamingResult.

func (*ScatterConn) UpdateStream

func (stc *ScatterConn) UpdateStream(ctx context.Context, rs *srvtopo.ResolvedShard, timestamp int64, position string, callback func(*querypb.StreamEvent) error) error

UpdateStream just sends the query to the ResolvedShard, and sends the results back.

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 commmits 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.

func (*TxConn) Resolve

func (txc *TxConn) Resolve(ctx context.Context, dtid string) error

Resolve resolves the specified 2PC transaction.

func (*TxConn) Rollback

func (txc *TxConn) Rollback(ctx context.Context, session *SafeSession) error

Rollback rolls back the current transaction. There are no retries on this operation.

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) Begin

func (vtg *VTGate) Begin(ctx context.Context, singledb bool) (*vtgatepb.Session, error)

Begin begins a transaction. This is a legacy function.

func (*VTGate) Commit

func (vtg *VTGate) Commit(ctx context.Context, twopc bool, session *vtgatepb.Session) error

Commit commits a transaction. This is a legacy function.

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) Gateway

func (vtg *VTGate) Gateway() gateway.Gateway

Gateway returns the current gateway implementation. Mostly used for tests.

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

func (vtg *VTGate) HandlePanic(err *error)

HandlePanic recovers from panics, and logs / increment counters

func (*VTGate) IsHealthy

func (vtg *VTGate) IsHealthy() error

IsHealthy returns nil if server is healthy. Otherwise, it returns an error indicating the reason.

func (*VTGate) L2VTGate

func (vtg *VTGate) L2VTGate() *L2VTGate

L2VTGate returns the L2VTGate object. Mostly used for tests.

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 mutiple go routines.

func (*VTGate) ResolveTransaction

func (vtg *VTGate) ResolveTransaction(ctx context.Context, dtid string) error

ResolveTransaction resolves the specified 2PC transaction.

func (*VTGate) Rollback

func (vtg *VTGate) Rollback(ctx context.Context, session *vtgatepb.Session) error

Rollback rolls back a transaction. This is a legacy function.

func (*VTGate) SplitQuery

func (vtg *VTGate) SplitQuery(
	ctx context.Context,
	keyspace string,
	sql string,
	bindVariables map[string]*querypb.BindVariable,
	splitColumns []string,
	splitCount int64,
	numRowsPerQueryPart int64,
	algorithm querypb.SplitQueryRequest_Algorithm) ([]*vtgatepb.SplitQueryResponse_Part, error)

SplitQuery implements the SplitQuery RPC. This is the new version that supports multiple split-columns and multiple splitting algorithms. See the documentation of SplitQueryRequest in "proto/vtgate.proto" for more information.

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 mutiple 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 mutiple 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 mutiple 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 mutiple go routines.

func (*VTGate) UpdateStream

func (vtg *VTGate) UpdateStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, tabletType topodatapb.TabletType, timestamp int64, event *querypb.EventToken, callback func(*querypb.StreamEvent, int64) error) error

UpdateStream is part of the vtgate service API. Note we guarantee the callback will not be called concurrently by mutiple go routines, as the current implementation can only target one shard.

func (*VTGate) VSchemaStats

func (vtg *VTGate) VSchemaStats() *VSchemaStats

VSchemaStats returns the loaded vschema stats.

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 vtgateconntest provides the test methods to make sure a vtgateconn/vtgateservice pair over RPC works correctly.
Package vtgateconntest provides the test methods to make sure a vtgateconn/vtgateservice pair over RPC works correctly.
Package vtgateservice provides to interface definition for the vtgate service
Package vtgateservice provides to interface definition for the vtgate service
vtgateservice_testing
Package vtgateservice_testing is a generated GoMock package.
Package vtgateservice_testing is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL