memoryusagealarm

package
v1.1.0-beta.0...-c8e1979 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlarmReason

type AlarmReason uint

AlarmReason implements alarm reason.

const (
	// GrowTooFast is the reason that memory increasing too fast.
	GrowTooFast AlarmReason = iota
	// ExceedAlarmRatio is the reason that memory used exceed threshold.
	ExceedAlarmRatio
	// NoReason means no alarm
	NoReason
)

func (AlarmReason) String

func (reason AlarmReason) String() string

type ConfigProvider

type ConfigProvider interface {
	// GetMemoryUsageAlarmRatio returns the ratio of memory usage that triggers an alarm
	GetMemoryUsageAlarmRatio() float64
	// GetMemoryUsageAlarmKeepRecordNum returns the number of alarm records to keep
	GetMemoryUsageAlarmKeepRecordNum() int64
	// GetLogDir returns the directory for storing logs
	GetLogDir() string
	// GetComponentName returns the name of the component (e.g. "tidb-server" or "br")
	GetComponentName() string
}

ConfigProvider provides memory usage alarm configuration values

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

Handle is the handler for memory usage alarm.

func NewMemoryUsageAlarmHandle

func NewMemoryUsageAlarmHandle(exitCh chan struct{}, provider ConfigProvider) *Handle

NewMemoryUsageAlarmHandle builds a memory usage alarm handler.

func (*Handle) Run

func (eqh *Handle) Run()

Run starts a memory usage alarm goroutine at the start time of the server.

func (*Handle) SetSessionManager

func (eqh *Handle) SetSessionManager(sm util.SessionManager) *Handle

SetSessionManager sets the SessionManager which is used to fetching the info of all active sessions.

type TiDBConfigProvider

type TiDBConfigProvider struct{}

TiDBConfigProvider implements ConfigProvider using TiDB's vardef variables

func (*TiDBConfigProvider) GetComponentName

func (*TiDBConfigProvider) GetComponentName() string

GetComponentName returns the name of the component for logging and metrics. This helps identify which component triggered the memory alarm.

func (*TiDBConfigProvider) GetLogDir

func (*TiDBConfigProvider) GetLogDir() string

GetLogDir returns the directory for storing memory profiles and alarm records.

func (*TiDBConfigProvider) GetMemoryUsageAlarmKeepRecordNum

func (*TiDBConfigProvider) GetMemoryUsageAlarmKeepRecordNum() int64

GetMemoryUsageAlarmKeepRecordNum returns the number of alarm records to keep. When the number of records exceeds this limit, older records will be deleted.

func (*TiDBConfigProvider) GetMemoryUsageAlarmRatio

func (*TiDBConfigProvider) GetMemoryUsageAlarmRatio() float64

GetMemoryUsageAlarmRatio returns the ratio of memory usage that triggers an alarm. When memory usage exceeds this ratio of the total memory limit (or system memory if no limit), the memory monitor will dump profiles and trigger OOM-related actions.

Jump to

Keyboard shortcuts

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