Documentation ¶
Index ¶
- Constants
- Variables
- func AddStatusPart()
- func AllowQueries(dbconfig *dbconfigs.DBConfig, schemaOverrides []SchemaOverride, ...) error
- func Commit(logStats *SQLQueryStats, qe *QueryEngine, transactionID int64)
- func DisallowQueries()
- func GetSessionId() int64
- func InitQueryService()
- func IsHealthy() error
- func Rand() int64
- func RegisterQueryService()
- func ReloadSchema()
- func SetQueryRules(qrs *QueryRules)
- type Action
- type BindVarCond
- type CacheInvalidator
- type CachePool
- func (cp *CachePool) Available() int64
- func (cp *CachePool) Capacity() int64
- func (cp *CachePool) Close()
- func (cp *CachePool) Get(timeout time.Duration) *memcache.Connection
- func (cp *CachePool) IdleTimeout() time.Duration
- func (cp *CachePool) IsClosed() bool
- func (cp *CachePool) MaxCap() int64
- func (cp *CachePool) Open()
- func (cp *CachePool) Put(conn *memcache.Connection)
- func (cp *CachePool) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (cp *CachePool) StatsJSON() string
- func (cp *CachePool) WaitCount() int64
- func (cp *CachePool) WaitTime() time.Duration
- type Config
- type ConnectionKiller
- func (ck *ConnectionKiller) Close()
- func (ck *ConnectionKiller) Kill(connID int64) error
- func (ck *ConnectionKiller) Open(ConnFactory dbconnpool.CreateConnectionFunc)
- func (ck *ConnectionKiller) SetDeadline(connID int64, deadline Deadline) QueryDeadliner
- func (ck *ConnectionKiller) SetIdleTimeout(idleTimeout time.Duration)
- type Consolidator
- type CreateCacheFunc
- type Deadline
- type DirtyKeys
- type ExecPlan
- type MemcacheStats
- type Operator
- type QueryDeadliner
- type QueryDetail
- type QueryDetailzRow
- type QueryEngine
- type QueryExecutor
- type QueryList
- type QueryRule
- func (qr *QueryRule) AddBindVarCond(name string, onAbsent, onMismatch bool, op Operator, value interface{}) error
- func (qr *QueryRule) AddPlanCond(planType planbuilder.PlanType)
- func (qr *QueryRule) AddTableCond(tableName string)
- func (qr *QueryRule) Copy() (newqr *QueryRule)
- func (qr *QueryRule) SetIPCond(pattern string) (err error)
- func (qr *QueryRule) SetQueryCond(pattern string) (err error)
- func (qr *QueryRule) SetUserCond(pattern string) (err error)
- type QueryRules
- type QuerySplitter
- type RCResult
- type RequestContext
- type Result
- type RowCache
- type RowCacheConfig
- type RowcacheInvalidator
- func (rci *RowcacheInvalidator) AppendGTID(gtid myproto.GTID)
- func (rci *RowcacheInvalidator) Close()
- func (rci *RowcacheInvalidator) Open(dbname string, mysqld *mysqlctl.Mysqld)
- func (rci *RowcacheInvalidator) Position() myproto.ReplicationPosition
- func (rci *RowcacheInvalidator) PositionString() string
- func (rci *RowcacheInvalidator) SetPosition(rp myproto.ReplicationPosition)
- type SQLQueryStats
- func (stats *SQLQueryStats) AddRewrittenSql(sql string, start time.Time)
- func (log *SQLQueryStats) ContextHTML() template.HTML
- func (stats *SQLQueryStats) FmtBindVariables(full bool) string
- func (stats *SQLQueryStats) FmtQuerySources() string
- func (log *SQLQueryStats) Format(params url.Values) string
- func (log *SQLQueryStats) RemoteAddr() string
- func (stats *SQLQueryStats) RewrittenSql() string
- func (stats *SQLQueryStats) Send()
- func (stats *SQLQueryStats) SizeOfResponse() int
- func (stats *SQLQueryStats) TotalTime() time.Duration
- func (log *SQLQueryStats) Username() string
- type SchemaInfo
- func (si *SchemaInfo) Close()
- func (si *SchemaInfo) CreateOrUpdateTable(tableName string)
- func (si *SchemaInfo) DropTable(tableName string)
- func (si *SchemaInfo) GetPlan(logStats *SQLQueryStats, sql string) *ExecPlan
- func (si *SchemaInfo) GetRules() (qrs *QueryRules)
- func (si *SchemaInfo) GetSchema() []*schema.Table
- func (si *SchemaInfo) GetStreamPlan(sql string) *ExecPlan
- func (si *SchemaInfo) GetTable(tableName string) *TableInfo
- func (si *SchemaInfo) Open(connFactory dbconnpool.CreateConnectionFunc, schemaOverrides []SchemaOverride, ...)
- func (si *SchemaInfo) Reload()
- func (si *SchemaInfo) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (si *SchemaInfo) SetQueryCacheSize(size int)
- func (si *SchemaInfo) SetReloadTime(reloadTime time.Duration)
- func (si *SchemaInfo) SetRules(qrs *QueryRules)
- type SchemaOverride
- type SqlQuery
- func (sq *SqlQuery) Begin(context context.Context, session *proto.Session, txInfo *proto.TransactionInfo) (err error)
- func (sq *SqlQuery) Commit(context context.Context, session *proto.Session) (err error)
- func (sq *SqlQuery) Execute(context context.Context, query *proto.Query, reply *mproto.QueryResult) (err error)
- func (sq *SqlQuery) ExecuteBatch(context context.Context, queryList *proto.QueryList, ...) (err error)
- func (sq *SqlQuery) GetSessionId(sessionParams *proto.SessionParams, sessionInfo *proto.SessionInfo) error
- func (sq *SqlQuery) GetState() string
- func (sq *SqlQuery) Rollback(context context.Context, session *proto.Session) (err error)
- func (sq *SqlQuery) SplitQuery(context context.Context, req *proto.SplitQueryRequest, ...) error
- func (sq *SqlQuery) StreamExecute(context context.Context, query *proto.Query, ...) (err error)
- type SqlQueryRegisterFunction
- type TableInfo
- type TabletError
- type TxConnection
- type TxPool
- func (axp *TxPool) Begin() int64
- func (axp *TxPool) Close()
- func (axp *TxPool) Get(transactionId int64) (conn *TxConnection)
- func (axp *TxPool) LogActive()
- func (axp *TxPool) Open(connFactory dbconnpool.CreateConnectionFunc)
- func (axp *TxPool) Rollback(transactionId int64)
- func (axp *TxPool) SafeCommit(transactionId int64) (invalidList map[string]DirtyKeys, err error)
- func (axp *TxPool) SetPoolTimeout(timeout time.Duration)
- func (axp *TxPool) SetTimeout(timeout time.Duration)
- func (axp *TxPool) Timeout() time.Duration
- func (axp *TxPool) TransactionKiller()
- func (axp *TxPool) WaitForEmpty()
Constants ¶
const ( QR_CONTINUE = Action(iota) QR_FAIL QR_FAIL_RETRY )
const ( QR_NOOP = Operator(iota) QR_EQ QR_NE QR_LT QR_GE QR_GT QR_LE QR_MATCH QR_NOMATCH QR_IN QR_NOTIN )
const ( QR_OK = iota QR_MISMATCH QR_OUT_OF_RANGE )
const ( RC_DELETED = 1 // MAX_KEY_LEN is a value less than memcache's limit of 250. MAX_KEY_LEN = 200 // MAX_DATA_LEN prevents large rows from being inserted in rowcache. MAX_DATA_LEN = 8000 )
const ( // Allowed state transitions: // NOT_SERVING -> INITIALIZING -> SERVING/NOT_SERVING, // SERVING -> SHUTTING_TX // SHUTTING_TX -> SHUTTING_QUERIES // SHUTTING_QUERIES -> NOT_SERVING // // NOT_SERVING: The query service is not serving queries. NOT_SERVING = iota // INITIALIZING: The query service is tyring to get to the SERVING state. // This is a transient state. It's only informational. INITIALIZING // SERVING: Query service is running. Everything is allowed. SERVING // SHUTTING_TX: Query service is shutting down and has disallowed // new transactions. New queries are still allowed as long as they // are part of an existing transaction. We remain in this state // until all existing transactions are completed. SHUTTING_TX // SHUTTING_QUERIES: Query service is shutting down and has disallowed // new queries. This state follows SHUTTING_TX. We enter this state // after all existing transactions have completed. We remain in this // state until all existing queries are completed. The next state // after this is NOT_SERVING. SHUTTING_QUERIES )
const ( QUERY_SOURCE_ROWCACHE = 1 << iota QUERY_SOURCE_CONSOLIDATOR QUERY_SOURCE_MYSQL )
const ( FAIL = iota RETRY FATAL TX_POOL_FULL NOT_IN_TX )
const ( TX_CLOSE = "close" TX_COMMIT = "commit" TX_ROLLBACK = "rollback" TX_KILL = "kill" )
const TRAILING_COMMENT = "_trailingComment"
Variables ¶
var ( BEGIN = "begin" COMMIT = "commit" ROLLBACK = "rollback" )
var DefaultQsConfig = Config{ PoolSize: 16, StreamPoolSize: 750, TransactionCap: 20, TransactionTimeout: 30, MaxResultSize: 10000, QueryCacheSize: 5000, SchemaReloadTime: 30 * 60, QueryTimeout: 0, TxPoolTimeout: 1, IdleTimeout: 30 * 60, StreamBufferSize: 32 * 1024, RowCache: RowCacheConfig{Memory: -1, TcpPort: -1, Connections: -1, Threads: -1}, SpotCheckRatio: 0, StrictMode: true, StrictTableAcl: false, }
DefaultQSConfig is the default value for the query service config.
The value for StreamBufferSize was chosen after trying out a few of them. Too small buffers force too many packets to be sent. Too big buffers force the clients to read them in multiple chunks and make memory copies. so with the encoding overhead, this seems to work great (the overhead makes the final packets on the wire about twice bigger than this).
var (
QPSRates *stats.Rates
)
var SqlQueryLogger = streamlog.New("SqlQuery", 50)
var SqlQueryRegisterFunctions []SqlQueryRegisterFunction
var TimeoutErr = errors.New("timed out")
var TxLogger = streamlog.New("TxLog", 10)
TxLogger can be used to enable logging of transactions. Call TxLogger.ServeLogs in your main program to enable logging. The log format can be inferred by looking at TxConnection.Format.
Functions ¶
func AddStatusPart ¶
func AddStatusPart()
AddStatusPart registers the status part for the status page.
func AllowQueries ¶
func AllowQueries(dbconfig *dbconfigs.DBConfig, schemaOverrides []SchemaOverride, qrs *QueryRules, mysqld *mysqlctl.Mysqld, waitForMysql bool) error
AllowQueries can take an indefinite amount of time to return because it keeps retrying until it obtains a valid connection to the database.
func Commit ¶
func Commit(logStats *SQLQueryStats, qe *QueryEngine, transactionID int64)
Commit commits the specified transaction.
func DisallowQueries ¶
func DisallowQueries()
DisallowQueries can take a long time to return (not indefinite) because it has to wait for queries & transactions to be completed or killed, and also for house keeping goroutines to be terminated.
func GetSessionId ¶
func GetSessionId() int64
func InitQueryService ¶
func InitQueryService()
InitQueryService registers the query service, after loading any necessary config files. It also starts any relevant streaming logs.
func IsHealthy ¶
func IsHealthy() error
IsHealthy returns nil if the query service is healthy (able to connect to the database and serving traffic) or an error explaining the unhealthiness otherwise.
func RegisterQueryService ¶
func RegisterQueryService()
func ReloadSchema ¶
func ReloadSchema()
Reload the schema. If the query service is not running, nothing will happen
func SetQueryRules ¶
func SetQueryRules(qrs *QueryRules)
Types ¶
type Action ¶
type Action int
Action speficies the list of actions to perform when a QueryRule is triggered.
type BindVarCond ¶
type BindVarCond struct {
// contains filtered or unexported fields
}
BindVarCond represents a bind var condition.
type CacheInvalidator ¶
type CacheInvalidator interface {
Delete(key string)
}
CacheInvalidator provides the abstraction needed for an instant invalidation vs. delayed invalidation in the case of in-transaction dmls
type CachePool ¶
type CachePool struct { DeleteExpiry uint64 // contains filtered or unexported fields }
CachePool re-exposes ResourcePool as a pool of Memcache connection objects.
func NewCachePool ¶
func (*CachePool) Get ¶
func (cp *CachePool) Get(timeout time.Duration) *memcache.Connection
You must call Put after Get.
func (*CachePool) IdleTimeout ¶
func (*CachePool) Put ¶
func (cp *CachePool) Put(conn *memcache.Connection)
type Config ¶
type Config struct { PoolSize int StreamPoolSize int TransactionCap int TransactionTimeout float64 MaxResultSize int StreamBufferSize int QueryCacheSize int SchemaReloadTime float64 QueryTimeout float64 TxPoolTimeout float64 IdleTimeout float64 RowCache RowCacheConfig SpotCheckRatio float64 StrictMode bool StrictTableAcl bool }
type ConnectionKiller ¶
type ConnectionKiller struct {
// contains filtered or unexported fields
}
ConnectionKiller is used for killing MySQL connections
func NewConnectionKiller ¶
func NewConnectionKiller(poolSize int, idleTimeout time.Duration) *ConnectionKiller
NewConnectionKiller creates a new ConnectionKiller
func (*ConnectionKiller) Close ¶
func (ck *ConnectionKiller) Close()
Close closes the underlying connection pool
func (*ConnectionKiller) Kill ¶
func (ck *ConnectionKiller) Kill(connID int64) error
Kill kills the specified connection
func (*ConnectionKiller) Open ¶
func (ck *ConnectionKiller) Open(ConnFactory dbconnpool.CreateConnectionFunc)
Open opens the connection pool used to kill other connections
func (*ConnectionKiller) SetDeadline ¶
func (ck *ConnectionKiller) SetDeadline(connID int64, deadline Deadline) QueryDeadliner
SetDeadline sets a deadline for the specifed connID. It also returns a QueryDeadliner. If Done is not called on QueryDeadliner before the deadline is reached, the connection is killed.
func (*ConnectionKiller) SetIdleTimeout ¶
func (ck *ConnectionKiller) SetIdleTimeout(idleTimeout time.Duration)
SetIdleTimeout sets the idle timeout for the underlying connection pool
type Consolidator ¶
type Consolidator struct {
// contains filtered or unexported fields
}
Consolidator consolidates duplicate queries from executing simulaneously and shares results between them.
func NewConsolidator ¶
func NewConsolidator() *Consolidator
NewConsolidator creates a new Consolidator
func (*Consolidator) Create ¶
func (co *Consolidator) Create(sql string) (r *Result, created bool)
Create adds a query to currently executing queries and acquires a lock on its Result if it is not already present. If the query is a duplicate, Create returns false.
func (*Consolidator) ServeHTTP ¶
func (co *Consolidator) ServeHTTP(response http.ResponseWriter, request *http.Request)
type CreateCacheFunc ¶
type CreateCacheFunc func() (*memcache.Connection, error)
type Deadline ¶
Deadline supports deadline oriented convenience functions.
func NewDeadline ¶
NewDeadline creates a deadline using the specified timeout. If the timeout is 0, then the deadline is a zero value.
type ExecPlan ¶
type ExecPlan struct { *planbuilder.ExecPlan TableInfo *TableInfo Fields []mproto.Field Rules *QueryRules Authorized tableacl.ACL QueryCount int64 Time time.Duration RowCount int64 ErrorCount int64 // contains filtered or unexported fields }
type MemcacheStats ¶
type MemcacheStats struct {
// contains filtered or unexported fields
}
MemcacheStats exports the Memcache internal stats through stats package.
func NewMemcacheStats ¶
func NewMemcacheStats(cachePool *CachePool, main, slabs, items bool) *MemcacheStats
NewMemcacheStats creates a new MemcacheStats based on given CachePool. main, slabs and items specify the categories of stats that need to be exported.
func (*MemcacheStats) Close ¶
func (s *MemcacheStats) Close()
Close clears the variable values and stops exporting the stats.
type QueryDeadliner ¶
type QueryDeadliner chan bool
QueryDeadliner is meant to kill a query if it doesn't complete by the specified deadline.
func (QueryDeadliner) Done ¶
func (qd QueryDeadliner) Done()
Done informs the ConnectionKiller that the query completed successfully. If this happens before the deadline, the query will not be killed. Done should not be called more than once.
type QueryDetail ¶
type QueryDetail struct {
// contains filtered or unexported fields
}
QueryDetail is a simple wrapper for Query, Context and PoolConnection
func NewQueryDetail ¶
func NewQueryDetail(query string, context context.Context, connID int64) *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:
WaitForTxEmpty: There should be no more new calls to Begin once this function is called. This will return when there are no more pending transactions.
Close: There should be no more pending queries when this function is called.
Functions of QueryEngine do not return errors. They instead panic with NewTabletError as the error type. TODO(sougou): Switch to error return scheme.
func NewQueryEngine ¶
func NewQueryEngine(config Config) *QueryEngine
NewQueryEngine creates a new QueryEngine. This is a singleton class. You must call this only once.
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) Launch ¶
func (qe *QueryEngine) Launch(f func())
Launch launches the specified function inside a goroutine. If Close or WaitForTxEmpty is called while a goroutine is running, QueryEngine will not return until the existing functions have completed. This functionality allows us to launch tasks with the assurance that the QueryEngine will not be closed underneath us.
func (*QueryEngine) Open ¶
func (qe *QueryEngine) Open(dbconfig *dbconfigs.DBConfig, schemaOverrides []SchemaOverride, qrs *QueryRules, mysqld *mysqlctl.Mysqld)
Open must be called before sending requests to QueryEngine.
func (*QueryEngine) WaitForTxEmpty ¶
func (qe *QueryEngine) WaitForTxEmpty()
WaitForTxEmpty must be called before calling Close. Before calling WaitForTxEmpty, you must ensure that there will be no more calls to Begin.
type QueryExecutor ¶
type QueryExecutor struct { RequestContext // contains filtered or unexported fields }
QueryExecutor is used for executing a query request.
func (*QueryExecutor) Execute ¶
func (qre *QueryExecutor) Execute() (reply *mproto.QueryResult)
Execute performs a non-streaming query execution.
func (*QueryExecutor) Stream ¶
func (qre *QueryExecutor) Stream(sendReply func(*mproto.QueryResult) 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(connKiller *ConnectionKiller) *QueryList
NewQueryList creates a new QueryList
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 QueryRule ¶
QueryRule represents one rule (conditions-action). Name is meant to uniquely identify a rule. Description is a human readable comment that describes the rule. For a QueryRule to fire, all conditions of the QueryRule have to match. For example, an empty QueryRule will match all requests. Every QueryRule has an associated Action. If all the conditions of the QueryRule are met, then the Action is triggerred.
func NewQueryRule ¶
NewQueryRule creates a new QueryRule.
func (*QueryRule) AddBindVarCond ¶
func (qr *QueryRule) AddBindVarCond(name string, onAbsent, onMismatch bool, op Operator, value interface{}) error
AddBindVarCond adds a bind variable restriction to the QueryRule. All bind var conditions have to be satisfied for the QueryRule to be a match. name represents the name (not regexp) of the bind variable. onAbsent specifies the value of the condition if the bind variable is absent. onMismatch specifies the value of the condition if there's a type mismatch on the condition. For inequalities, the bindvar is the left operand and the value in the condition is the right operand: bindVar Operator value. Value & operator rules Type Operators Bindvar nil NOOP any type uint64 EQ, NE, LT, GE, GT, LE whole numbers int64 EQ, NE, LT, GE, GT, LE whole numbers string EQ, NE, LT, GE, GT, LE, MATCH, NOMATCH []byte, string KeyRange IN, NOTIN whole numbers whole numbers can be: int, int8, int16, int32, int64, uint64
func (*QueryRule) AddPlanCond ¶
func (qr *QueryRule) AddPlanCond(planType planbuilder.PlanType)
AddPlanCond adds to the list of plans that can be matched for the rule to fire. This function acts as an OR: Any plan id match is considered a match.
func (*QueryRule) AddTableCond ¶
AddTableCond adds to the list of tableNames that can be matched for the rule to fire. This function acts as an OR: Any tableName match is considered a match.
func (*QueryRule) SetIPCond ¶
SetIPCond adds a regular expression condition for the client IP. It has to be a full match (not substring).
func (*QueryRule) SetQueryCond ¶
SetQueryCond adds a regular expression condition for the query.
func (*QueryRule) SetUserCond ¶
SetUserCond adds a regular expression condition for the user name used by the client.
type QueryRules ¶
type QueryRules struct {
// contains filtered or unexported fields
}
QueryRules is used to store and execute rules for the tabletserver.
func GetQueryRules ¶
func GetQueryRules() (qrs *QueryRules)
func LoadCustomRules ¶
func LoadCustomRules() (qrs *QueryRules)
LoadCustomRules returns custom rules as specified by the command line flags.
func (*QueryRules) Add ¶
func (qrs *QueryRules) Add(qr *QueryRule)
Add adds a QueryRule to QueryRules. It does not check for duplicates.
func (*QueryRules) Copy ¶
func (qrs *QueryRules) Copy() (newqrs *QueryRules)
Copy performs a deep copy of QueryRules. A nil input produces a nil output.
func (*QueryRules) Delete ¶
func (qrs *QueryRules) Delete(name string) (qr *QueryRule)
Delete deletes a QueryRule by name and returns the rule that was deleted. It returns nil if the rule was not found.
func (*QueryRules) Find ¶
func (qrs *QueryRules) Find(name string) (qr *QueryRule)
Find finds the first occurrence of a QueryRule by matching the Name field. It returns nil if the rule was not found.
func (*QueryRules) UnmarshalJSON ¶
func (qrs *QueryRules) UnmarshalJSON(data []byte) (err error)
type QuerySplitter ¶
type QuerySplitter struct {
// contains filtered or unexported fields
}
QuerySplitter splits a BoundQuery into equally sized smaller queries. QuerySplits are generated by adding primary key range clauses to the original query. Only a limited set of queries are supported, see QuerySplitter.validateQuery() for details. Also, the table must have at least one primary key and the leading primary key must be numeric, see QuerySplitter.getSplitBoundaries()
func NewQuerySplitter ¶
func NewQuerySplitter(query *proto.BoundQuery, splitCount int, schemaInfo *SchemaInfo) *QuerySplitter
NewQuerySplitter creates a new QuerySplitter. query is the original query to split and splitCount is the desired number of splits. splitCount must be a positive int, if not it will be set to 1.
type RequestContext ¶
type RequestContext struct {
// contains filtered or unexported fields
}
type Result ¶
type Result struct { Result *proto.QueryResult Err error // contains filtered or unexported fields }
Result is a wrapper for QueryResult of a query.
type RowCache ¶
type RowCache struct {
// contains filtered or unexported fields
}
func NewRowCache ¶
type RowCacheConfig ¶
type RowCacheConfig struct { Binary string Memory int Socket string TcpPort int Connections int Threads int LockPaged bool }
func (*RowCacheConfig) GetSubprocessFlags ¶
func (c *RowCacheConfig) GetSubprocessFlags() []string
type RowcacheInvalidator ¶
type RowcacheInvalidator struct {
// contains filtered or unexported fields
}
RowcacheInvalidator runs the service to invalidate the rowcache based on binlog events.
func NewRowcacheInvalidator ¶
func NewRowcacheInvalidator(qe *QueryEngine) *RowcacheInvalidator
NewRowcacheInvalidator creates a new RowcacheInvalidator. Just like QueryEngine, this is a singleton class. You must call this only once.
func (*RowcacheInvalidator) AppendGTID ¶
func (rci *RowcacheInvalidator) AppendGTID(gtid myproto.GTID)
AppendGTID updates the current replication position by appending a GTID to the set of transactions that have been processed.
func (*RowcacheInvalidator) Close ¶
func (rci *RowcacheInvalidator) Close()
Close terminates the invalidation loop. It returns only of the loop has terminated.
func (*RowcacheInvalidator) Open ¶
func (rci *RowcacheInvalidator) Open(dbname string, mysqld *mysqlctl.Mysqld)
Open runs the invalidation loop.
func (*RowcacheInvalidator) Position ¶
func (rci *RowcacheInvalidator) Position() myproto.ReplicationPosition
Position returns the current ReplicationPosition.
func (*RowcacheInvalidator) PositionString ¶
func (rci *RowcacheInvalidator) PositionString() string
PositionString returns the current ReplicationPosition as a string.
func (*RowcacheInvalidator) SetPosition ¶
func (rci *RowcacheInvalidator) SetPosition(rp myproto.ReplicationPosition)
SetPosition sets the current ReplicationPosition.
type SQLQueryStats ¶
type SQLQueryStats struct { Method string PlanType string OriginalSql string BindVariables map[string]interface{} RowsAffected int NumberOfQueries int StartTime time.Time EndTime time.Time MysqlResponseTime time.Duration WaitingForConnection time.Duration CacheHits int64 CacheAbsent int64 CacheMisses int64 CacheInvalidations int64 QuerySources byte Rows [][]sqltypes.Value TransactionID int64 // contains filtered or unexported fields }
func (*SQLQueryStats) AddRewrittenSql ¶
func (stats *SQLQueryStats) AddRewrittenSql(sql string, start time.Time)
func (*SQLQueryStats) ContextHTML ¶
func (log *SQLQueryStats) ContextHTML() template.HTML
func (*SQLQueryStats) FmtBindVariables ¶
func (stats *SQLQueryStats) FmtBindVariables(full bool) string
FmtBindVariables returns the map of bind variables as JSON. For values that are strings or byte slices it only reports their type and length.
func (*SQLQueryStats) FmtQuerySources ¶
func (stats *SQLQueryStats) FmtQuerySources() string
FmtQuerySources returns a comma separated list of query sources. If there were no query sources, it returns the string "none".
func (*SQLQueryStats) Format ¶
func (log *SQLQueryStats) Format(params url.Values) string
String returns a tab separated list of logged fields.
func (*SQLQueryStats) RemoteAddr ¶
func (log *SQLQueryStats) RemoteAddr() string
func (*SQLQueryStats) RewrittenSql ¶
func (stats *SQLQueryStats) RewrittenSql() string
RewrittenSql returns a semicolon separated list of SQL statements that were executed.
func (*SQLQueryStats) Send ¶
func (stats *SQLQueryStats) Send()
func (*SQLQueryStats) SizeOfResponse ¶
func (stats *SQLQueryStats) SizeOfResponse() int
SizeOfResponse returns the approximate size of the response in bytes (this does not take in account BSON encoding). It will return 0 for streaming requests.
func (*SQLQueryStats) TotalTime ¶
func (stats *SQLQueryStats) TotalTime() time.Duration
func (*SQLQueryStats) Username ¶
func (log *SQLQueryStats) Username() string
type SchemaInfo ¶
type SchemaInfo struct {
// contains filtered or unexported fields
}
func NewSchemaInfo ¶
func (*SchemaInfo) Close ¶
func (si *SchemaInfo) Close()
func (*SchemaInfo) CreateOrUpdateTable ¶
func (si *SchemaInfo) CreateOrUpdateTable(tableName string)
func (*SchemaInfo) DropTable ¶
func (si *SchemaInfo) DropTable(tableName string)
func (*SchemaInfo) GetPlan ¶
func (si *SchemaInfo) GetPlan(logStats *SQLQueryStats, sql string) *ExecPlan
func (*SchemaInfo) GetRules ¶
func (si *SchemaInfo) GetRules() (qrs *QueryRules)
func (*SchemaInfo) GetSchema ¶
func (si *SchemaInfo) GetSchema() []*schema.Table
func (*SchemaInfo) GetStreamPlan ¶
func (si *SchemaInfo) GetStreamPlan(sql string) *ExecPlan
GetStreamPlan is similar to GetPlan, but doesn't use the cache and doesn't enforce a limit. It just returns the parsed query.
func (*SchemaInfo) GetTable ¶
func (si *SchemaInfo) GetTable(tableName string) *TableInfo
func (*SchemaInfo) Open ¶
func (si *SchemaInfo) Open(connFactory dbconnpool.CreateConnectionFunc, schemaOverrides []SchemaOverride, cachePool *CachePool, qrs *QueryRules, strictMode bool)
func (*SchemaInfo) Reload ¶
func (si *SchemaInfo) Reload()
func (*SchemaInfo) ServeHTTP ¶
func (si *SchemaInfo) ServeHTTP(response http.ResponseWriter, request *http.Request)
func (*SchemaInfo) SetQueryCacheSize ¶
func (si *SchemaInfo) SetQueryCacheSize(size int)
func (*SchemaInfo) SetReloadTime ¶
func (si *SchemaInfo) SetReloadTime(reloadTime time.Duration)
func (*SchemaInfo) SetRules ¶
func (si *SchemaInfo) SetRules(qrs *QueryRules)
type SchemaOverride ¶
type SqlQuery ¶
type SqlQuery struct {
// contains filtered or unexported fields
}
SqlQuery implements the RPC interface for the query service.
var SqlQueryRpcService *SqlQuery
func NewSqlQuery ¶
NewSqlQuery creates an instance of SqlQuery. Only one instance of SqlQuery can be created per process.
func (*SqlQuery) Begin ¶
func (sq *SqlQuery) Begin(context context.Context, session *proto.Session, txInfo *proto.TransactionInfo) (err error)
Begin starts a new transaction. This is allowed only if the state is SERVING.
func (*SqlQuery) Execute ¶
func (sq *SqlQuery) Execute(context context.Context, query *proto.Query, reply *mproto.QueryResult) (err error)
Execute executes the query and returns the result as response.
func (*SqlQuery) ExecuteBatch ¶
func (sq *SqlQuery) ExecuteBatch(context context.Context, queryList *proto.QueryList, reply *proto.QueryResultList) (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 also begin its own transaction, in which case it's expected to commit it also.
func (*SqlQuery) GetSessionId ¶
func (sq *SqlQuery) GetSessionId(sessionParams *proto.SessionParams, sessionInfo *proto.SessionInfo) error
GetSessionId returns a sessionInfo response if the state is SERVING.
func (*SqlQuery) SplitQuery ¶
func (sq *SqlQuery) SplitQuery(context context.Context, req *proto.SplitQueryRequest, reply *proto.SplitQueryResult) error
SplitQuery splits a BoundQuery into smaller queries that return a subset of rows from the original query.
func (*SqlQuery) StreamExecute ¶
func (sq *SqlQuery) StreamExecute(context context.Context, query *proto.Query, sendReply func(*mproto.QueryResult) 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).
type SqlQueryRegisterFunction ¶
type SqlQueryRegisterFunction func(*SqlQuery)
type TableInfo ¶
func NewTableInfo ¶
func NewTableInfo(conn dbconnpool.PoolConnection, tableName string, tableType string, createTime sqltypes.Value, comment string, cachePool *CachePool) (ti *TableInfo, err error)
type TabletError ¶
func NewTabletError ¶
func NewTabletError(errorType int, format string, args ...interface{}) *TabletError
func NewTabletErrorSql ¶
func NewTabletErrorSql(errorType int, err error) *TabletError
func (*TabletError) Error ¶
func (te *TabletError) Error() string
func (*TabletError) RecordStats ¶
func (te *TabletError) RecordStats()
type TxConnection ¶
type TxConnection struct { dbconnpool.PoolConnection TransactionID int64 StartTime time.Time EndTime time.Time Queries []string Conclusion string LogToFile sync2.AtomicInt32 // contains filtered or unexported fields }
func (*TxConnection) DirtyKeys ¶
func (txc *TxConnection) DirtyKeys(tableName string) DirtyKeys
func (*TxConnection) RecordQuery ¶
func (txc *TxConnection) RecordQuery(query string)
func (*TxConnection) Recycle ¶
func (txc *TxConnection) Recycle()
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
func (*TxPool) Get ¶
func (axp *TxPool) Get(transactionId int64) (conn *TxConnection)
You must call Recycle on TxConnection once done.
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(connFactory dbconnpool.CreateConnectionFunc)
func (*TxPool) SafeCommit ¶
func (*TxPool) SetPoolTimeout ¶
func (*TxPool) SetTimeout ¶
func (*TxPool) TransactionKiller ¶
func (axp *TxPool) TransactionKiller()
func (*TxPool) WaitForEmpty ¶
func (axp *TxPool) WaitForEmpty()
Source Files ¶
- cache_pool.go
- codex.go
- comments.go
- connection_killer.go
- consolidator.go
- deadline.go
- logzcss.go
- memcache_stats.go
- query_engine.go
- query_executor.go
- query_list.go
- query_rules.go
- query_splitter.go
- queryctl.go
- querylogz.go
- queryz.go
- request_context.go
- rowcache.go
- rowcache_invalidator.go
- schema_info.go
- schemaz.go
- sqlquery.go
- status.go
- stream_queryz.go
- streamlogger.go
- table_info.go
- tablet_error.go
- transaction.go
- tx_pool.go
- txlogz.go