Documentation
¶
Index ¶
- Constants
- type SQLKiller
- func (killer *SQLKiller) ClearFinishFunc()
- func (killer *SQLKiller) FinishResultSet()
- func (killer *SQLKiller) GetKillEventChan() <-chan struct{}
- func (killer *SQLKiller) GetKillSignal() killSignal
- func (killer *SQLKiller) HandleSignal() error
- func (killer *SQLKiller) Reset()
- func (killer *SQLKiller) SendKillSignal(reason killSignal)
- func (killer *SQLKiller) SendKillSignalWithKillEventReason(killSignal killSignal, desc string)
- func (killer *SQLKiller) SetFinishFunc(fn func())
Constants ¶
const ( UnspecifiedKillSignal killSignal = iota QueryInterrupted MaxExecTimeExceeded QueryMemoryExceeded ServerMemoryExceeded RunawayQueryExceeded KilledByMemArbitrator )
KillSignal types.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SQLKiller ¶
type SQLKiller struct {
Finish func()
ConnID atomic.Uint64
// FinishFuncLock is used to ensure that Finish is not called and modified at the same time.
// An external call to the Finish function only allows when the main goroutine to be in the writeResultSet process.
// When the main goroutine exits the writeResultSet process, the Finish function will be cleared.
FinishFuncLock sync.Mutex
Signal killSignal
// InWriteResultSet is used to indicate whether the query is currently calling clientConn.writeResultSet().
// If the query is in writeResultSet and Finish() can acquire rs.finishLock, we can assume the query is waiting for the client to receive data from the server over network I/O.
InWriteResultSet atomic.Bool
IsConnectionAlive atomic.Pointer[func() bool]
// contains filtered or unexported fields
}
SQLKiller is used to kill a query.
func (*SQLKiller) ClearFinishFunc ¶
func (killer *SQLKiller) ClearFinishFunc()
ClearFinishFunc clears the finish function.1
func (*SQLKiller) FinishResultSet ¶
func (killer *SQLKiller) FinishResultSet()
FinishResultSet is used to close the result set. If a kill signal is sent but the SQL query is stuck in the network stack while writing packets to the client, encountering some bugs that cause it to hang, or failing to detect the kill signal, we can call Finish to release resources used during the SQL execution process.
func (*SQLKiller) GetKillEventChan ¶
func (killer *SQLKiller) GetKillEventChan() <-chan struct{}
GetKillEventChan returns a recv chan which will be closed when the kill signal is sent.
func (*SQLKiller) GetKillSignal ¶
func (killer *SQLKiller) GetKillSignal() killSignal
GetKillSignal gets the kill signal.
func (*SQLKiller) HandleSignal ¶
HandleSignal handles the kill signal and return the error.
func (*SQLKiller) SendKillSignal ¶
func (killer *SQLKiller) SendKillSignal(reason killSignal)
SendKillSignal sends a kill signal to the query.
func (*SQLKiller) SendKillSignalWithKillEventReason ¶
SendKillSignalWithKillEventReason sets the reason for the kill event and sends a kill signal.
func (*SQLKiller) SetFinishFunc ¶
func (killer *SQLKiller) SetFinishFunc(fn func())
SetFinishFunc sets the finish function.