Documentation ¶
Index ¶
- Variables
- type DBConn
- func (dbc *DBConn) ApplySetting(ctx context.Context, setting *pools.Setting) error
- func (dbc *DBConn) BaseShowTables() string
- func (dbc *DBConn) BaseShowTablesWithSizes() string
- func (dbc *DBConn) Close()
- func (dbc *DBConn) Current() string
- func (dbc *DBConn) CurrentForLogging() string
- func (dbc *DBConn) Err() error
- func (dbc *DBConn) Exec(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
- func (dbc *DBConn) ExecOnce(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
- func (dbc *DBConn) Expired(lifetimeTimeout time.Duration) bool
- func (dbc *DBConn) FetchNext(ctx context.Context, maxrows int, wantfields bool) (*sqltypes.Result, error)
- func (dbc *DBConn) ID() int64
- func (dbc *DBConn) IsClosed() bool
- func (dbc *DBConn) IsSameSetting(setting string) bool
- func (dbc *DBConn) IsSettingApplied() bool
- func (dbc *DBConn) Kill(reason string, elapsed time.Duration) error
- func (dbc *DBConn) Recycle()
- func (dbc *DBConn) ResetSetting(ctx context.Context) error
- func (dbc *DBConn) Stream(ctx context.Context, query string, callback func(*sqltypes.Result) error, ...) error
- func (dbc *DBConn) StreamOnce(ctx context.Context, query string, callback func(*sqltypes.Result) error, ...) error
- func (dbc *DBConn) Taint()
- func (dbc *DBConn) VerifyMode(strictTransTables bool) error
- type Pool
- func (cp *Pool) Active() int64
- func (cp *Pool) Available() int64
- func (cp *Pool) Capacity() int64
- func (cp *Pool) Close()
- func (cp *Pool) DiffSettingCount() int64
- func (cp *Pool) Exhausted() int64
- func (cp *Pool) Get(ctx context.Context, setting *pools.Setting) (*DBConn, error)
- func (cp *Pool) GetCount() int64
- func (cp *Pool) GetSettingCount() int64
- func (cp *Pool) IdleClosed() int64
- func (cp *Pool) IdleTimeout() time.Duration
- func (cp *Pool) InUse() int64
- func (cp *Pool) MaxCap() int64
- func (cp *Pool) MaxLifetimeClosed() int64
- func (cp *Pool) Open(appParams, dbaParams, appDebugParams dbconfigs.Connector)
- func (cp *Pool) Put(conn *DBConn)
- func (cp *Pool) ResetSettingCount() int64
- func (cp *Pool) SetCapacity(capacity int) (err error)
- func (cp *Pool) SetIdleTimeout(idleTimeout time.Duration)
- func (cp *Pool) StatsJSON() string
- func (cp *Pool) WaitCount() int64
- func (cp *Pool) WaitTime() time.Duration
Constants ¶
This section is empty.
Variables ¶
var ErrConnPoolClosed = vterrors.New(vtrpcpb.Code_INTERNAL, "internal error: unexpected: conn pool is closed")
ErrConnPoolClosed is returned when the connection pool is closed.
Functions ¶
This section is empty.
Types ¶
type DBConn ¶
type DBConn struct {
// contains filtered or unexported fields
}
DBConn is a db connection for tabletserver. It performs automatic reconnects as needed. Its Execute function has a timeout that can kill its own queries and the underlying connection. It will also trigger a CheckMySQL whenever applicable.
func NewDBConnNoPool ¶
func NewDBConnNoPool(ctx context.Context, params dbconfigs.Connector, dbaPool *dbconnpool.ConnectionPool, setting *pools.Setting) (*DBConn, error)
NewDBConnNoPool creates a new DBConn without a pool.
func (*DBConn) ApplySetting ¶ added in v0.15.0
ApplySetting implements the pools.Resource interface.
func (*DBConn) BaseShowTables ¶ added in v0.10.0
BaseShowTables returns a query that shows tables
func (*DBConn) BaseShowTablesWithSizes ¶ added in v0.16.0
BaseShowTablesWithSizes returns a query that shows tables and their sizes
func (*DBConn) CurrentForLogging ¶ added in v0.13.0
CurrentForLogging applies transformations to the query making it suitable to log. It applies sanitization rules based on tablet settings and limits the max length of queries.
func (*DBConn) Err ¶ added in v0.9.0
Err returns an error if there was a client initiated error like a query kill.
func (*DBConn) Exec ¶
func (dbc *DBConn) Exec(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
Exec executes the specified query. If there is a connection error, it will reconnect and retry. A failed reconnect will trigger a CheckMySQL.
func (*DBConn) ExecOnce ¶
func (dbc *DBConn) ExecOnce(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
ExecOnce executes the specified query, but does not retry on connection errors.
func (*DBConn) Expired ¶ added in v0.16.0
Expired returns whether a connection has passed its lifetime
func (*DBConn) FetchNext ¶ added in v0.10.0
func (dbc *DBConn) FetchNext(ctx context.Context, maxrows int, wantfields bool) (*sqltypes.Result, error)
FetchNext returns the next result set.
func (*DBConn) IsSameSetting ¶ added in v0.15.0
IsSameSetting implements the pools.Resource interface.
func (*DBConn) IsSettingApplied ¶ added in v0.15.0
IsSettingApplied implements the pools.Resource interface.
func (*DBConn) Kill ¶
Kill kills the currently executing query both on MySQL side and on the connection side. If no query is executing, it's a no-op. Kill will also not kill a query more than once.
func (*DBConn) ResetSetting ¶ added in v0.15.0
ResetSetting implements the pools.Resource interface.
func (*DBConn) Stream ¶
func (dbc *DBConn) Stream(ctx context.Context, query string, callback func(*sqltypes.Result) error, alloc func() *sqltypes.Result, streamBufferSize int, includedFields querypb.ExecuteOptions_IncludedFields) error
Stream executes the query and streams the results.
func (*DBConn) StreamOnce ¶ added in v0.15.0
func (dbc *DBConn) StreamOnce(ctx context.Context, query string, callback func(*sqltypes.Result) error, alloc func() *sqltypes.Result, streamBufferSize int, includedFields querypb.ExecuteOptions_IncludedFields) error
StreamOnce executes the query and streams the results. But, does not retry on connection errors.
func (*DBConn) Taint ¶
func (dbc *DBConn) Taint()
Taint unregister connection from original pool and taints the connection.
func (*DBConn) VerifyMode ¶
VerifyMode is a helper method to verify mysql is running with sql_mode = STRICT_TRANS_TABLES or STRICT_ALL_TABLES and autocommit=ON.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool implements a custom connection pool for tabletserver. It's similar to dbconnpool.ConnPool, but the connections it creates come with built-in ability to kill in-flight queries. These connections also trigger a CheckMySQL call if we fail to connect to MySQL. Other than the connection type, ConnPool maintains an additional pool of dba connections that are used to kill connections.
func (*Pool) Close ¶
func (cp *Pool) Close()
Close will close the pool and wait for connections to be returned before exiting.
func (*Pool) DiffSettingCount ¶ added in v0.15.0
DiffSettingCount returns the number of times different settings were applied on the resource.
func (*Pool) GetSettingCount ¶ added in v0.15.0
GetSettingCount returns the number of times getWithSettings was called
func (*Pool) IdleClosed ¶
IdleClosed returns the number of closed connections for the pool.
func (*Pool) IdleTimeout ¶
IdleTimeout returns the idle timeout for the pool.
func (*Pool) MaxLifetimeClosed ¶ added in v0.16.0
MaxLifetimeClosed returns the number of connections closed to refresh timeout for the pool.
func (*Pool) ResetSettingCount ¶ added in v0.15.0
ResetSettingCount returns the number of times settings were reset on the resource.
func (*Pool) SetCapacity ¶
SetCapacity alters the size of the pool at runtime.
func (*Pool) SetIdleTimeout ¶
SetIdleTimeout sets the idleTimeout on the pool.