Documentation ¶
Overview ¶
Package tabletenv maintains environment variables and types that are common for all packages of tabletserver.
Index ¶
- Constants
- Variables
- func Init()
- func IsLocalContext(ctx context.Context) bool
- func LocalContext() context.Context
- func SecondsVar(p *Seconds, name string, value Seconds, usage string)
- type ConnPoolConfig
- type Env
- type GracePeriodsConfig
- type HealthcheckConfig
- type HotRowProtectionConfig
- type LogStats
- func (stats *LogStats) AddRewrittenSQL(sql string, start time.Time)
- func (stats *LogStats) CallInfo() (string, string)
- func (stats *LogStats) Context() context.Context
- func (stats *LogStats) ContextHTML() template.HTML
- func (stats *LogStats) EffectiveCaller() string
- func (stats *LogStats) ErrorStr() string
- func (stats *LogStats) EventTime() time.Time
- func (stats *LogStats) FmtQuerySources() string
- func (stats *LogStats) ImmediateCaller() string
- func (stats *LogStats) Logf(w io.Writer, params url.Values) error
- func (stats *LogStats) RewrittenSQL() string
- func (stats *LogStats) Send()
- func (stats *LogStats) SizeOfResponse() int
- func (stats *LogStats) TotalTime() time.Duration
- type OltpConfig
- type ReplicationTrackerConfig
- type Seconds
- type Stats
- type TabletConfig
- type TransactionLimitConfig
Constants ¶
const ( Enable = "enable" Disable = "disable" Dryrun = "dryRun" NotOnMaster = "notOnMaster" Polling = "polling" Heartbeat = "heartbeat" )
These constants represent values for various config parameters.
const ( // QuerySourceConsolidator means query result is found in consolidator. QuerySourceConsolidator = 1 << iota // QuerySourceMySQL means query result is returned from MySQL. QuerySourceMySQL )
Variables ¶
var ( // 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. TxLogger = streamlog.New("TxLog", 10) // StatsLogger is the main stream logger object StatsLogger = streamlog.New("TabletServer", 50) )
Functions ¶
func Init ¶
func Init()
Init must be called after flag.Parse, and before doing any other operations.
func IsLocalContext ¶
IsLocalContext returns true if the context is based on LocalContext.
func LocalContext ¶
LocalContext returns a context that's local to the process.
Types ¶
type ConnPoolConfig ¶
type ConnPoolConfig struct { Size int `json:"size,omitempty"` TimeoutSeconds Seconds `json:"timeoutSeconds,omitempty"` IdleTimeoutSeconds Seconds `json:"idleTimeoutSeconds,omitempty"` PrefillParallelism int `json:"prefillParallelism,omitempty"` MaxWaiters int `json:"maxWaiters,omitempty"` }
ConnPoolConfig contains the config for a conn pool.
type Env ¶
type Env interface { CheckMySQL() Config() *TabletConfig Exporter() *servenv.Exporter Stats() *Stats LogError() }
Env defines the functions supported by TabletServer that the sub-componennts need to access.
func NewEnv ¶
func NewEnv(config *TabletConfig, exporterName string) Env
NewEnv creates an Env that can be used for tabletserver subcomponents without an actual TabletServer.
type GracePeriodsConfig ¶
type GracePeriodsConfig struct { TransactionShutdownSeconds Seconds `json:"transactionShutdownSeconds,omitempty"` TransitionSeconds Seconds `json:"transitionSeconds,omitempty"` }
GracePeriodsConfig contains various grace periods. TODO(sougou): move lameduck here?
type HealthcheckConfig ¶
type HealthcheckConfig struct { IntervalSeconds Seconds `json:"intervalSeconds,omitempty"` DegradedThresholdSeconds Seconds `json:"degradedThresholdSeconds,omitempty"` UnhealthyThresholdSeconds Seconds `json:"unhealthyThresholdSeconds,omitempty"` }
HealthcheckConfig contains the config for healthcheck.
type HotRowProtectionConfig ¶
type HotRowProtectionConfig struct { // Mode can be disable, dryRun or enable. Default is disable. Mode string `json:"mode,omitempty"` MaxQueueSize int `json:"maxQueueSize,omitempty"` MaxGlobalQueueSize int `json:"maxGlobalQueueSize,omitempty"` MaxConcurrency int `json:"maxConcurrency,omitempty"` }
HotRowProtectionConfig contains the config for hot row protection.
type LogStats ¶
type LogStats struct { Ctx context.Context Method string Target *querypb.Target PlanType string OriginalSQL string BindVariables map[string]*querypb.BindVariable RowsAffected int NumberOfQueries int StartTime time.Time EndTime time.Time MysqlResponseTime time.Duration WaitingForConnection time.Duration QuerySources byte Rows [][]sqltypes.Value TransactionID int64 ReservedID int64 Error error // contains filtered or unexported fields }
LogStats records the stats for a single query
func NewLogStats ¶
NewLogStats constructs a new LogStats with supplied Method and ctx field values, and the StartTime field set to the present time.
func (*LogStats) AddRewrittenSQL ¶
AddRewrittenSQL adds a single sql statement to the rewritten list
func (*LogStats) ContextHTML ¶
ContextHTML returns the HTML version of the context that was used, or "". This is a method on LogStats instead of a field so that it doesn't need to be passed by value everywhere.
func (*LogStats) EffectiveCaller ¶
EffectiveCaller returns the effective caller stored in LogStats.Ctx
func (*LogStats) FmtQuerySources ¶
FmtQuerySources returns a comma separated list of query sources. If there were no query sources, it returns the string "none".
func (*LogStats) ImmediateCaller ¶
ImmediateCaller returns the immediate caller stored in LogStats.Ctx
func (*LogStats) Logf ¶
Logf formats the log record to the given writer, either as tab-separated list of logged fields or as JSON.
func (*LogStats) RewrittenSQL ¶
RewrittenSQL returns a semicolon separated list of SQL statements that were executed.
func (*LogStats) SizeOfResponse ¶
SizeOfResponse returns the approximate size of the response in bytes (this does not take in account protocol encoding). It will return 0 for streaming requests.
type OltpConfig ¶
type OltpConfig struct { QueryTimeoutSeconds Seconds `json:"queryTimeoutSeconds,omitempty"` TxTimeoutSeconds Seconds `json:"txTimeoutSeconds,omitempty"` MaxRows int `json:"maxRpws,omitempty"` WarnRows int `json:"warnRows,omitempty"` }
OltpConfig contains the config for oltp settings.
type ReplicationTrackerConfig ¶
type ReplicationTrackerConfig struct { // Mode can be disable, polling or heartbeat. Default is disable. Mode string `json:"mode,omitempty"` HeartbeatIntervalSeconds Seconds `json:"heartbeatIntervalSeconds,omitempty"` }
ReplicationTrackerConfig contains the config for the replication tracker.
type Seconds ¶
type Seconds float64
Seconds provides convenience functions for extracting duration from flaot64 seconds values.
type Stats ¶
type Stats struct { MySQLTimings *servenv.TimingsWrapper // Time spent executing MySQL commands QueryTimings *servenv.TimingsWrapper // Query timings QPSRates *stats.Rates // Human readable QPS rates WaitTimings *servenv.TimingsWrapper // waits like Consolidations etc KillCounters *stats.CountersWithSingleLabel // Connection and transaction kills ErrorCounters *stats.CountersWithSingleLabel InternalErrors *stats.CountersWithSingleLabel Warnings *stats.CountersWithSingleLabel Unresolved *stats.GaugesWithSingleLabel // For now, only Prepares are tracked UserTableQueryCount *stats.CountersWithMultiLabels // Per CallerID/table counts UserTableQueryTimesNs *stats.CountersWithMultiLabels // Per CallerID/table latencies UserTransactionCount *stats.CountersWithMultiLabels // Per CallerID transaction counts UserTransactionTimesNs *stats.CountersWithMultiLabels // Per CallerID transaction latencies ResultHistogram *stats.Histogram // Row count histograms TableaclAllowed *stats.CountersWithMultiLabels // Number of allows TableaclDenied *stats.CountersWithMultiLabels // Number of denials TableaclPseudoDenied *stats.CountersWithMultiLabels // Number of pseudo denials UserActiveReservedCount *stats.CountersWithSingleLabel // Per CallerID active reserved connection counts UserReservedCount *stats.CountersWithSingleLabel // Per CallerID reserved connection counts UserReservedTimesNs *stats.CountersWithSingleLabel // Per CallerID reserved connection duration }
Stats contains tracked by various parts of TabletServer.
type TabletConfig ¶
type TabletConfig struct { DB *dbconfigs.DBConfigs `json:"db,omitempty"` OltpReadPool ConnPoolConfig `json:"oltpReadPool,omitempty"` OlapReadPool ConnPoolConfig `json:"olapReadPool,omitempty"` TxPool ConnPoolConfig `json:"txPool,omitempty"` Oltp OltpConfig `json:"oltp,omitempty"` HotRowProtection HotRowProtectionConfig `json:"hotRowProtection,omitempty"` Healthcheck HealthcheckConfig `json:"healthcheck,omitempty"` GracePeriods GracePeriodsConfig `json:"gracePeriods,omitempty"` ReplicationTracker ReplicationTrackerConfig `json:"replicationTracker,omitempty"` // Consolidator can be enable, disable, or notOnMaster. Default is enable. Consolidator string `json:"consolidator,omitempty"` PassthroughDML bool `json:"passthroughDML,omitempty"` StreamBufferSize int `json:"streamBufferSize,omitempty"` QueryCacheSize int `json:"queryCacheSize,omitempty"` SchemaReloadIntervalSeconds Seconds `json:"schemaReloadIntervalSeconds,omitempty"` WatchReplication bool `json:"watchReplication,omitempty"` TrackSchemaVersions bool `json:"trackSchemaVersions,omitempty"` TerseErrors bool `json:"terseErrors,omitempty"` MessagePostponeParallelism int `json:"messagePostponeParallelism,omitempty"` CacheResultFields bool `json:"cacheResultFields,omitempty"` ExternalConnections map[string]*dbconfigs.DBConfigs `json:"externalConnections,omitempty"` StrictTableACL bool `json:"-"` EnableTableACLDryRun bool `json:"-"` TableACLExemptACL string `json:"-"` TwoPCEnable bool `json:"-"` TwoPCCoordinatorAddress string `json:"-"` TwoPCAbandonAge Seconds `json:"-"` EnableTxThrottler bool `json:"-"` TxThrottlerConfig string `json:"-"` TxThrottlerHealthCheckCells []string `json:"-"` EnableLagThrottler bool `json:"-"` TransactionLimitConfig `json:"-"` EnforceStrictTransTables bool `json:"-"` }
TabletConfig contains all the configuration for query service
func NewCurrentConfig ¶
func NewCurrentConfig() *TabletConfig
NewCurrentConfig returns a copy of the current config.
func NewDefaultConfig ¶
func NewDefaultConfig() *TabletConfig
NewDefaultConfig returns a new TabletConfig with pre-initialized defaults.
func (*TabletConfig) Clone ¶
func (c *TabletConfig) Clone() *TabletConfig
Clone creates a clone of TabletConfig.
func (*TabletConfig) Verify ¶
func (c *TabletConfig) Verify() error
Verify checks for contradicting flags.
type TransactionLimitConfig ¶
type TransactionLimitConfig struct { EnableTransactionLimit bool EnableTransactionLimitDryRun bool TransactionLimitPerUser float64 TransactionLimitByUsername bool TransactionLimitByPrincipal bool TransactionLimitByComponent bool TransactionLimitBySubcomponent bool }
TransactionLimitConfig captures configuration of transaction pool slots limiter configuration.