tabletserver

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 81 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// StateNotConnected is the state where tabletserver is not
	// connected to an underlying mysql instance. In this state we close
	// query engine since MySQL is probably unavailable
	StateNotConnected = servingState(iota)
	// StateNotServing is the state where tabletserver is connected
	// to an underlying mysql instance, but is not serving queries.
	// We do not close the query engine to not close the pool. We keep
	// the query engine open but prevent queries from running by blocking them
	// in StartRequest.
	StateNotServing
	// StateServing is where queries are allowed.
	StateServing
)
View Source
const (
	// RedoStateFailed represents the Failed state for redo_state.
	RedoStateFailed = 0
	// RedoStatePrepared represents the Prepared state for redo_state.
	RedoStatePrepared = 1
	// DTStatePrepare represents the PREPARE state for dt_state.
	DTStatePrepare = querypb.TransactionState_PREPARE
	// DTStateCommit represents the COMMIT state for dt_state.
	DTStateCommit = querypb.TransactionState_COMMIT
	// DTStateRollback represents the ROLLBACK state for dt_state.
	DTStateRollback = querypb.TransactionState_ROLLBACK
)
View Source
const (
	NotServing txEngineState = iota
	Transitioning
	AcceptingReadAndWrite
	AcceptingReadOnly
)

The TxEngine can be in any of these states

Variables

View Source
var RegisterFunctions []func(Controller)

RegisterFunctions is a list of all the RegisterFunction that will be called upon Register() on a TabletServer

Functions

This section is empty.

Types

type BinlogWatcher

type BinlogWatcher struct {
	// contains filtered or unexported fields
}

BinlogWatcher is a tabletserver service that watches the replication stream. It will trigger schema reloads if a DDL is encountered.

func NewBinlogWatcher

func NewBinlogWatcher(env tabletenv.Env, vs VStreamer, config *tabletenv.TabletConfig) *BinlogWatcher

NewBinlogWatcher creates a new BinlogWatcher.

func (*BinlogWatcher) Close

func (blw *BinlogWatcher) Close()

Close stops the BinlogWatcher service.

func (*BinlogWatcher) Open

func (blw *BinlogWatcher) Open()

Open starts the BinlogWatcher service.

type Controller

type Controller interface {
	// Register registers this query service with the RPC layer.
	Register()

	// AddStatusHeader adds the header part to the status page.
	AddStatusHeader()

	// AddStatusHeader adds the status part to the status page
	AddStatusPart()

	// Stats returns stats vars.
	Stats() *tabletenv.Stats

	// InitDBConfig sets up the db config vars.
	InitDBConfig(target *querypb.Target, dbConfigs *dbconfigs.DBConfigs, mysqlDaemon mysqlctl.MysqlDaemon) error

	// SetServingType transitions the query service to the required serving type.
	// Returns true if the state of QueryService or the tablet type changed.
	SetServingType(tabletType topodatapb.TabletType, terTimestamp time.Time, serving bool, reason string) error

	// EnterLameduck causes tabletserver to enter the lameduck state.
	EnterLameduck()

	// IsServing returns true if the query service is running
	IsServing() bool

	// IsHealthy returns the health status of the QueryService
	IsHealthy() error

	// ClearQueryPlanCache clears internal query plan cache
	ClearQueryPlanCache()

	// ReloadSchema makes the quey service reload its schema cache
	ReloadSchema(ctx context.Context) error

	// RegisterQueryRuleSource adds a query rule source
	RegisterQueryRuleSource(ruleSource string)

	// RegisterQueryRuleSource removes a query rule source
	UnRegisterQueryRuleSource(ruleSource string)

	// SetQueryRules sets the query rules for this QueryService
	SetQueryRules(ruleSource string, qrs *rules.Rules) error

	// QueryService returns the QueryService object used by this Controller
	QueryService() queryservice.QueryService

	// SchemaEngine returns the SchemaEngine object used by this Controller
	SchemaEngine() *schema.Engine

	// BroadcastHealth sends the current health to all listeners
	BroadcastHealth()

	// TopoServer returns the topo server.
	TopoServer() *topo.Server
}

Controller defines the control interface for TabletServer.

type Properties

type Properties struct {
	EffectiveCaller *vtrpcpb.CallerID
	ImmediateCaller *querypb.VTGateCallerID
	StartTime       time.Time
	Stats           *servenv.TimingsWrapper
}

Properties contains meta information about the connection

type QueryDetail

type QueryDetail struct {
	// contains filtered or unexported fields
}

QueryDetail is a simple wrapper for Query, Context and a killable conn.

func NewQueryDetail

func NewQueryDetail(ctx context.Context, conn killable) *QueryDetail

NewQueryDetail creates a new QueryDetail

type QueryDetailzRow

type QueryDetailzRow struct {
	Type              string
	Query             string
	ContextHTML       safehtml.HTML
	Start             time.Time
	Duration          time.Duration
	ConnID            int64
	State             string
	ShowTerminateLink bool
}

QueryDetailzRow is used for rendering QueryDetail in a template

type QueryEngine

type QueryEngine struct {
	// contains filtered or unexported fields
}

QueryEngine implements the core functionality of tabletserver. It assumes that no requests will be sent to it before Open is called and succeeds. Shutdown is done in the following order:

Close: There should be no more pending queries when this function is called.

func NewQueryEngine

func NewQueryEngine(env tabletenv.Env, se *schema.Engine) *QueryEngine

NewQueryEngine creates a new QueryEngine. This is a singleton class. You must call this only once.

func (*QueryEngine) AddStats

func (qe *QueryEngine) AddStats(planType planbuilder.PlanType, tableName, workload string, queryCount int64, duration, mysqlTime time.Duration, rowsAffected, rowsReturned, errorCount int64, errorCode string)

AddStats adds the given stats for the planName.tableName

func (*QueryEngine) ClearQueryPlanCache

func (qe *QueryEngine) ClearQueryPlanCache()

ClearQueryPlanCache should be called if query plan cache is potentially obsolete

func (*QueryEngine) Close

func (qe *QueryEngine) Close()

Close must be called to shut down QueryEngine. You must ensure that no more queries will be sent before calling Close.

func (*QueryEngine) GetConnSetting added in v0.15.0

func (qe *QueryEngine) GetConnSetting(ctx context.Context, settings []string) (*pools.Setting, error)

GetConnSetting returns system settings for the connection.

func (*QueryEngine) GetMessageStreamPlan

func (qe *QueryEngine) GetMessageStreamPlan(name string) (*TabletPlan, error)

GetMessageStreamPlan builds a plan for Message streaming.

func (*QueryEngine) GetPlan

func (qe *QueryEngine) GetPlan(ctx context.Context, logStats *tabletenv.LogStats, sql string, skipQueryPlanCache bool) (*TabletPlan, error)

GetPlan returns the TabletPlan that for the query. Plans are cached in a cache.LRUCache.

func (*QueryEngine) GetStreamPlan

func (qe *QueryEngine) GetStreamPlan(sql string) (*TabletPlan, error)

GetStreamPlan is similar to GetPlan, but doesn't use the cache and doesn't enforce a limit. It just returns the parsed query.

func (*QueryEngine) IsMySQLReachable

func (qe *QueryEngine) IsMySQLReachable() error

IsMySQLReachable returns an error if it cannot connect to MySQL. This can be called before opening the QueryEngine.

func (*QueryEngine) Open

func (qe *QueryEngine) Open() error

Open must be called before sending requests to QueryEngine.

func (*QueryEngine) QueryPlanCacheCap

func (qe *QueryEngine) QueryPlanCacheCap() int

QueryPlanCacheCap returns the capacity of the query cache.

func (*QueryEngine) QueryPlanCacheLen added in v0.10.0

func (qe *QueryEngine) QueryPlanCacheLen() int

QueryPlanCacheLen returns the length (size in entries) of the query cache

func (*QueryEngine) SetQueryPlanCacheCap

func (qe *QueryEngine) SetQueryPlanCacheCap(size int)

SetQueryPlanCacheCap sets the query plan cache capacity.

type QueryExecutor

type QueryExecutor struct {
	// contains filtered or unexported fields
}

QueryExecutor is used for executing a query request.

func (*QueryExecutor) BeginAgain

func (*QueryExecutor) BeginAgain(ctx context.Context, dc *StatefulConnection) error

BeginAgain commits the existing transaction and begins a new one

func (*QueryExecutor) Execute

func (qre *QueryExecutor) Execute() (reply *sqltypes.Result, err error)

Execute performs a non-streaming query execution.

func (*QueryExecutor) GetSchemaDefinitions added in v0.16.0

func (qre *QueryExecutor) GetSchemaDefinitions(tableType querypb.SchemaTableType, tableNames []string, callback func(schemaRes *querypb.GetSchemaResponse) error) error

func (*QueryExecutor) MessageStream

func (qre *QueryExecutor) MessageStream(callback StreamCallback) error

MessageStream streams messages from a message table.

func (*QueryExecutor) Stream

func (qre *QueryExecutor) Stream(callback StreamCallback) error

Stream performs a streaming query execution.

type QueryList

type QueryList struct {
	// contains filtered or unexported fields
}

QueryList holds a thread safe list of QueryDetails

func NewQueryList

func NewQueryList(name string) *QueryList

NewQueryList creates a new QueryList

func (*QueryList) Add

func (ql *QueryList) Add(qd *QueryDetail)

Add adds a QueryDetail to QueryList

func (*QueryList) AppendQueryzRows added in v0.9.0

func (ql *QueryList) AppendQueryzRows(rows []QueryDetailzRow) []QueryDetailzRow

AppendQueryzRows returns a list of QueryDetailzRow sorted by start time

func (*QueryList) Remove

func (ql *QueryList) Remove(qd *QueryDetail)

Remove removes a QueryDetail from QueryList

func (*QueryList) Terminate

func (ql *QueryList) Terminate(connID int64) bool

Terminate updates the query status and kills the connection

func (*QueryList) TerminateAll

func (ql *QueryList) TerminateAll()

TerminateAll terminates all queries and kills the MySQL connections

type StatefulConnection

type StatefulConnection struct {
	ConnID tx.ConnID
	// contains filtered or unexported fields
}

StatefulConnection is used in the situations where we need a dedicated connection for a vtgate session. This is used for transactions and reserved connections. NOTE: After use, if must be returned either by doing a Unlock() or a Release().

func (*StatefulConnection) ApplySetting added in v0.15.0

func (sc *StatefulConnection) ApplySetting(ctx context.Context, setting *pools.Setting) error

func (*StatefulConnection) CleanTxState

func (sc *StatefulConnection) CleanTxState()

CleanTxState cleans out the current transaction state

func (*StatefulConnection) Close

func (sc *StatefulConnection) Close()

Close closes the underlying connection. When the connection is Unblocked, it will be Released

func (*StatefulConnection) Current added in v0.9.0

func (sc *StatefulConnection) Current() string

Current returns the currently executing query

func (*StatefulConnection) ElapsedTimeout added in v0.15.0

func (sc *StatefulConnection) ElapsedTimeout() bool

func (*StatefulConnection) Exec

func (sc *StatefulConnection) Exec(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)

Exec executes the statement in the dedicated connection

func (*StatefulConnection) FetchNext added in v0.10.0

func (sc *StatefulConnection) FetchNext(ctx context.Context, maxrows int, wantfields bool) (*sqltypes.Result, error)

FetchNext returns the next result set.

func (*StatefulConnection) ID

func (sc *StatefulConnection) ID() int64

ID returns the mysql connection ID

func (*StatefulConnection) IsClosed

func (sc *StatefulConnection) IsClosed() bool

IsClosed returns true when the connection is still operational

func (*StatefulConnection) IsInTransaction

func (sc *StatefulConnection) IsInTransaction() bool

IsInTransaction returns true when the connection has tx state

func (*StatefulConnection) IsTainted

func (sc *StatefulConnection) IsTainted() bool

IsTainted tells us whether this connection is tainted

func (*StatefulConnection) Kill added in v0.9.0

func (sc *StatefulConnection) Kill(reason string, elapsed time.Duration) error

Kill kills the currently executing query and connection

func (*StatefulConnection) LogTransaction

func (sc *StatefulConnection) LogTransaction(reason tx.ReleaseReason)

LogTransaction logs transaction related stats

func (*StatefulConnection) Release

func (sc *StatefulConnection) Release(reason tx.ReleaseReason)

Release is used when the connection will not be used ever again. The underlying dbConn is removed so that this connection cannot be used by mistake.

func (*StatefulConnection) Releasef

func (sc *StatefulConnection) Releasef(reasonFormat string, a ...any)

Releasef is used when the connection will not be used ever again. The underlying dbConn is removed so that this connection cannot be used by mistake.

func (*StatefulConnection) Renew

func (sc *StatefulConnection) Renew() error

Renew the existing connection with new connection id.

func (*StatefulConnection) ReservedID added in v0.9.0

func (sc *StatefulConnection) ReservedID() tx.ConnID

ReservedID returns the identifier for this connection

func (*StatefulConnection) SetTimeout added in v0.15.0

func (sc *StatefulConnection) SetTimeout(timeout time.Duration)

func (*StatefulConnection) Stats

func (sc *StatefulConnection) Stats() *tabletenv.Stats

Stats implements the tx.IStatefulConnection interface

func (*StatefulConnection) String

func (sc *StatefulConnection) String(sanitize bool) string

String returns a printable version of the connection info.

func (*StatefulConnection) Taint

Taint taints the existing connection.

func (*StatefulConnection) TxProperties

func (sc *StatefulConnection) TxProperties() *tx.Properties

TxProperties returns the transactional properties of the connection

func (*StatefulConnection) UnderlyingDBConn

func (sc *StatefulConnection) UnderlyingDBConn() *connpool.DBConn

UnderlyingDBConn returns the underlying database connection

func (*StatefulConnection) Unlock

func (sc *StatefulConnection) Unlock()

Unlock returns the connection to the pool. The connection remains active. This method is idempotent and can be called multiple times

func (*StatefulConnection) UnlockUpdateTime added in v0.8.0

func (sc *StatefulConnection) UnlockUpdateTime()

UnlockUpdateTime returns the connection to the pool. The connection remains active. This method is idempotent and can be called multiple times

type StatefulConnectionPool

type StatefulConnectionPool struct {
	// contains filtered or unexported fields
}

StatefulConnectionPool keeps track of currently and future active connections it's used whenever the session has some state that requires a dedicated connection

func NewStatefulConnPool

func NewStatefulConnPool(env tabletenv.Env) *StatefulConnectionPool

NewStatefulConnPool creates an ActivePool

func (*StatefulConnectionPool) AdjustLastID

func (sf *StatefulConnectionPool) AdjustLastID(id int64)

AdjustLastID adjusts the last transaction id to be at least as large as the input value. This will ensure that there are no dtid collisions with future transactions.

func (*StatefulConnectionPool) Capacity

func (sf *StatefulConnectionPool) Capacity() int

Capacity returns the pool capacity.

func (*StatefulConnectionPool) Close

func (sf *StatefulConnectionPool) Close()

Close closes the TxPool. A closed pool can be reopened.

func (*StatefulConnectionPool) ForAllTxProperties

func (sf *StatefulConnectionPool) ForAllTxProperties(f func(*tx.Properties))

ForAllTxProperties executes a function an every connection that has a not-nil TxProperties

func (*StatefulConnectionPool) GetAndLock

func (sf *StatefulConnectionPool) GetAndLock(id int64, reason string) (*StatefulConnection, error)

GetAndLock locks the connection for use. It accepts a purpose as a string. If it cannot be found, it returns a "not found" error. If in use, it returns a "in use: purpose" error.

func (*StatefulConnectionPool) GetElapsedTimeout added in v0.15.0

func (sf *StatefulConnectionPool) GetElapsedTimeout(purpose string) []*StatefulConnection

GetElapsedTimeout returns sessions older than the timeout stored on the connection. Does not return any connections that are in use. TODO(sougou): deprecate.

func (*StatefulConnectionPool) NewConn

NewConn creates a new StatefulConnection. It will be created from either the normal pool or the found_rows pool, depending on the options provided

func (*StatefulConnectionPool) Open

func (sf *StatefulConnectionPool) Open(appParams, dbaParams, appDebugParams dbconfigs.Connector)

Open makes the TxPool operational. This also starts the transaction killer that will kill long-running transactions.

func (*StatefulConnectionPool) ShutdownAll added in v0.9.0

func (sf *StatefulConnectionPool) ShutdownAll() []*StatefulConnection

ShutdownAll enters the state where all connections are to be killed. It returns all connections that are not in use. They must be rolled back by the caller (TxPool). InUse connections will be killed as they are returned.

func (*StatefulConnectionPool) ShutdownNonTx added in v0.9.0

func (sf *StatefulConnectionPool) ShutdownNonTx()

ShutdownNonTx enters the state where all non-transactional connections are killed. InUse connections will be killed as they are returned.

func (*StatefulConnectionPool) WaitForEmpty

func (sf *StatefulConnectionPool) WaitForEmpty()

WaitForEmpty returns as soon as the pool becomes empty

type StreamCallback added in v0.11.0

type StreamCallback func(result *sqltypes.Result) error

StreamCallback is a function that is called with every Result object from a streaming query

type StreamConsolidator added in v0.11.0

type StreamConsolidator struct {
	// contains filtered or unexported fields
}

StreamConsolidator is a data structure capable of merging several identical streaming queries so only one query is executed in MySQL and its response is fanned out to all the clients simultaneously.

func NewStreamConsolidator added in v0.11.0

func NewStreamConsolidator(maxMemoryTotal, maxMemoryQuery int64, cleanup StreamCallback) *StreamConsolidator

NewStreamConsolidator allocates a stream consolidator. The consolidator will use up to maxMemoryTotal bytes in order to allow simultaneous queries to "catch up" to each other. Each individual stream will only use up to maxMemoryQuery bytes of memory as a history buffer to catch up.

func (*StreamConsolidator) Consolidate added in v0.11.0

func (sc *StreamConsolidator) Consolidate(logStats *tabletenv.LogStats, sql string, callback StreamCallback, leaderCallback func(StreamCallback) error) error

Consolidate wraps the execution of a streaming query so that any other queries being executed simultaneously will wait for the results of the original query, instead of being executed from scratch in MySQL. Query consolidation is based by comparing the resulting `sql` string, which should not contain comments in it. The original `callback` that will yield results to the client must be passed as `callback`. A `leaderCallback` must also be supplied: this function must perform the actual query in the upstream MySQL server, yielding results into the modified callback that it receives as an argument.

func (*StreamConsolidator) SetBlocking added in v0.11.0

func (sc *StreamConsolidator) SetBlocking(block bool)

SetBlocking sets whether fanning out should block to wait for slower clients to catch up, or should immediately disconnect clients that are taking too long to process the consolidated stream. By default, blocking is only enabled when running with the race detector.

type TabletPlan

type TabletPlan struct {
	*planbuilder.Plan
	Original   string
	Rules      *rules.Rules
	Authorized []*tableacl.ACLResult

	QueryCount   uint64
	Time         uint64
	MysqlTime    uint64
	RowsAffected uint64
	RowsReturned uint64
	ErrorCount   uint64
}

TabletPlan wraps the planbuilder's exec plan to enforce additional rules and track stats.

func (*TabletPlan) AddStats

func (ep *TabletPlan) AddStats(queryCount uint64, duration, mysqlTime time.Duration, rowsAffected, rowsReturned, errorCount uint64)

AddStats updates the stats for the current TabletPlan.

func (*TabletPlan) CachedSize added in v0.10.0

func (cached *TabletPlan) CachedSize(alloc bool) int64

func (*TabletPlan) IsValid added in v0.15.0

func (ep *TabletPlan) IsValid(hasReservedCon, hasSysSettings bool) error

func (*TabletPlan) Stats

func (ep *TabletPlan) Stats() (queryCount uint64, duration, mysqlTime time.Duration, rowsAffected, rowsReturned, errorCount uint64)

Stats returns the current stats of TabletPlan.

type TabletServer

type TabletServer struct {
	QueryTimeout     atomic.Int64
	TerseErrors      bool
	TruncateErrorLen int
	// contains filtered or unexported fields
}

TabletServer implements the RPC interface for the query service. TabletServer is initialized in the following sequence: NewTabletServer->InitDBConfig->SetServingType. Subcomponents of TabletServer are initialized using one of the following sequences: New->InitDBConfig->Init->Open, or New->InitDBConfig->Open. Essentially, InitDBConfig is a continuation of New. However, the db config is not initially available. For this reason, the initialization is done in two phases. Some subcomponents have Init functions. Such functions usually perform one-time initializations and must be idempotent. Open and Close can be called repeatedly during the lifetime of a subcomponent. These should also be idempotent.

func NewServer

func NewServer(name string, topoServer *topo.Server, alias *topodatapb.TabletAlias) *TabletServer

NewServer creates a new TabletServer based on the command line flags.

func NewTabletServer

func NewTabletServer(name string, config *tabletenv.TabletConfig, topoServer *topo.Server, alias *topodatapb.TabletAlias) *TabletServer

NewTabletServer creates an instance of TabletServer. Only the first instance of TabletServer will expose its state variables.

func (*TabletServer) AddStatusHeader

func (tsv *TabletServer) AddStatusHeader()

AddStatusHeader registers a standlone header for the status page.

func (*TabletServer) AddStatusPart

func (tsv *TabletServer) AddStatusPart()

AddStatusPart registers the status part for the status page.

func (*TabletServer) Begin

func (tsv *TabletServer) Begin(ctx context.Context, target *querypb.Target, options *querypb.ExecuteOptions) (state queryservice.TransactionState, err error)

Begin starts a new transaction. This is allowed only if the state is StateServing.

func (*TabletServer) BeginExecute

func (tsv *TabletServer) BeginExecute(ctx context.Context, target *querypb.Target, preQueries []string, sql string, bindVariables map[string]*querypb.BindVariable, reservedID int64, options *querypb.ExecuteOptions) (queryservice.TransactionState, *sqltypes.Result, error)

BeginExecute combines Begin and Execute.

func (*TabletServer) BeginStreamExecute added in v0.13.0

func (tsv *TabletServer) BeginStreamExecute(
	ctx context.Context,
	target *querypb.Target,
	preQueries []string,
	sql string,
	bindVariables map[string]*querypb.BindVariable,
	reservedID int64,
	options *querypb.ExecuteOptions,
	callback func(*sqltypes.Result) error,
) (queryservice.TransactionState, error)

BeginStreamExecute combines Begin and StreamExecute.

func (*TabletServer) BroadcastHealth

func (tsv *TabletServer) BroadcastHealth()

BroadcastHealth will broadcast the current health to all listeners

func (*TabletServer) CheckMySQL

func (tsv *TabletServer) CheckMySQL()

CheckMySQL initiates a check to see if MySQL is reachable. If not, it shuts down the query service. The check is rate-limited to no more than once per second. The function satisfies tabletenv.Env.

func (*TabletServer) ClearQueryPlanCache

func (tsv *TabletServer) ClearQueryPlanCache()

ClearQueryPlanCache clears internal query plan cache

func (*TabletServer) Close

func (tsv *TabletServer) Close(ctx context.Context) error

Close is a no-op.

func (*TabletServer) Commit

func (tsv *TabletServer) Commit(ctx context.Context, target *querypb.Target, transactionID int64) (newReservedID int64, err error)

Commit commits the specified transaction.

func (*TabletServer) CommitPrepared

func (tsv *TabletServer) CommitPrepared(ctx context.Context, target *querypb.Target, dtid string) (err error)

CommitPrepared commits the prepared transaction.

func (*TabletServer) ConcludeTransaction

func (tsv *TabletServer) ConcludeTransaction(ctx context.Context, target *querypb.Target, dtid string) (err error)

ConcludeTransaction deletes the 2pc transaction metadata essentially resolving it.

func (*TabletServer) Config

func (tsv *TabletServer) Config() *tabletenv.TabletConfig

Config satisfies tabletenv.Env.

func (*TabletServer) ConsolidatorMode added in v0.9.0

func (tsv *TabletServer) ConsolidatorMode() string

ConsolidatorMode returns the consolidator mode.

func (*TabletServer) CreateTransaction

func (tsv *TabletServer) CreateTransaction(ctx context.Context, target *querypb.Target, dtid string, participants []*querypb.Target) (err error)

CreateTransaction creates the metadata for a 2PC transaction.

func (*TabletServer) EnableHeartbeat added in v0.8.0

func (tsv *TabletServer) EnableHeartbeat(enabled bool)

EnableHeartbeat forces heartbeat to be on or off. Only to be used for testing.

func (*TabletServer) EnableHistorian

func (tsv *TabletServer) EnableHistorian(enabled bool)

EnableHistorian forces historian to be on or off. Only to be used for testing.

func (*TabletServer) EnableThrottler added in v0.10.0

func (tsv *TabletServer) EnableThrottler(enabled bool)

EnableThrottler forces throttler to be on or off. When throttler is off, it responds to all check requests with HTTP 200 OK Only to be used for testing.

func (*TabletServer) EnterLameduck

func (tsv *TabletServer) EnterLameduck()

EnterLameduck causes tabletserver to enter the lameduck state. This state causes health checks to fail, but the behavior of tabletserver otherwise remains the same. Any subsequent calls to SetServingType will cause the tabletserver to exit this mode.

func (*TabletServer) Execute

func (tsv *TabletServer) Execute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, transactionID, reservedID int64, options *querypb.ExecuteOptions) (result *sqltypes.Result, err error)

Execute executes the query and returns the result as response.

func (*TabletServer) ExitLameduck

func (tsv *TabletServer) ExitLameduck()

ExitLameduck causes the tabletserver to exit the lameduck mode.

func (*TabletServer) Exporter

func (tsv *TabletServer) Exporter() *servenv.Exporter

Exporter satisfies tabletenv.Env.

func (*TabletServer) GetSchema added in v0.16.0

func (tsv *TabletServer) GetSchema(ctx context.Context, target *querypb.Target, tableType querypb.SchemaTableType, tableNames []string, callback func(schemaRes *querypb.GetSchemaResponse) error) (err error)

GetSchema returns table definitions for the specified tables.

func (*TabletServer) HandlePanic

func (tsv *TabletServer) HandlePanic(err *error)

HandlePanic is part of the queryservice.QueryService interface

func (*TabletServer) InitACL

func (tsv *TabletServer) InitACL(tableACLConfigFile string, enforceTableACLConfig bool, reloadACLConfigFileInterval time.Duration)

InitACL loads the table ACL and sets up a SIGHUP handler for reloading it.

func (*TabletServer) InitDBConfig

func (tsv *TabletServer) InitDBConfig(target *querypb.Target, dbcfgs *dbconfigs.DBConfigs, mysqld mysqlctl.MysqlDaemon) error

InitDBConfig initializes the db config variables for TabletServer. You must call this function to complete the creation of TabletServer.

func (*TabletServer) IsHealthy

func (tsv *TabletServer) IsHealthy() error

IsHealthy returns nil for non-serving types or if the query service is healthy (able to connect to the database and serving traffic), or an error explaining the unhealthiness otherwise.

func (*TabletServer) IsServing

func (tsv *TabletServer) IsServing() bool

IsServing returns true if TabletServer is in SERVING state.

func (*TabletServer) LagThrottler added in v0.8.0

func (tsv *TabletServer) LagThrottler() *throttle.Throttler

LagThrottler returns the throttle.Throttler part of TabletServer.

func (*TabletServer) LogError

func (tsv *TabletServer) LogError()

LogError satisfies tabletenv.Env.

func (*TabletServer) MaxResultSize

func (tsv *TabletServer) MaxResultSize() int

MaxResultSize returns the max result size.

func (*TabletServer) MessageAck

func (tsv *TabletServer) MessageAck(ctx context.Context, target *querypb.Target, name string, ids []*querypb.Value) (count int64, err error)

MessageAck acks the list of messages for a given message table. It returns the number of messages successfully acked.

func (*TabletServer) MessageStream

func (tsv *TabletServer) MessageStream(ctx context.Context, target *querypb.Target, name string, callback func(*sqltypes.Result) error) (err error)

MessageStream streams messages from the requested table.

func (*TabletServer) PoolSize

func (tsv *TabletServer) PoolSize() int

PoolSize returns the pool size.

func (*TabletServer) PostponeMessages

func (tsv *TabletServer) PostponeMessages(ctx context.Context, target *querypb.Target, querygen messager.QueryGenerator, ids []string) (count int64, err error)

PostponeMessages postpones the list of messages for a given message table. It returns the number of messages successfully postponed.

func (*TabletServer) Prepare

func (tsv *TabletServer) Prepare(ctx context.Context, target *querypb.Target, transactionID int64, dtid string) (err error)

Prepare prepares the specified transaction.

func (*TabletServer) PurgeMessages

func (tsv *TabletServer) PurgeMessages(ctx context.Context, target *querypb.Target, querygen messager.QueryGenerator, timeCutoff int64) (count int64, err error)

PurgeMessages purges messages older than specified time in Unix Nanoseconds. It purges at most 500 messages. It returns the number of messages successfully purged.

func (*TabletServer) QueryPlanCacheCap

func (tsv *TabletServer) QueryPlanCacheCap() int

QueryPlanCacheCap returns the plan cache capacity

func (*TabletServer) QueryPlanCacheLen added in v0.10.0

func (tsv *TabletServer) QueryPlanCacheLen() int

QueryPlanCacheLen returns the plan cache length

func (*TabletServer) QueryPlanCacheWait added in v0.10.0

func (tsv *TabletServer) QueryPlanCacheWait()

QueryPlanCacheWait waits until the query plan cache has processed all recent queries

func (*TabletServer) QueryService

func (tsv *TabletServer) QueryService() queryservice.QueryService

QueryService returns the QueryService part of TabletServer.

func (*TabletServer) ReadTransaction

func (tsv *TabletServer) ReadTransaction(ctx context.Context, target *querypb.Target, dtid string) (metadata *querypb.TransactionMetadata, err error)

ReadTransaction returns the metadata for the specified dtid.

func (*TabletServer) Register

func (tsv *TabletServer) Register()

Register prepares TabletServer for serving by calling all the registrations functions.

func (*TabletServer) RegisterQueryRuleSource

func (tsv *TabletServer) RegisterQueryRuleSource(ruleSource string)

RegisterQueryRuleSource registers ruleSource for setting query rules.

func (*TabletServer) Release

func (tsv *TabletServer) Release(ctx context.Context, target *querypb.Target, transactionID, reservedID int64) error

Release implements the QueryService interface

func (*TabletServer) ReloadSchema

func (tsv *TabletServer) ReloadSchema(ctx context.Context) error

ReloadSchema reloads the schema.

func (*TabletServer) ReserveBeginExecute

func (tsv *TabletServer) ReserveBeginExecute(ctx context.Context, target *querypb.Target, preQueries []string, postBeginQueries []string, sql string, bindVariables map[string]*querypb.BindVariable, options *querypb.ExecuteOptions) (state queryservice.ReservedTransactionState, result *sqltypes.Result, err error)

ReserveBeginExecute implements the QueryService interface

func (*TabletServer) ReserveBeginStreamExecute added in v0.13.0

func (tsv *TabletServer) ReserveBeginStreamExecute(
	ctx context.Context,
	target *querypb.Target,
	preQueries []string,
	postBeginQueries []string,
	sql string,
	bindVariables map[string]*querypb.BindVariable,
	options *querypb.ExecuteOptions,
	callback func(*sqltypes.Result) error,
) (state queryservice.ReservedTransactionState, err error)

ReserveBeginStreamExecute combines Begin and StreamExecute.

func (*TabletServer) ReserveExecute

func (tsv *TabletServer) ReserveExecute(ctx context.Context, target *querypb.Target, preQueries []string, sql string, bindVariables map[string]*querypb.BindVariable, transactionID int64, options *querypb.ExecuteOptions) (state queryservice.ReservedState, result *sqltypes.Result, err error)

ReserveExecute implements the QueryService interface

func (*TabletServer) ReserveStreamExecute added in v0.13.0

func (tsv *TabletServer) ReserveStreamExecute(
	ctx context.Context,
	target *querypb.Target,
	preQueries []string,
	sql string,
	bindVariables map[string]*querypb.BindVariable,
	transactionID int64,
	options *querypb.ExecuteOptions,
	callback func(*sqltypes.Result) error,
) (state queryservice.ReservedState, err error)

ReserveStreamExecute combines Begin and StreamExecute.

func (*TabletServer) Rollback

func (tsv *TabletServer) Rollback(ctx context.Context, target *querypb.Target, transactionID int64) (newReservedID int64, err error)

Rollback rollsback the specified transaction.

func (*TabletServer) RollbackPrepared

func (tsv *TabletServer) RollbackPrepared(ctx context.Context, target *querypb.Target, dtid string, originalID int64) (err error)

RollbackPrepared commits the prepared transaction.

func (*TabletServer) SchemaEngine

func (tsv *TabletServer) SchemaEngine() *schema.Engine

SchemaEngine returns the SchemaEngine part of TabletServer.

func (*TabletServer) SetConsolidatorMode

func (tsv *TabletServer) SetConsolidatorMode(mode string)

SetConsolidatorMode sets the consolidator mode.

func (*TabletServer) SetMaxResultSize

func (tsv *TabletServer) SetMaxResultSize(val int)

SetMaxResultSize changes the max result size to the specified value.

func (*TabletServer) SetPassthroughDMLs

func (tsv *TabletServer) SetPassthroughDMLs(val bool)

SetPassthroughDMLs changes the setting to pass through all DMLs It should only be used for testing

func (*TabletServer) SetPoolSize

func (tsv *TabletServer) SetPoolSize(val int)

SetPoolSize changes the pool size to the specified value.

func (*TabletServer) SetQueryPlanCacheCap

func (tsv *TabletServer) SetQueryPlanCacheCap(val int)

SetQueryPlanCacheCap changes the plan cache capacity to the specified value.

func (*TabletServer) SetQueryRules

func (tsv *TabletServer) SetQueryRules(ruleSource string, qrs *rules.Rules) error

SetQueryRules sets the query rules for a registered ruleSource.

func (*TabletServer) SetRollback

func (tsv *TabletServer) SetRollback(ctx context.Context, target *querypb.Target, dtid string, transactionID int64) (err error)

SetRollback transitions the 2pc transaction to the Rollback state. If a transaction id is provided, that transaction is also rolled back.

func (*TabletServer) SetServingType

func (tsv *TabletServer) SetServingType(tabletType topodatapb.TabletType, terTimestamp time.Time, serving bool, reason string) error

SetServingType changes the serving type of the tabletserver. It starts or stops internal services as deemed necessary. Returns true if the state of QueryService or the tablet type changed.

func (*TabletServer) SetStreamConsolidationBlocking added in v0.11.0

func (tsv *TabletServer) SetStreamConsolidationBlocking(block bool)

SetStreamConsolidationBlocking sets whether the stream consolidator should wait for slow clients

func (*TabletServer) SetStreamPoolSize

func (tsv *TabletServer) SetStreamPoolSize(val int)

SetStreamPoolSize changes the pool size to the specified value.

func (*TabletServer) SetThrottleMetricThreshold added in v0.11.0

func (tsv *TabletServer) SetThrottleMetricThreshold(val float64)

SetThrottleMetricThreshold changes the throttler metric threshold

func (*TabletServer) SetTracking

func (tsv *TabletServer) SetTracking(enabled bool)

SetTracking forces tracking to be on or off. Only to be used for testing.

func (*TabletServer) SetTxPoolSize

func (tsv *TabletServer) SetTxPoolSize(val int)

SetTxPoolSize changes the tx pool size to the specified value.

func (*TabletServer) SetWarnResultSize

func (tsv *TabletServer) SetWarnResultSize(val int)

SetWarnResultSize changes the warn result size to the specified value.

func (*TabletServer) StartCommit

func (tsv *TabletServer) StartCommit(ctx context.Context, target *querypb.Target, transactionID int64, dtid string) (err error)

StartCommit atomically commits the transaction along with the decision to commit the associated 2pc transaction.

func (*TabletServer) StartService

func (tsv *TabletServer) StartService(target *querypb.Target, dbcfgs *dbconfigs.DBConfigs, mysqld mysqlctl.MysqlDaemon) error

StartService is a convenience function for InitDBConfig->SetServingType with serving=true.

func (*TabletServer) Stats

func (tsv *TabletServer) Stats() *tabletenv.Stats

Stats satisfies tabletenv.Env.

func (*TabletServer) StopService

func (tsv *TabletServer) StopService()

StopService shuts down the tabletserver to the uninitialized state. It first transitions to StateShuttingDown, then waits for active services to shut down. Then it shuts down the rest. This function should be called before process termination, or if MySQL is unreachable. Under normal circumstances, SetServingType should be called.

func (*TabletServer) StreamExecute

func (tsv *TabletServer) StreamExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, transactionID int64, reservedID int64, options *querypb.ExecuteOptions, callback func(*sqltypes.Result) error) (err error)

StreamExecute executes the query and streams the result. The first QueryResult will have Fields set (and Rows nil). The subsequent QueryResult will have Rows set (and Fields nil).

func (*TabletServer) StreamHealth

func (tsv *TabletServer) StreamHealth(ctx context.Context, callback func(*querypb.StreamHealthResponse) error) error

StreamHealth streams the health status to callback.

func (*TabletServer) StreamPoolSize

func (tsv *TabletServer) StreamPoolSize() int

StreamPoolSize returns the pool size.

func (*TabletServer) TableGC added in v0.8.0

func (tsv *TabletServer) TableGC() *gc.TableGC

TableGC returns the tableDropper part of TabletServer.

func (*TabletServer) ThrottleMetricThreshold added in v0.11.0

func (tsv *TabletServer) ThrottleMetricThreshold() float64

ThrottleMetricThreshold returns the throttler metric threshold

func (*TabletServer) TopoServer

func (tsv *TabletServer) TopoServer() *topo.Server

TopoServer returns the topo server.

func (*TabletServer) TwoPCEngineWait added in v0.11.0

func (tsv *TabletServer) TwoPCEngineWait()

TwoPCEngineWait waits until the TwoPC engine has been opened, and the redo read

func (*TabletServer) TxPoolSize

func (tsv *TabletServer) TxPoolSize() int

TxPoolSize returns the tx pool size.

func (*TabletServer) UnRegisterQueryRuleSource

func (tsv *TabletServer) UnRegisterQueryRuleSource(ruleSource string)

UnRegisterQueryRuleSource unregisters ruleSource from query rules.

func (*TabletServer) VStream

func (tsv *TabletServer) VStream(ctx context.Context, request *binlogdatapb.VStreamRequest, send func([]*binlogdatapb.VEvent) error) error

VStream streams VReplication events.

func (*TabletServer) VStreamResults

func (tsv *TabletServer) VStreamResults(ctx context.Context, target *querypb.Target, query string, send func(*binlogdatapb.VStreamResultsResponse) error) error

VStreamResults streams rows from the specified starting point.

func (*TabletServer) VStreamRows

VStreamRows streams rows from the specified starting point.

func (*TabletServer) WaitForSchemaReset added in v0.10.0

func (tsv *TabletServer) WaitForSchemaReset(timeout time.Duration)

WaitForSchemaReset blocks the TabletServer until there's been at least `timeout` duration without any schema changes. This is useful for tests that need to wait for all the currently existing schema changes to finish being applied.

func (*TabletServer) WarnResultSize

func (tsv *TabletServer) WarnResultSize() int

WarnResultSize returns the warn result size.

type TwoPC

type TwoPC struct {
	// contains filtered or unexported fields
}

TwoPC performs 2PC metadata management (MM) functions.

func NewTwoPC

func NewTwoPC(readPool *connpool.Pool) *TwoPC

NewTwoPC creates a TwoPC variable.

func (*TwoPC) Close

func (tpc *TwoPC) Close()

Close closes the TwoPC service.

func (*TwoPC) CountUnresolvedRedo

func (tpc *TwoPC) CountUnresolvedRedo(ctx context.Context, unresolvedTime time.Time) (int64, error)

CountUnresolvedRedo returns the number of prepared transactions that are still unresolved.

func (*TwoPC) CreateTransaction

func (tpc *TwoPC) CreateTransaction(ctx context.Context, conn *StatefulConnection, dtid string, participants []*querypb.Target) error

CreateTransaction saves the metadata of a 2pc transaction as Prepared.

func (*TwoPC) DeleteRedo

func (tpc *TwoPC) DeleteRedo(ctx context.Context, conn *StatefulConnection, dtid string) error

DeleteRedo deletes the redo log for the dtid.

func (*TwoPC) DeleteTransaction

func (tpc *TwoPC) DeleteTransaction(ctx context.Context, conn *StatefulConnection, dtid string) error

DeleteTransaction deletes the metadata for the specified transaction.

func (*TwoPC) Open

func (tpc *TwoPC) Open(dbconfigs *dbconfigs.DBConfigs) error

Open starts the TwoPC service.

func (*TwoPC) ReadAbandoned

func (tpc *TwoPC) ReadAbandoned(ctx context.Context, abandonTime time.Time) (map[string]time.Time, error)

ReadAbandoned returns the list of abandoned transactions and their associated start time.

func (*TwoPC) ReadAllRedo

func (tpc *TwoPC) ReadAllRedo(ctx context.Context) (prepared, failed []*tx.PreparedTx, err error)

ReadAllRedo returns all the prepared transactions from the redo logs.

func (*TwoPC) ReadAllTransactions

func (tpc *TwoPC) ReadAllTransactions(ctx context.Context) ([]*tx.DistributedTx, error)

ReadAllTransactions returns info about all distributed transactions.

func (*TwoPC) ReadTransaction

func (tpc *TwoPC) ReadTransaction(ctx context.Context, dtid string) (*querypb.TransactionMetadata, error)

ReadTransaction returns the metadata for the transaction.

func (*TwoPC) SaveRedo

func (tpc *TwoPC) SaveRedo(ctx context.Context, conn *StatefulConnection, dtid string, queries []string) error

SaveRedo saves the statements in the redo log using the supplied connection.

func (*TwoPC) Transition

func (tpc *TwoPC) Transition(ctx context.Context, conn *StatefulConnection, dtid string, state querypb.TransactionState) error

Transition performs a transition from Prepare to the specified state. If the transaction is not a in the Prepare state, an error is returned.

func (*TwoPC) UpdateRedo

func (tpc *TwoPC) UpdateRedo(ctx context.Context, conn *StatefulConnection, dtid string, state int) error

UpdateRedo changes the state of the redo log for the dtid.

type TxEngine

type TxEngine struct {
	// contains filtered or unexported fields
}

TxEngine is responsible for handling the tx-pool and keeping read-write, read-only or not-serving states. It will start and shut down the underlying tx-pool as required.

func NewTxEngine

func NewTxEngine(env tabletenv.Env) *TxEngine

NewTxEngine creates a new TxEngine.

func (*TxEngine) AcceptReadOnly

func (te *TxEngine) AcceptReadOnly()

AcceptReadOnly transitions to read-only mode. If current state is read-write, then we wait for shutdown and then transition.

func (*TxEngine) AcceptReadWrite

func (te *TxEngine) AcceptReadWrite()

AcceptReadWrite will start accepting all transactions. If transitioning from RO mode, transactions are rolled back before accepting new transactions. This is to allow for 2PC state to be correctly initialized.

func (*TxEngine) Begin

func (te *TxEngine) Begin(ctx context.Context, savepointQueries []string, reservedID int64, setting *pools.Setting, options *querypb.ExecuteOptions) (int64, string, string, error)

Begin begins a transaction, and returns the associated transaction id and the statement(s) used to execute the begin (if any).

Subsequent statements can access the connection through the transaction id.

func (*TxEngine) Close

func (te *TxEngine) Close()

Close will disregard common rules for when to kill transactions and wait forever for transactions to wrap up

func (*TxEngine) Commit

func (te *TxEngine) Commit(ctx context.Context, transactionID int64) (int64, string, error)

Commit commits the specified transaction and renews connection id if one exists.

func (*TxEngine) Release

func (te *TxEngine) Release(connID int64) error

Release closes the underlying connection.

func (*TxEngine) Reserve

func (te *TxEngine) Reserve(ctx context.Context, options *querypb.ExecuteOptions, txID int64, preQueries []string) (int64, error)

Reserve creates a reserved connection and returns the id to it

func (*TxEngine) ReserveBegin

func (te *TxEngine) ReserveBegin(ctx context.Context, options *querypb.ExecuteOptions, preQueries []string, savepointQueries []string) (int64, string, error)

ReserveBegin creates a reserved connection, and in it opens a transaction

func (*TxEngine) Rollback

func (te *TxEngine) Rollback(ctx context.Context, transactionID int64) (int64, error)

Rollback rolls back the specified transaction.

type TxExecutor

type TxExecutor struct {
	// contains filtered or unexported fields
}

TxExecutor is used for executing a transactional request. TODO: merge this with tx_engine

func (*TxExecutor) CommitPrepared

func (txe *TxExecutor) CommitPrepared(dtid string) error

CommitPrepared commits a prepared transaction. If the operation fails, an error counter is incremented and the transaction is marked as failed in the redo log.

func (*TxExecutor) ConcludeTransaction

func (txe *TxExecutor) ConcludeTransaction(dtid string) error

ConcludeTransaction deletes the 2pc transaction metadata essentially resolving it.

func (*TxExecutor) CreateTransaction

func (txe *TxExecutor) CreateTransaction(dtid string, participants []*querypb.Target) error

CreateTransaction creates the metadata for a 2PC transaction.

func (*TxExecutor) Prepare

func (txe *TxExecutor) Prepare(transactionID int64, dtid string) error

Prepare performs a prepare on a connection including the redo log work. If there is any failure, an error is returned. No cleanup is performed. A subsequent call to RollbackPrepared, which is required by the 2PC protocol, will perform all the cleanup.

func (*TxExecutor) ReadTransaction

func (txe *TxExecutor) ReadTransaction(dtid string) (*querypb.TransactionMetadata, error)

ReadTransaction returns the metadata for the sepcified dtid.

func (*TxExecutor) ReadTwopcInflight

func (txe *TxExecutor) ReadTwopcInflight() (distributed []*tx.DistributedTx, prepared, failed []*tx.PreparedTx, err error)

ReadTwopcInflight returns info about all in-flight 2pc transactions.

func (*TxExecutor) RollbackPrepared

func (txe *TxExecutor) RollbackPrepared(dtid string, originalID int64) error

RollbackPrepared rolls back a prepared transaction. This function handles the case of an incomplete prepare.

If the prepare completely failed, it will just rollback the original transaction identified by originalID.

If the connection was moved to the prepared pool, but redo log creation failed, then it will rollback that transaction and return the conn to the txPool.

If prepare was fully successful, it will also delete the redo log. If the redo log deletion fails, it returns an error indicating that a retry is needed.

In recovery mode, the original transaction id will not be available. If so, it must be set to 0, and the function will not attempt that step. If the original transaction is still alive, the transaction killer will be the one to eventually roll it back.

func (*TxExecutor) SetRollback

func (txe *TxExecutor) SetRollback(dtid string, transactionID int64) error

SetRollback transitions the 2pc transaction to the Rollback state. If a transaction id is provided, that transaction is also rolled back.

func (*TxExecutor) StartCommit

func (txe *TxExecutor) StartCommit(transactionID int64, dtid string) error

StartCommit atomically commits the transaction along with the decision to commit the associated 2pc transaction.

type TxPool

type TxPool struct {
	// contains filtered or unexported fields
}

TxPool does a lot of the transactional operations on StatefulConnections. It does not, with two exceptions, concern itself with a connections life cycle. The two exceptions are Begin, which creates a new StatefulConnection, and RollbackAndRelease, which does a Release after doing the rollback.

func NewTxPool

func NewTxPool(env tabletenv.Env, limiter txlimiter.TxLimiter) *TxPool

NewTxPool creates a new TxPool. It's not operational until it's Open'd.

func (*TxPool) AdjustLastID

func (tp *TxPool) AdjustLastID(id int64)

AdjustLastID adjusts the last transaction id to be at least as large as the input value. This will ensure that there are no dtid collisions with future transactions.

func (*TxPool) Begin

func (tp *TxPool) Begin(ctx context.Context, options *querypb.ExecuteOptions, readOnly bool, reservedID int64, savepointQueries []string, setting *pools.Setting) (*StatefulConnection, string, string, error)

Begin begins a transaction, and returns the associated connection and the statements (if any) executed to initiate the transaction. In autocommit mode the statement will be "". The connection returned is locked for the callee and its responsibility is to unlock the connection.

func (*TxPool) Close

func (tp *TxPool) Close()

Close closes the TxPool. A closed pool can be reopened.

func (*TxPool) Commit

func (tp *TxPool) Commit(ctx context.Context, txConn *StatefulConnection) (string, error)

Commit commits the transaction on the connection.

func (*TxPool) GetAndLock

func (tp *TxPool) GetAndLock(connID tx.ConnID, reason string) (*StatefulConnection, error)

GetAndLock fetches the connection associated to the connID and blocks it from concurrent use You must call Unlock on TxConnection once done.

func (*TxPool) LogActive

func (tp *TxPool) LogActive()

LogActive causes all existing transactions to be logged when they complete. The logging is throttled to no more than once every txLogInterval.

func (*TxPool) NewTxProps

func (tp *TxPool) NewTxProps(immediateCaller *querypb.VTGateCallerID, effectiveCaller *vtrpcpb.CallerID, autocommit bool) *tx.Properties

NewTxProps creates a new TxProperties struct

func (*TxPool) Open

func (tp *TxPool) Open(appParams, dbaParams, appDebugParams dbconfigs.Connector)

Open makes the TxPool operational. This also starts the transaction killer that will kill long-running transactions.

func (*TxPool) Rollback

func (tp *TxPool) Rollback(ctx context.Context, txConn *StatefulConnection) error

Rollback rolls back the transaction on the specified connection.

func (*TxPool) RollbackAndRelease

func (tp *TxPool) RollbackAndRelease(ctx context.Context, txConn *StatefulConnection)

RollbackAndRelease rolls back the transaction on the specified connection, and releases the connection when done

func (*TxPool) Shutdown added in v0.9.0

func (tp *TxPool) Shutdown(ctx context.Context)

Shutdown immediately rolls back all transactions that are not in use. In-use connections will be closed when they are unlocked (not in use).

func (*TxPool) WaitForEmpty

func (tp *TxPool) WaitForEmpty()

WaitForEmpty waits until all active transactions are completed.

type TxPreparedPool

type TxPreparedPool struct {
	// contains filtered or unexported fields
}

TxPreparedPool manages connections for prepared transactions. The Prepare functionality and associated orchestration is done by TxPool.

func NewTxPreparedPool

func NewTxPreparedPool(capacity int) *TxPreparedPool

NewTxPreparedPool creates a new TxPreparedPool.

func (*TxPreparedPool) FetchAll

func (pp *TxPreparedPool) FetchAll() []*StatefulConnection

FetchAll removes all connections and returns them as a list. It also forgets all reserved dtids.

func (*TxPreparedPool) FetchForCommit

func (pp *TxPreparedPool) FetchForCommit(dtid string) (*StatefulConnection, error)

FetchForCommit returns the connection for commit. Before returning, it remembers the dtid in its reserved list as "committing". If the dtid is already in the reserved list, it returns an error. If the commit is successful, the dtid can be removed from the reserved list by calling Forget. If the commit failed, SetFailed must be called. This will inform future retries that the previous commit failed.

func (*TxPreparedPool) FetchForRollback

func (pp *TxPreparedPool) FetchForRollback(dtid string) *StatefulConnection

FetchForRollback returns the connection and removes it from the pool. If the connection is not found, it returns nil. If the dtid is in the reserved list, it means that an operator is trying to resolve a previously failed commit. So, it removes the entry and returns nil.

func (*TxPreparedPool) Forget

func (pp *TxPreparedPool) Forget(dtid string)

Forget removes the dtid from the reserved list.

func (*TxPreparedPool) Put

func (pp *TxPreparedPool) Put(c *StatefulConnection, dtid string) error

Put adds the connection to the pool. It returns an error if the pool is full or on duplicate key.

func (*TxPreparedPool) SetFailed

func (pp *TxPreparedPool) SetFailed(dtid string)

SetFailed marks the reserved dtid as failed. If there was no previous entry, one is created.

type VStreamer

type VStreamer interface {
	Stream(ctx context.Context, startPos string, tablePKs []*binlogdatapb.TableLastPK, filter *binlogdatapb.Filter, throttlerApp throttlerapp.Name, send func([]*binlogdatapb.VEvent) error) error
}

VStreamer defines the functions of VStreamer that the BinlogWatcher needs.

Directories

Path Synopsis
schematest
Package schematest provides support for testing packages that depend on schema
Package schematest provides support for testing packages that depend on schema
Package tabletenv maintains environment variables and types that are common for all packages of tabletserver.
Package tabletenv maintains environment variables and types that are common for all packages of tabletserver.
Package txserializer provides the vttablet hot row protection.
Package txserializer provides the vttablet hot row protection.
testenv
Package testenv supplies test functions for testing vstreamer.
Package testenv supplies test functions for testing vstreamer.

Jump to

Keyboard shortcuts

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