Documentation ¶
Index ¶
- func MockBackendConfigAttach(name, addr string) *config.BackendConfig
- func MockBackendConfigDefault(name, addr string) *config.BackendConfig
- func MockBackendConfigReplica(name, addr, replica string) *config.BackendConfig
- func MockScatterDefault(log *xlog.Log) *config.ScatterConfig
- func MockScatterDefault2(dir string) *config.ScatterConfig
- func MockTxnMgrScatter(log *xlog.Log, n int) (*fakedb.DB, *TxnManager, map[string]*Poolz, []string, *Scatter, func())
- type Connection
- type Pool
- type Poolz
- type QueryDetail
- type QueryDetailzRow
- type Queryz
- type Scatter
- func (scatter *Scatter) Add(config *config.BackendConfig) error
- func (scatter *Scatter) AllBackends() []string
- func (scatter *Scatter) BackendConfigsClone() []*config.BackendConfig
- func (scatter *Scatter) Backends() []string
- func (scatter *Scatter) CheckBackend(backenName string) bool
- func (scatter *Scatter) Close()
- func (scatter *Scatter) CreateTransaction() (*Txn, error)
- func (scatter *Scatter) FlushConfig() error
- func (scatter *Scatter) Init(scatterConf *config.ScatterConfig) error
- func (scatter *Scatter) LoadConfig() error
- func (scatter *Scatter) MySQLStats() *stats.Timings
- func (scatter *Scatter) PoolzClone() map[string]*Poolz
- func (scatter *Scatter) QueryRates() *stats.Rates
- func (scatter *Scatter) QueryStats() *stats.Timings
- func (scatter *Scatter) Queryz() *Queryz
- func (scatter *Scatter) Remove(config *config.BackendConfig) error
- func (scatter *Scatter) TxnCounters() *stats.Counters
- func (scatter *Scatter) Txnz() *Txnz
- type Transaction
- type Txn
- func (txn *Txn) Abort() error
- func (txn *Txn) Begin() error
- func (txn *Txn) BeginScatter() error
- func (txn *Txn) Commit() error
- func (txn *Txn) CommitScatter() error
- func (txn *Txn) Execute(req *xcontext.RequestContext) (*sqltypes.Result, error)
- func (txn *Txn) ExecuteOnThisBackend(backend string, query string) (*sqltypes.Result, error)
- func (txn *Txn) ExecuteRaw(database string, query string) (*sqltypes.Result, error)
- func (txn *Txn) ExecuteScatter(query string) (*sqltypes.Result, error)
- func (txn *Txn) ExecuteSingle(query string) (*sqltypes.Result, error)
- func (txn *Txn) ExecuteStreamFetch(req *xcontext.RequestContext, callback func(*sqltypes.Result) error, ...) error
- func (txn *Txn) Finish() error
- func (txn *Txn) MaxJoinRows() int
- func (txn *Txn) Rollback() error
- func (txn *Txn) RollbackPhaseOne() error
- func (txn *Txn) RollbackScatter() error
- func (txn *Txn) SetIsExecOnRep(isExecOnRep bool)
- func (txn *Txn) SetMaxJoinRows(max int)
- func (txn *Txn) SetMaxResult(max int)
- func (txn *Txn) SetMultiStmtTxn()
- func (txn *Txn) SetSessionID(id uint32)
- func (txn *Txn) SetTimeout(timeout int)
- func (txn *Txn) State() int32
- func (txn *Txn) TxID() uint64
- func (txn *Txn) WriteXaCommitErrLog(state string) error
- func (txn *Txn) XID() string
- func (txn *Txn) XaState() int32
- type TxnDetail
- type TxnDetailzRow
- type TxnManager
- func MockTxnMgr(log *xlog.Log, n int) (*fakedb.DB, *TxnManager, map[string]*Poolz, []string, func())
- func MockTxnMgrWithAttach(log *xlog.Log, n int) (*fakedb.DB, *TxnManager, map[string]*Poolz, []string, func())
- func MockTxnMgrWithReplica(log *xlog.Log, n int) (*fakedb.DB, *TxnManager, map[string]*Poolz, []string, func())
- func NewTxnManager(log *xlog.Log) *TxnManager
- func (mgr *TxnManager) Add() error
- func (mgr *TxnManager) Close()
- func (mgr *TxnManager) CommitLock()
- func (mgr *TxnManager) CommitRLock()
- func (mgr *TxnManager) CommitRUnlock()
- func (mgr *TxnManager) CommitUnlock()
- func (mgr *TxnManager) CreateTxn(backends map[string]*Poolz) (*Txn, error)
- func (mgr *TxnManager) GetID() uint64
- func (mgr *TxnManager) Init(scatter *Scatter, ScatterConf *config.ScatterConfig) error
- func (mgr *TxnManager) Remove() error
- type Txnz
- type XaCheck
- func (xc *XaCheck) Close()
- func (xc *XaCheck) GetRetrysLen() int
- func (xc *XaCheck) GetXaCheckFile() string
- func (xc *XaCheck) Init() error
- func (xc *XaCheck) LoadXaCommitErrLogs() error
- func (xc *XaCheck) ReadXaCommitErrLogs(data string) (*XaCommitErrs, error)
- func (xc *XaCheck) RemoveXaCommitErrLogs() error
- func (xc *XaCheck) WriteXaCommitErrLog(txn *Txn, state string) error
- type XaCommitErr
- type XaCommitErrs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MockBackendConfigAttach ¶
func MockBackendConfigAttach(name, addr string) *config.BackendConfig
MockBackendConfigAttach mocks new attach backend config.
func MockBackendConfigDefault ¶
func MockBackendConfigDefault(name, addr string) *config.BackendConfig
MockBackendConfigDefault mocks new normal backend config.
func MockBackendConfigReplica ¶
func MockBackendConfigReplica(name, addr, replica string) *config.BackendConfig
MockBackendConfigReplica mocks new backend config with replica.
func MockScatterDefault ¶
func MockScatterDefault(log *xlog.Log) *config.ScatterConfig
MockScatterDefault mocks new xacheck config.
func MockScatterDefault2 ¶
func MockScatterDefault2(dir string) *config.ScatterConfig
MockScatterDefault2 mocks new xacheck config with dir.
Types ¶
type Connection ¶
type Connection interface { ID() uint32 Dial() error Ping() error Close() Closed() bool LastErr() error UseDB(string) error Kill(string) error Recycle() Address() string SetTimestamp(int64) Timestamp() int64 Execute(string) (*sqltypes.Result, error) ExecuteStreamFetch(string) (driver.Rows, error) ExecuteWithLimits(query string, timeout int, maxmem int) (*sqltypes.Result, error) }
Connection tuple.
func MockClient ¶
func MockClient(log *xlog.Log, addr string) (Connection, func())
MockClient mocks a client connection.
func MockClientWithConfig ¶
func MockClientWithConfig(log *xlog.Log, conf *config.BackendConfig) (Connection, func())
MockClientWithConfig mocks a client with backendconfig.
func NewConnection ¶
func NewConnection(log *xlog.Log, pool *Pool) Connection
NewConnection creates a new connection.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool tuple.
func (*Pool) Get ¶
func (p *Pool) Get() (Connection, error)
Get used to get a connection from the pool.
type Poolz ¶
type Poolz struct {
// contains filtered or unexported fields
}
Poolz ... Add replica and normal pool to distribute SQL between read and write in some cases for load-balance.
type QueryDetail ¶
type QueryDetail struct { ID uint64 // contains filtered or unexported fields }
QueryDetail is a simple wrapper for Query
func NewQueryDetail ¶
func NewQueryDetail(conn Connection, query string) *QueryDetail
NewQueryDetail creates a new QueryDetail
type QueryDetailzRow ¶
type QueryDetailzRow struct { Start time.Time Duration time.Duration ConnID uint32 Query string Address string Color string }
QueryDetailzRow is used for rendering QueryDetail in a template
type Queryz ¶
type Queryz struct { ID uint64 // contains filtered or unexported fields }
Queryz holds a thread safe list of QueryDetails
func (*Queryz) GetQueryzRows ¶
func (qz *Queryz) GetQueryzRows() byStartTime
GetQueryzRows returns a list of QueryDetailzRow sorted by start time
func (*Queryz) Remove ¶
func (qz *Queryz) Remove(qd *QueryDetail)
Remove removes a QueryDetail from Queryz
type Scatter ¶
type Scatter struct {
// contains filtered or unexported fields
}
Scatter tuple.
func MockScatter ¶
MockScatter used to mock a scatter.
func NewScatter ¶
NewScatter creates a new scatter.
func (*Scatter) Add ¶
func (scatter *Scatter) Add(config *config.BackendConfig) error
Add used to add a new backend to scatter.
func (*Scatter) AllBackends ¶
AllBackends returns all backends.
func (*Scatter) BackendConfigsClone ¶
func (scatter *Scatter) BackendConfigsClone() []*config.BackendConfig
BackendConfigsClone used to clone all the backend configs.
func (*Scatter) CheckBackend ¶
func (*Scatter) CreateTransaction ¶
CreateTransaction used to create a transaction.
func (*Scatter) FlushConfig ¶
FlushConfig used to write the backends to file.
func (*Scatter) Init ¶
func (scatter *Scatter) Init(scatterConf *config.ScatterConfig) error
Init is used to init the xaCheck and start the xaCheck thread.
func (*Scatter) LoadConfig ¶
LoadConfig used to load all backends from metadir/backend.json file.
func (*Scatter) MySQLStats ¶
MySQLStats returns the mysql stats.
func (*Scatter) PoolzClone ¶
PoolzClone used to copy backends to new map.
func (*Scatter) QueryRates ¶
QueryRates returns the query rates.
func (*Scatter) QueryStats ¶
QueryStats returns the query stats.
func (*Scatter) Remove ¶
func (scatter *Scatter) Remove(config *config.BackendConfig) error
Remove used to remove a backend from the scatter.
func (*Scatter) TxnCounters ¶
TxnCounters returns the txn counters.
type Transaction ¶
type Transaction interface { XID() string TxID() uint64 State() int32 XaState() int32 Abort() error Begin() error Rollback() error Commit() error Finish() error BeginScatter() error CommitScatter() error RollbackScatter() error SetMultiStmtTxn() SetSessionID(id uint32) SetIsExecOnRep(isExecOnRep bool) SetTimeout(timeout int) SetMaxResult(max int) SetMaxJoinRows(max int) MaxJoinRows() int Execute(req *xcontext.RequestContext) (*sqltypes.Result, error) ExecuteRaw(database string, query string) (*sqltypes.Result, error) }
Transaction interface.
type Txn ¶
type Txn struct {
// contains filtered or unexported fields
}
Txn tuple.
func (*Txn) BeginScatter ¶
BeginScatter used to start a XA transaction in the multiple-statement transaction
func (*Txn) CommitScatter ¶
CommitScatter is used in the multiple-statement transaction
func (*Txn) Execute ¶
Execute used to execute the query. If the txn is in twopc mode, we do the xaStart before the real query execute.
func (*Txn) ExecuteOnThisBackend ¶
ExecuteOnThisBackend used to send the query to this backend.
func (*Txn) ExecuteRaw ¶
ExecuteRaw used to execute raw query, txn not implemented.
func (*Txn) ExecuteScatter ¶
ExecuteScatter used to execute query on all shards.
func (*Txn) ExecuteSingle ¶
ExecuteSingle used to execute query on one shard.
func (*Txn) ExecuteStreamFetch ¶
func (txn *Txn) ExecuteStreamFetch(req *xcontext.RequestContext, callback func(*sqltypes.Result) error, streamBufferSize int) error
ExecuteStreamFetch used to execute stream fetch query.
func (*Txn) Finish ¶
Finish used to finish a transaction. If the lastErr is nil, we will recycle all the twopc connections to the pool for reuse, otherwise we wil close all of the them.
func (*Txn) Rollback ¶
Rollback used to rollback a XA transaction. 1. XA END 2. XA PREPARE 3. XA ROLLBACK
func (*Txn) RollbackPhaseOne ¶
RollbackPhaseOne used to rollback when the SQL return error at the phase one. won't do `XA PREPARE` which will write log to binlog, especially when large Transactions happen. 1. XA END 2. XA ROLLBACK
func (*Txn) RollbackScatter ¶
RollbackScatter is used in the multiple-statement transaction
func (*Txn) SetIsExecOnRep ¶
SetIsExecOnRep used to set the txn isExecOnRep, true -- execute on the replica.
func (*Txn) SetMaxJoinRows ¶
SetMaxJoinRows used to set the txn max join rows.
func (*Txn) SetMaxResult ¶
SetMaxResult used to set the txn max result.
func (*Txn) SetSessionID ¶
SetSessionID -- bind the txn to session id, for debug.
func (*Txn) SetTimeout ¶
SetTimeout used to set the txn timeout.
func (*Txn) WriteXaCommitErrLog ¶
WriteXaCommitErrLog used to write the error xaid to the log.
type TxnDetail ¶
type TxnDetail struct {
// contains filtered or unexported fields
}
TxnDetail is a simple wrapper for Query
func NewTxnDetail ¶
func NewTxnDetail(txn Transaction) *TxnDetail
NewTxnDetail creates a new TxnDetail
type TxnDetailzRow ¶
type TxnDetailzRow struct { Start time.Time Duration time.Duration TxnID uint64 XAID string Query string State string XaState string Color string }
TxnDetailzRow is used for rendering TxnDetail in a template
type TxnManager ¶
type TxnManager struct {
// contains filtered or unexported fields
}
TxnManager tuple.
func MockTxnMgr ¶
func MockTxnMgr(log *xlog.Log, n int) (*fakedb.DB, *TxnManager, map[string]*Poolz, []string, func())
MockTxnMgr mocks txn manager.
func MockTxnMgrWithAttach ¶
func MockTxnMgrWithAttach(log *xlog.Log, n int) (*fakedb.DB, *TxnManager, map[string]*Poolz, []string, func())
MockTxnMgrWithAttach mocks txn manager with attach backend.
func MockTxnMgrWithReplica ¶
func MockTxnMgrWithReplica(log *xlog.Log, n int) (*fakedb.DB, *TxnManager, map[string]*Poolz, []string, func())
MockTxnMgrWithReplica mocks txn manager with replica-address.
func NewTxnManager ¶
func NewTxnManager(log *xlog.Log) *TxnManager
NewTxnManager creates new TxnManager.
func (*TxnManager) Close ¶
func (mgr *TxnManager) Close()
Close is used to close the async worker xaCheck.
func (*TxnManager) CommitLock ¶
func (mgr *TxnManager) CommitLock()
CommitLock used to acquire the commit.
func (*TxnManager) CommitRLock ¶
func (mgr *TxnManager) CommitRLock()
CommitRLock used to acquire the read lock of commit.
func (*TxnManager) CommitRUnlock ¶
func (mgr *TxnManager) CommitRUnlock()
CommitRUnlock used to release the read lock of commit.
func (*TxnManager) CommitUnlock ¶
func (mgr *TxnManager) CommitUnlock()
CommitUnlock used to release the commit.
func (*TxnManager) CreateTxn ¶
func (mgr *TxnManager) CreateTxn(backends map[string]*Poolz) (*Txn, error)
CreateTxn creates new txn.
func (*TxnManager) Init ¶
func (mgr *TxnManager) Init(scatter *Scatter, ScatterConf *config.ScatterConfig) error
Init is used to init the async worker xaCheck.
func (*TxnManager) Remove ¶
func (mgr *TxnManager) Remove() error
Remove used to remove a txn from mgr.
type Txnz ¶
type Txnz struct {
// contains filtered or unexported fields
}
Txnz holds a thread safe list of TxnDetails
func (*Txnz) GetTxnzRows ¶
func (tz *Txnz) GetTxnzRows() []TxnDetailzRow
GetTxnzRows returns a list of TxnDetailzRow sorted by start time
type XaCheck ¶
type XaCheck struct {
// contains filtered or unexported fields
}
XaCheck tuple.
func NewXaCheck ¶
func NewXaCheck(scatter *Scatter, conf *config.ScatterConfig) *XaCheck
NewXaCheck creates the XaCheck tuple.
func (*XaCheck) GetRetrysLen ¶
GetRetrysLen return the retrys num
func (*XaCheck) GetXaCheckFile ¶
GetXaCheckFile get the XaCheck log file
func (*XaCheck) LoadXaCommitErrLogs ¶
LoadXaCommitErrLogs is used to load all XaCommitErr from metadir/xacheck.json file.
func (*XaCheck) ReadXaCommitErrLogs ¶
func (xc *XaCheck) ReadXaCommitErrLogs(data string) (*XaCommitErrs, error)
ReadXaCommitErrLogs is used to read the Xaredologs config from the data.
func (*XaCheck) RemoveXaCommitErrLogs ¶
RemoveXaCommitErrLogs is only used to test to avoid the noise, XaCommitErrLogs can not be removed in the production environment, it is so important.
type XaCommitErr ¶
type XaCommitErr struct { Time string `json:"time"` Xaid string `json:"xaid"` State string `json:"state"` Times int `json:"times"` }
XaCommitErr tuple.
type XaCommitErrs ¶
type XaCommitErrs struct {
Logs []*XaCommitErr `json:"xacommit-errs"`
}
XaCommitErrs tuple