Documentation ¶
Index ¶
- Constants
- Variables
- type Controller
- type DistributedTx
- type PreparedTx
- type QueryDetail
- type QueryDetailzRow
- type QueryEngine
- func (qe *QueryEngine) AddStats(planName, tableName string, queryCount int64, ...)
- func (qe *QueryEngine) ClearQueryPlanCache()
- func (qe *QueryEngine) Close()
- func (qe *QueryEngine) GetMessageStreamPlan(name string) (*TabletPlan, error)
- func (qe *QueryEngine) GetPlan(ctx context.Context, logStats *tabletenv.LogStats, sql string, ...) (*TabletPlan, error)
- func (qe *QueryEngine) GetStreamPlan(sql string) (*TabletPlan, error)
- func (qe *QueryEngine) InitDBConfig(dbcfgs *dbconfigs.DBConfigs)
- func (qe *QueryEngine) IsMySQLReachable() bool
- func (qe *QueryEngine) Open() error
- func (qe *QueryEngine) QueryPlanCacheCap() int
- func (qe *QueryEngine) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (qe *QueryEngine) SetQueryPlanCacheCap(size int)
- type QueryExecutor
- type QueryList
- type QueryStats
- type RegisterFunction
- type ReplicationWatcher
- func (rpw *ReplicationWatcher) Close()
- func (rpw *ReplicationWatcher) ComputeExtras(options *querypb.ExecuteOptions) *querypb.ResultExtras
- func (rpw *ReplicationWatcher) EventToken() *querypb.EventToken
- func (rpw *ReplicationWatcher) InitDBConfig(dbcfgs *dbconfigs.DBConfigs)
- func (rpw *ReplicationWatcher) Open()
- func (rpw *ReplicationWatcher) Process(ctx context.Context, dbconfigs *dbconfigs.DBConfigs)
- type TabletPlan
- type TabletServer
- func (tsv *TabletServer) AddStatusPart()
- func (tsv *TabletServer) Begin(ctx context.Context, target *querypb.Target, options *querypb.ExecuteOptions) (transactionID int64, err error)
- func (tsv *TabletServer) BeginExecute(ctx context.Context, target *querypb.Target, sql string, ...) (*sqltypes.Result, int64, error)
- func (tsv *TabletServer) BeginExecuteBatch(ctx context.Context, target *querypb.Target, queries []*querypb.BoundQuery, ...) ([]sqltypes.Result, int64, error)
- func (tsv *TabletServer) BroadcastHealth(terTimestamp int64, stats *querypb.RealtimeStats)
- func (tsv *TabletServer) CheckMySQL()
- func (tsv *TabletServer) ClearQueryPlanCache()
- func (tsv *TabletServer) Close(ctx context.Context) error
- func (tsv *TabletServer) Commit(ctx context.Context, target *querypb.Target, transactionID int64) (err error)
- func (tsv *TabletServer) CommitPrepared(ctx context.Context, target *querypb.Target, dtid string) (err error)
- func (tsv *TabletServer) ConcludeTransaction(ctx context.Context, target *querypb.Target, dtid string) (err error)
- func (tsv *TabletServer) CreateTransaction(ctx context.Context, target *querypb.Target, dtid string, ...) (err error)
- func (tsv *TabletServer) EnterLameduck()
- func (tsv *TabletServer) Execute(ctx context.Context, target *querypb.Target, sql string, ...) (result *sqltypes.Result, err error)
- func (tsv *TabletServer) ExecuteBatch(ctx context.Context, target *querypb.Target, queries []*querypb.BoundQuery, ...) (results []sqltypes.Result, err error)
- func (tsv *TabletServer) ExitLameduck()
- func (tsv *TabletServer) GetQueryPoolTimeout() time.Duration
- func (tsv *TabletServer) GetQueryPoolWaiterCap() int64
- func (tsv *TabletServer) GetState() string
- func (tsv *TabletServer) GetTxPoolWaiterCap() int64
- func (tsv *TabletServer) HandlePanic(err *error)
- func (tsv *TabletServer) HeartbeatLag() (time.Duration, error)
- func (tsv *TabletServer) InitACL(tableACLConfigFile string, enforceTableACLConfig bool)
- func (tsv *TabletServer) InitDBConfig(target querypb.Target, dbcfgs *dbconfigs.DBConfigs) error
- func (tsv *TabletServer) IsHealthy() error
- func (tsv *TabletServer) IsServing() bool
- func (tsv *TabletServer) MaxDMLRows() int
- func (tsv *TabletServer) MaxResultSize() int
- func (tsv *TabletServer) MessageAck(ctx context.Context, target *querypb.Target, name string, ids []*querypb.Value) (count int64, err error)
- func (tsv *TabletServer) MessageStream(ctx context.Context, target *querypb.Target, name string, ...) (err error)
- func (tsv *TabletServer) PoolSize() int
- func (tsv *TabletServer) PostponeMessages(ctx context.Context, target *querypb.Target, name string, ids []string) (count int64, err error)
- func (tsv *TabletServer) Prepare(ctx context.Context, target *querypb.Target, transactionID int64, dtid string) (err error)
- func (tsv *TabletServer) PurgeMessages(ctx context.Context, target *querypb.Target, name string, timeCutoff int64) (count int64, err error)
- func (tsv *TabletServer) QueryPlanCacheCap() int
- func (tsv *TabletServer) QueryService() queryservice.QueryService
- func (tsv *TabletServer) ReadTransaction(ctx context.Context, target *querypb.Target, dtid string) (metadata *querypb.TransactionMetadata, err error)
- func (tsv *TabletServer) Register()
- func (tsv *TabletServer) RegisterQueryRuleSource(ruleSource string)
- func (tsv *TabletServer) ReloadSchema(ctx context.Context) error
- func (tsv *TabletServer) Rollback(ctx context.Context, target *querypb.Target, transactionID int64) (err error)
- func (tsv *TabletServer) RollbackPrepared(ctx context.Context, target *querypb.Target, dtid string, originalID int64) (err error)
- func (tsv *TabletServer) SchemaEngine() *schema.Engine
- func (tsv *TabletServer) SetAllowUnsafeDMLs(val bool)
- func (tsv *TabletServer) SetAutoCommit(auto bool)
- func (tsv *TabletServer) SetConsolidatorEnabled(enabled bool)
- func (tsv *TabletServer) SetMaxDMLRows(val int)
- func (tsv *TabletServer) SetMaxResultSize(val int)
- func (tsv *TabletServer) SetPassthroughDMLs(val bool)
- func (tsv *TabletServer) SetPoolSize(val int)
- func (tsv *TabletServer) SetQueryPlanCacheCap(val int)
- func (tsv *TabletServer) SetQueryPoolTimeout(val time.Duration)
- func (tsv *TabletServer) SetQueryPoolWaiterCap(val int64)
- func (tsv *TabletServer) SetQueryRules(ruleSource string, qrs *rules.Rules) error
- func (tsv *TabletServer) SetRollback(ctx context.Context, target *querypb.Target, dtid string, transactionID int64) (err error)
- func (tsv *TabletServer) SetServingType(tabletType topodatapb.TabletType, serving bool, ...) (stateChanged bool, err error)
- func (tsv *TabletServer) SetStreamPoolSize(val int)
- func (tsv *TabletServer) SetTxPoolSize(val int)
- func (tsv *TabletServer) SetTxPoolWaiterCap(val int64)
- func (tsv *TabletServer) SetTxTimeout(val time.Duration)
- func (tsv *TabletServer) SetWarnResultSize(val int)
- func (tsv *TabletServer) SplitQuery(ctx context.Context, target *querypb.Target, query *querypb.BoundQuery, ...) (splits []*querypb.QuerySplit, err error)
- func (tsv *TabletServer) StartCommit(ctx context.Context, target *querypb.Target, transactionID int64, dtid string) (err error)
- func (tsv *TabletServer) StartService(target querypb.Target, dbcfgs *dbconfigs.DBConfigs) (err error)
- func (tsv *TabletServer) StopService()
- func (tsv *TabletServer) StreamExecute(ctx context.Context, target *querypb.Target, sql string, ...) (err error)
- func (tsv *TabletServer) StreamHealth(ctx context.Context, callback func(*querypb.StreamHealthResponse) error) error
- func (tsv *TabletServer) StreamPoolSize() int
- func (tsv *TabletServer) TopoServer() *topo.Server
- func (tsv *TabletServer) TxPoolSize() int
- func (tsv *TabletServer) TxTimeout() time.Duration
- func (tsv *TabletServer) UnRegisterQueryRuleSource(ruleSource string)
- func (tsv *TabletServer) UpdateStream(ctx context.Context, target *querypb.Target, position string, timestamp int64, ...) error
- func (tsv *TabletServer) WarnResultSize() int
- type TwoPC
- func (tpc *TwoPC) Close()
- func (tpc *TwoPC) CountUnresolvedRedo(ctx context.Context, unresolvedTime time.Time) (int64, error)
- func (tpc *TwoPC) CreateTransaction(ctx context.Context, conn *TxConnection, dtid string, ...) error
- func (tpc *TwoPC) DeleteRedo(ctx context.Context, conn *TxConnection, dtid string) error
- func (tpc *TwoPC) DeleteTransaction(ctx context.Context, conn *TxConnection, dtid string) error
- func (tpc *TwoPC) Init(sidecarDBName string, dbaparams *mysql.ConnParams) error
- func (tpc *TwoPC) Open(dbconfigs *dbconfigs.DBConfigs)
- func (tpc *TwoPC) ReadAbandoned(ctx context.Context, abandonTime time.Time) (map[string]time.Time, error)
- func (tpc *TwoPC) ReadAllRedo(ctx context.Context) (prepared, failed []*PreparedTx, err error)
- func (tpc *TwoPC) ReadAllTransactions(ctx context.Context) ([]*DistributedTx, error)
- func (tpc *TwoPC) ReadTransaction(ctx context.Context, dtid string) (*querypb.TransactionMetadata, error)
- func (tpc *TwoPC) SaveRedo(ctx context.Context, conn *TxConnection, dtid string, queries []string) error
- func (tpc *TwoPC) Transition(ctx context.Context, conn *TxConnection, dtid string, ...) error
- func (tpc *TwoPC) UpdateRedo(ctx context.Context, conn *TxConnection, dtid string, state int) error
- type TxConnection
- func (txc *TxConnection) BeginAgain(ctx context.Context) error
- func (txc *TxConnection) EventTime() time.Time
- func (txc *TxConnection) Exec(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
- func (txc *TxConnection) Format(params url.Values) string
- func (txc *TxConnection) RecordQuery(query string)
- func (txc *TxConnection) Recycle()
- type TxEngine
- type TxExecutor
- func (txe *TxExecutor) CommitPrepared(dtid string) error
- func (txe *TxExecutor) ConcludeTransaction(dtid string) error
- func (txe *TxExecutor) CreateTransaction(dtid string, participants []*querypb.Target) error
- func (txe *TxExecutor) Prepare(transactionID int64, dtid string) error
- func (txe *TxExecutor) ReadTransaction(dtid string) (*querypb.TransactionMetadata, error)
- func (txe *TxExecutor) ReadTwopcInflight() (distributed []*DistributedTx, prepared, failed []*PreparedTx, err error)
- func (txe *TxExecutor) RollbackPrepared(dtid string, originalID int64) error
- func (txe *TxExecutor) SetRollback(dtid string, transactionID int64) error
- func (txe *TxExecutor) StartCommit(transactionID int64, dtid string) error
- type TxPool
- func (axp *TxPool) AdjustLastID(id int64)
- func (axp *TxPool) Begin(ctx context.Context, options *querypb.ExecuteOptions) (int64, error)
- func (axp *TxPool) Close()
- func (axp *TxPool) Commit(ctx context.Context, transactionID int64, mc messageCommitter) error
- func (axp *TxPool) Get(transactionID int64, reason string) (*TxConnection, error)
- func (axp *TxPool) LocalBegin(ctx context.Context, options *querypb.ExecuteOptions) (*TxConnection, error)
- func (axp *TxPool) LocalCommit(ctx context.Context, conn *TxConnection, mc messageCommitter) error
- func (axp *TxPool) LocalConclude(ctx context.Context, conn *TxConnection)
- func (axp *TxPool) LogActive()
- func (axp *TxPool) Open(appParams, dbaParams, appDebugParams *mysql.ConnParams)
- func (axp *TxPool) Rollback(ctx context.Context, transactionID int64) error
- func (axp *TxPool) RollbackNonBusy(ctx context.Context)
- func (axp *TxPool) SetTimeout(timeout time.Duration)
- func (axp *TxPool) Timeout() time.Duration
- func (axp *TxPool) WaitForEmpty()
- type TxPreparedPool
- func (pp *TxPreparedPool) FetchAll() []*TxConnection
- func (pp *TxPreparedPool) FetchForCommit(dtid string) (*TxConnection, error)
- func (pp *TxPreparedPool) FetchForRollback(dtid string) *TxConnection
- func (pp *TxPreparedPool) Forget(dtid string)
- func (pp *TxPreparedPool) Put(c *TxConnection, dtid string) error
- func (pp *TxPreparedPool) SetFailed(dtid string)
Constants ¶
const ( // StateNotConnected is the state where tabletserver is not // connected to an underlying mysql instance. StateNotConnected = iota // StateNotServing is the state where tabletserver is connected // to an underlying mysql instance, but is not serving queries. StateNotServing // StateServing is where queries are allowed. StateServing // StateTransitioning is a transient state indicating that // the tabletserver is tranisitioning to a new state. // In order to achieve clean transitions, no requests are // allowed during this state. StateTransitioning // StateShuttingDown indicates that the tabletserver // is shutting down. In this state, we wait for outstanding // requests and transactions to conclude. StateShuttingDown )
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 )
const ( TxClose = "close" TxCommit = "commit" TxRollback = "rollback" TxPrepare = "prepare" TxKill = "kill" )
These consts identify how a transaction was resolved.
Variables ¶
var RegisterFunctions []RegisterFunction
RegisterFunctions is a list of all the RegisterFunction that will be called upon Register() on a TabletServer
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface { // Register registers this query service with the RPC layer. Register() // AddStatusPart adds the status part to the status page AddStatusPart() // InitDBConfig sets up the db config vars. InitDBConfig(querypb.Target, *dbconfigs.DBConfigs) 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, serving bool, alsoAllow []topodatapb.TabletType) (bool, 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(terTimestamp int64, stats *querypb.RealtimeStats) // HeartbeatLag returns the current lag as calculated by the heartbeat // package, if heartbeat is enabled. Otherwise returns 0. HeartbeatLag() (time.Duration, error) // TopoServer returns the topo server. TopoServer() *topo.Server }
Controller defines the control interface for TabletServer.
type DistributedTx ¶
type DistributedTx struct { Dtid string State string Created time.Time Participants []querypb.Target }
DistributedTx is similar to querypb.TransactionMetadata, but is display friendly.
type PreparedTx ¶
PreparedTx represents a displayable version of a prepared transaction.
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 { Query string ContextHTML template.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(checker connpool.MySQLChecker, se *schema.Engine, config tabletenv.TabletConfig) *QueryEngine
NewQueryEngine creates a new QueryEngine. This is a singleton class. You must call this only once.
func (*QueryEngine) AddStats ¶
func (qe *QueryEngine) AddStats(planName, tableName string, queryCount int64, duration, mysqlTime time.Duration, rowCount, errorCount int64)
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) 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) InitDBConfig ¶
func (qe *QueryEngine) InitDBConfig(dbcfgs *dbconfigs.DBConfigs)
InitDBConfig must be called before Open.
func (*QueryEngine) IsMySQLReachable ¶
func (qe *QueryEngine) IsMySQLReachable() bool
IsMySQLReachable returns true if we can connect to MySQL.
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) ServeHTTP ¶
func (qe *QueryEngine) ServeHTTP(response http.ResponseWriter, request *http.Request)
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) Execute ¶
func (qre *QueryExecutor) Execute() (reply *sqltypes.Result, err error)
Execute performs a non-streaming query execution.
func (*QueryExecutor) MessageStream ¶
func (qre *QueryExecutor) MessageStream(callback func(*sqltypes.Result) error) error
MessageStream streams messages from a message table.
type QueryList ¶
type QueryList struct {
// contains filtered or unexported fields
}
QueryList holds a thread safe list of QueryDetails
func (*QueryList) Add ¶
func (ql *QueryList) Add(qd *QueryDetail)
Add adds a QueryDetail to QueryList
func (*QueryList) GetQueryzRows ¶
func (ql *QueryList) GetQueryzRows() []QueryDetailzRow
GetQueryzRows 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) TerminateAll ¶
func (ql *QueryList) TerminateAll()
TerminateAll terminates all queries and kills the MySQL connections
type QueryStats ¶
type QueryStats struct {
// contains filtered or unexported fields
}
QueryStats tracks query stats for export per planName/tableName
type RegisterFunction ¶
type RegisterFunction func(Controller)
RegisterFunction is a callback type to be called when we Register() a TabletServer
type ReplicationWatcher ¶
type ReplicationWatcher struct {
// contains filtered or unexported fields
}
ReplicationWatcher is a tabletserver service that watches the replication stream. It can tell you the current event token, and it will trigger schema reloads if a DDL is encountered.
func NewReplicationWatcher ¶
func NewReplicationWatcher(se *schema.Engine, config tabletenv.TabletConfig) *ReplicationWatcher
NewReplicationWatcher creates a new ReplicationWatcher.
func (*ReplicationWatcher) Close ¶
func (rpw *ReplicationWatcher) Close()
Close stops the ReplicationWatcher service.
func (*ReplicationWatcher) ComputeExtras ¶
func (rpw *ReplicationWatcher) ComputeExtras(options *querypb.ExecuteOptions) *querypb.ResultExtras
ComputeExtras returns the requested ResultExtras based on the supplied options.
func (*ReplicationWatcher) EventToken ¶
func (rpw *ReplicationWatcher) EventToken() *querypb.EventToken
EventToken returns the current event token.
func (*ReplicationWatcher) InitDBConfig ¶
func (rpw *ReplicationWatcher) InitDBConfig(dbcfgs *dbconfigs.DBConfigs)
InitDBConfig must be called before Open.
func (*ReplicationWatcher) Open ¶
func (rpw *ReplicationWatcher) Open()
Open starts the ReplicationWatcher service.
type TabletPlan ¶
type TabletPlan struct { *planbuilder.Plan Fields []*querypb.Field Rules *rules.Rules LegacyAuthorized *tableacl.ACLResult Authorized []*tableacl.ACLResult QueryCount int64 Time time.Duration MysqlTime time.Duration RowCount int64 ErrorCount int64 // contains filtered or unexported fields }
TabletPlan wraps the planbuilder's exec plan to enforce additional rules and track stats.
func (*TabletPlan) AddStats ¶
func (ep *TabletPlan) AddStats(queryCount int64, duration, mysqlTime time.Duration, rowCount, errorCount int64)
AddStats updates the stats for the current TabletPlan.
func (*TabletPlan) Size ¶
func (*TabletPlan) Size() int
Size allows TabletPlan to be in cache.LRUCache.
type TabletServer ¶
type TabletServer struct { QueryTimeout sync2.AtomicDuration BeginTimeout sync2.AtomicDuration TerseErrors bool // 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 like creating metadata tables in the sidecar database. These functions 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(topoServer *topo.Server, alias topodatapb.TabletAlias) *TabletServer
NewServer creates a new TabletServer based on the command line flags.
func NewTabletServer ¶
func NewTabletServer(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 NewTabletServerWithNilTopoServer ¶
func NewTabletServerWithNilTopoServer(config tabletenv.TabletConfig) *TabletServer
NewTabletServerWithNilTopoServer is typically used in tests that don't need a topoServer member.
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) (transactionID int64, 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, sql string, bindVariables map[string]*querypb.BindVariable, options *querypb.ExecuteOptions) (*sqltypes.Result, int64, error)
BeginExecute combines Begin and Execute.
func (*TabletServer) BeginExecuteBatch ¶
func (tsv *TabletServer) BeginExecuteBatch(ctx context.Context, target *querypb.Target, queries []*querypb.BoundQuery, asTransaction bool, options *querypb.ExecuteOptions) ([]sqltypes.Result, int64, error)
BeginExecuteBatch combines Begin and ExecuteBatch.
func (*TabletServer) BroadcastHealth ¶
func (tsv *TabletServer) BroadcastHealth(terTimestamp int64, stats *querypb.RealtimeStats)
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.
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) (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) 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) 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 int64, options *querypb.ExecuteOptions) (result *sqltypes.Result, err error)
Execute executes the query and returns the result as response.
func (*TabletServer) ExecuteBatch ¶
func (tsv *TabletServer) ExecuteBatch(ctx context.Context, target *querypb.Target, queries []*querypb.BoundQuery, asTransaction bool, transactionID int64, options *querypb.ExecuteOptions) (results []sqltypes.Result, err error)
ExecuteBatch executes a group of queries and returns their results as a list. ExecuteBatch can be called for an existing transaction, or it can be called with the AsTransaction flag which will execute all statements inside an independent transaction. If AsTransaction is true, TransactionId must be 0.
func (*TabletServer) ExitLameduck ¶
func (tsv *TabletServer) ExitLameduck()
ExitLameduck causes the tabletserver to exit the lameduck mode.
func (*TabletServer) GetQueryPoolTimeout ¶
func (tsv *TabletServer) GetQueryPoolTimeout() time.Duration
GetQueryPoolTimeout returns the timeout to get a connection from the query pool This function should only be used for testing.
func (*TabletServer) GetQueryPoolWaiterCap ¶
func (tsv *TabletServer) GetQueryPoolWaiterCap() int64
GetQueryPoolWaiterCap returns the limit on the number of queries that can be waiting for a connection from the pool This function should only be used for testing.
func (*TabletServer) GetState ¶
func (tsv *TabletServer) GetState() string
GetState returns the name of the current TabletServer state.
func (*TabletServer) GetTxPoolWaiterCap ¶
func (tsv *TabletServer) GetTxPoolWaiterCap() int64
GetTxPoolWaiterCap returns the limit on the number of queries that can be waiting for a connection from the pool This function should only be used for testing.
func (*TabletServer) HandlePanic ¶
func (tsv *TabletServer) HandlePanic(err *error)
HandlePanic is part of the queryservice.QueryService interface
func (*TabletServer) HeartbeatLag ¶
func (tsv *TabletServer) HeartbeatLag() (time.Duration, error)
HeartbeatLag returns the current lag as calculated by the heartbeat package, if heartbeat is enabled. Otherwise returns 0.
func (*TabletServer) InitACL ¶
func (tsv *TabletServer) InitACL(tableACLConfigFile string, enforceTableACLConfig bool)
InitACL loads the table ACL and sets up a SIGHUP handler for reloading it.
func (*TabletServer) InitDBConfig ¶
InitDBConfig initializes the db config variables for TabletServer. You must call this function before calling SetServingType.
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) MaxDMLRows ¶
func (tsv *TabletServer) MaxDMLRows() int
MaxDMLRows returns the max result size.
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, name string, 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, name string, 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 pool size.
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 sepcified 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) ReloadSchema ¶
func (tsv *TabletServer) ReloadSchema(ctx context.Context) error
ReloadSchema reloads the schema.
func (*TabletServer) Rollback ¶
func (tsv *TabletServer) Rollback(ctx context.Context, target *querypb.Target, transactionID 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) SetAllowUnsafeDMLs ¶
func (tsv *TabletServer) SetAllowUnsafeDMLs(val bool)
SetAllowUnsafeDMLs changes the setting to allow unsafe DML statements in SBR mode. It should be used only on initialization or for testing.
func (*TabletServer) SetAutoCommit ¶
func (tsv *TabletServer) SetAutoCommit(auto bool)
SetAutoCommit sets autocommit on or off. This function should only be used for testing.
func (*TabletServer) SetConsolidatorEnabled ¶
func (tsv *TabletServer) SetConsolidatorEnabled(enabled bool)
SetConsolidatorEnabled (true) will enable the query consolidator. SetConsolidatorEnabled (false) will disable the query consolidator. This function should only be used for testing.
func (*TabletServer) SetMaxDMLRows ¶
func (tsv *TabletServer) SetMaxDMLRows(val int)
SetMaxDMLRows changes the max result size to the specified value. This function should only be used for testing.
func (*TabletServer) SetMaxResultSize ¶
func (tsv *TabletServer) SetMaxResultSize(val int)
SetMaxResultSize changes the max result size to the specified value. This function should only be used for testing.
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. This function should only be used for testing.
func (*TabletServer) SetQueryPlanCacheCap ¶
func (tsv *TabletServer) SetQueryPlanCacheCap(val int)
SetQueryPlanCacheCap changes the pool size to the specified value. This function should only be used for testing.
func (*TabletServer) SetQueryPoolTimeout ¶
func (tsv *TabletServer) SetQueryPoolTimeout(val time.Duration)
SetQueryPoolTimeout changes the timeout to get a connection from the query pool This function should only be used for testing.
func (*TabletServer) SetQueryPoolWaiterCap ¶
func (tsv *TabletServer) SetQueryPoolWaiterCap(val int64)
SetQueryPoolWaiterCap changes the limit on the number of queries that can be waiting for a connection from the pool This function should only be used for testing.
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, serving bool, alsoAllow []topodatapb.TabletType) (stateChanged bool, err error)
SetServingType changes the serving type of the tabletserver. It starts or stops internal services as deemed necessary. The tabletType determines the primary serving type, while alsoAllow specifies other tablet types that should also be honored for serving. Returns true if the state of QueryService or the tablet type changed.
func (*TabletServer) SetStreamPoolSize ¶
func (tsv *TabletServer) SetStreamPoolSize(val int)
SetStreamPoolSize changes the pool size to the specified value. This function should only be used for testing.
func (*TabletServer) SetTxPoolSize ¶
func (tsv *TabletServer) SetTxPoolSize(val int)
SetTxPoolSize changes the tx pool size to the specified value. This function should only be used for testing.
func (*TabletServer) SetTxPoolWaiterCap ¶
func (tsv *TabletServer) SetTxPoolWaiterCap(val int64)
SetTxPoolWaiterCap changes the limit on the number of queries that can be waiting for a connection from the pool This function should only be used for testing.
func (*TabletServer) SetTxTimeout ¶
func (tsv *TabletServer) SetTxTimeout(val time.Duration)
SetTxTimeout changes the transaction timeout to the specified value. This function should only be used for testing.
func (*TabletServer) SetWarnResultSize ¶
func (tsv *TabletServer) SetWarnResultSize(val int)
SetWarnResultSize changes the warn result size to the specified value. This function should only be used for testing.
func (*TabletServer) SplitQuery ¶
func (tsv *TabletServer) SplitQuery( ctx context.Context, target *querypb.Target, query *querypb.BoundQuery, splitColumns []string, splitCount int64, numRowsPerQueryPart int64, algorithm querypb.SplitQueryRequest_Algorithm, ) (splits []*querypb.QuerySplit, err error)
SplitQuery splits a query + bind variables into smaller queries that return a subset of rows from the original query. This is the new version that supports multiple split columns and multiple split algortihms. See the documentation of SplitQueryRequest in proto/vtgate.proto for more details.
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) (err error)
StartService is a convenience function for InitDBConfig->SetServingType with serving=true.
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 QueryEngine. This function should be called before process termination, or if MySQL is unreachable. Under normal circumstances, SetServingType should be called, which will keep QueryEngine open.
func (*TabletServer) StreamExecute ¶
func (tsv *TabletServer) StreamExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, 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. At the beginning, if TabletServer has a valid health state, that response is immediately sent.
func (*TabletServer) StreamPoolSize ¶
func (tsv *TabletServer) StreamPoolSize() int
StreamPoolSize returns the pool size.
func (*TabletServer) TopoServer ¶
func (tsv *TabletServer) TopoServer() *topo.Server
TopoServer returns the topo server.
func (*TabletServer) TxPoolSize ¶
func (tsv *TabletServer) TxPoolSize() int
TxPoolSize returns the tx pool size.
func (*TabletServer) TxTimeout ¶
func (tsv *TabletServer) TxTimeout() time.Duration
TxTimeout returns the transaction timeout.
func (*TabletServer) UnRegisterQueryRuleSource ¶
func (tsv *TabletServer) UnRegisterQueryRuleSource(ruleSource string)
UnRegisterQueryRuleSource unregisters ruleSource from query rules.
func (*TabletServer) UpdateStream ¶
func (tsv *TabletServer) UpdateStream(ctx context.Context, target *querypb.Target, position string, timestamp int64, callback func(*querypb.StreamEvent) error) error
UpdateStream streams binlog events.
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 (*TwoPC) CountUnresolvedRedo ¶
CountUnresolvedRedo returns the number of prepared transactions that are still unresolved.
func (*TwoPC) CreateTransaction ¶
func (tpc *TwoPC) CreateTransaction(ctx context.Context, conn *TxConnection, dtid string, participants []*querypb.Target) error
CreateTransaction saves the metadata of a 2pc transaction as Prepared.
func (*TwoPC) DeleteRedo ¶
DeleteRedo deletes the redo log for the dtid.
func (*TwoPC) DeleteTransaction ¶
DeleteTransaction deletes the metadata for the specified transaction.
func (*TwoPC) Init ¶
func (tpc *TwoPC) Init(sidecarDBName string, dbaparams *mysql.ConnParams) error
Init initializes TwoPC. If the metadata database or tables are not present, they are created.
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 []*PreparedTx, err error)
ReadAllRedo returns all the prepared transactions from the redo logs.
func (*TwoPC) ReadAllTransactions ¶
func (tpc *TwoPC) ReadAllTransactions(ctx context.Context) ([]*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 *TxConnection, 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 *TxConnection, 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 ¶
UpdateRedo changes the state of the redo log for the dtid.
type TxConnection ¶
type TxConnection struct { *connpool.DBConn TransactionID int64 StartTime time.Time EndTime time.Time Queries []string NewMessages map[string][]*messager.MessageRow ChangedMessages map[string][]string Conclusion string LogToFile sync2.AtomicInt32 ImmediateCallerID *querypb.VTGateCallerID EffectiveCallerID *vtrpcpb.CallerID // contains filtered or unexported fields }
TxConnection is meant for executing transactions. It can return itself to the tx pool correctly. It also does not retry statements if there are failures.
func (*TxConnection) BeginAgain ¶
func (txc *TxConnection) BeginAgain(ctx context.Context) error
BeginAgain commits the existing transaction and begins a new one
func (*TxConnection) EventTime ¶
func (txc *TxConnection) EventTime() time.Time
EventTime returns the time the event was created.
func (*TxConnection) Exec ¶
func (txc *TxConnection) Exec(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
Exec executes the statement for the current transaction.
func (*TxConnection) Format ¶
func (txc *TxConnection) Format(params url.Values) string
Format returns a printable version of the connection info.
func (*TxConnection) RecordQuery ¶
func (txc *TxConnection) RecordQuery(query string)
RecordQuery records the query against this transaction.
func (*TxConnection) Recycle ¶
func (txc *TxConnection) Recycle()
Recycle returns the connection to the pool. The transaction remains active.
type TxEngine ¶
type TxEngine struct {
// contains filtered or unexported fields
}
TxEngine handles transactions.
func NewTxEngine ¶
func NewTxEngine(checker connpool.MySQLChecker, config tabletenv.TabletConfig) *TxEngine
NewTxEngine creates a new TxEngine.
func (*TxEngine) Close ¶
Close closes the TxEngine. If the immediate flag is on, then all current transactions are immediately rolled back. Otherwise, the function waits for all current transactions to conclude. If a shutdown grace period was specified, the transactions are rolled back if they're not resolved by that time.
func (*TxEngine) Init ¶
Init must be called once when vttablet starts for setting up the metadata tables.
func (*TxEngine) InitDBConfig ¶
InitDBConfig must be called before Init.
type TxExecutor ¶
type TxExecutor struct {
// contains filtered or unexported fields
}
TxExecutor is used for executing a transactional request.
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 []*DistributedTx, prepared, failed []*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 is the transaction pool for the query service.
func NewTxPool ¶
func NewTxPool( prefix string, capacity int, foundRowsCapacity int, timeout time.Duration, idleTimeout time.Duration, waiterCap int, checker connpool.MySQLChecker, limiter txlimiter.TxLimiter) *TxPool
NewTxPool creates a new TxPool. It's not operational until it's Open'd.
func (*TxPool) AdjustLastID ¶
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 ¶
Begin begins a transaction, and returns the associated transaction id. Subsequent statements can access the connection through the transaction id.
func (*TxPool) Close ¶
func (axp *TxPool) Close()
Close closes the TxPool. A closed pool can be reopened.
func (*TxPool) Get ¶
func (axp *TxPool) Get(transactionID int64, reason string) (*TxConnection, error)
Get fetches the connection associated to the transactionID. You must call Recycle on TxConnection once done.
func (*TxPool) LocalBegin ¶
func (axp *TxPool) LocalBegin(ctx context.Context, options *querypb.ExecuteOptions) (*TxConnection, error)
LocalBegin is equivalent to Begin->Get. It's used for executing transactions within a request. It's safe to always call LocalConclude at the end.
func (*TxPool) LocalCommit ¶
func (axp *TxPool) LocalCommit(ctx context.Context, conn *TxConnection, mc messageCommitter) error
LocalCommit is the commit function for LocalBegin.
func (*TxPool) LocalConclude ¶
func (axp *TxPool) LocalConclude(ctx context.Context, conn *TxConnection)
LocalConclude concludes a transaction started by LocalBegin. If the transaction was not previously concluded, it's rolled back.
func (*TxPool) LogActive ¶
func (axp *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) Open ¶
func (axp *TxPool) Open(appParams, dbaParams, appDebugParams *mysql.ConnParams)
Open makes the TxPool operational. This also starts the transaction killer that will kill long-running transactions.
func (*TxPool) RollbackNonBusy ¶
RollbackNonBusy rolls back all transactions that are not in use. Transactions can be in use for situations like executing statements or in prepared state.
func (*TxPool) SetTimeout ¶
SetTimeout sets the transaction timeout.
func (*TxPool) WaitForEmpty ¶
func (axp *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() []*TxConnection
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) (*TxConnection, 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) *TxConnection
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 *TxConnection, 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.
Source Files ¶
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 splitquery contains the logic needed for implementing the tabletserver's SplitQuery RPC.
|
Package splitquery contains the logic needed for implementing the tabletserver's SplitQuery RPC. |
splitquery_testing
Package splitquery_testing is a generated GoMock package.
|
Package splitquery_testing is a generated GoMock package. |
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. |