sqlkiller

package
v1.1.0-beta.0...-8106d93 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnspecifiedKillSignal killSignal = iota
	QueryInterrupted
	MaxExecTimeExceeded
	QueryMemoryExceeded
	ServerMemoryExceeded
	RunawayQueryExceeded
)

KillSignal types.

Variables

This section is empty.

Functions

This section is empty.

Types

type SQLKiller

type SQLKiller struct {
	Signal killSignal
	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
	Finish         func()
	// 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
}

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) GetKillSignal

func (killer *SQLKiller) GetKillSignal() killSignal

GetKillSignal gets the kill signal.

func (*SQLKiller) HandleSignal

func (killer *SQLKiller) HandleSignal() error

HandleSignal handles the kill signal and return the error.

func (*SQLKiller) Reset

func (killer *SQLKiller) Reset()

Reset resets the SqlKiller.

func (*SQLKiller) SendKillSignal

func (killer *SQLKiller) SendKillSignal(reason killSignal)

SendKillSignal sends a kill signal to the query.

func (*SQLKiller) SetFinishFunc

func (killer *SQLKiller) SetFinishFunc(fn func())

SetFinishFunc sets the finish function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL