Documentation ¶
Index ¶
- type Conn
- func (dbc *Conn) ApplySetting(ctx context.Context, setting *smartconnpool.Setting) error
- func (dbc *Conn) BaseShowTables() string
- func (dbc *Conn) BaseShowTablesWithSizes() string
- func (dbc *Conn) Close()
- func (dbc *Conn) ConnCheck(ctx context.Context) error
- func (dbc *Conn) Current() string
- func (dbc *Conn) CurrentForLogging() string
- func (dbc *Conn) Err() error
- func (dbc *Conn) Exec(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
- func (dbc *Conn) ExecOnce(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
- func (dbc *Conn) FetchNext(ctx context.Context, maxrows int, wantfields bool) (*sqltypes.Result, error)
- func (dbc *Conn) ID() int64
- func (dbc *Conn) IsClosed() bool
- func (dbc *Conn) IsUnixSocket() bool
- func (dbc *Conn) Kill(reason string, elapsed time.Duration) error
- func (dbc *Conn) KillQuery(reason string, elapsed time.Duration) error
- func (dbc *Conn) Reconnect(ctx context.Context) error
- func (dbc *Conn) ResetSetting(ctx context.Context) error
- func (dbc *Conn) Setting() *smartconnpool.Setting
- func (dbc *Conn) Stream(ctx context.Context, query string, callback func(*sqltypes.Result) error, ...) error
- func (dbc *Conn) StreamOnce(ctx context.Context, query string, callback func(*sqltypes.Result) error, ...) error
- func (dbc *Conn) VerifyMode(strictTransTables bool) error
- type Pool
- type PooledConn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶ added in v0.19.0
type Conn struct {
// contains filtered or unexported fields
}
Conn 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 NewConn ¶ added in v0.19.0
func NewConn(ctx context.Context, params dbconfigs.Connector, dbaPool *dbconnpool.ConnectionPool, setting *smartconnpool.Setting, env tabletenv.Env) (*Conn, error)
NewConn creates a new Conn without a pool.
func (*Conn) ApplySetting ¶ added in v0.19.0
ApplySetting implements the pools.Resource interface.
func (*Conn) BaseShowTables ¶ added in v0.19.0
BaseShowTables returns a query that shows tables
func (*Conn) BaseShowTablesWithSizes ¶ added in v0.19.0
BaseShowTablesWithSizes returns a query that shows tables and their sizes
func (*Conn) CurrentForLogging ¶ added in v0.19.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 (*Conn) Err ¶ added in v0.19.0
Err returns an error if there was a client initiated error like a query kill and resets the error message on the connection.
func (*Conn) Exec ¶ added in v0.19.0
func (dbc *Conn) 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 (*Conn) ExecOnce ¶ added in v0.19.0
func (dbc *Conn) 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 (*Conn) FetchNext ¶ added in v0.19.0
func (dbc *Conn) FetchNext(ctx context.Context, maxrows int, wantfields bool) (*sqltypes.Result, error)
FetchNext returns the next result set.
func (*Conn) IsUnixSocket ¶ added in v0.21.0
func (*Conn) KillQuery ¶ added in v0.20.0
KillQuery executes a kill query statement to terminate the running query on the connection.
func (*Conn) ResetSetting ¶ added in v0.19.0
ResetSetting implements the pools.Resource interface.
func (*Conn) Setting ¶ added in v0.19.0
func (dbc *Conn) Setting() *smartconnpool.Setting
func (*Conn) Stream ¶ added in v0.19.0
func (dbc *Conn) 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 (*Conn) StreamOnce ¶ added in v0.19.0
func (dbc *Conn) 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 (*Conn) VerifyMode ¶ added in v0.19.0
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 { *smartconnpool.ConnPool[*Conn] // 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) Get ¶
func (cp *Pool) Get(ctx context.Context, setting *smartconnpool.Setting) (*PooledConn, error)
Get returns a connection. You must call Recycle on DBConn once done.
func (*Pool) SetIdleTimeout ¶
SetIdleTimeout sets the idleTimeout on the pool.
type PooledConn ¶ added in v0.19.0
type PooledConn = smartconnpool.Pooled[*Conn]