Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

use runtimeMemoryProfileThreshold

p0nyb68621e8c3de
diff --git a/backend/bin/server/cmd/root.go b/backend/bin/server/cmd/root.go
index c81ddbae67..b46db94316 100644
--- a/backend/bin/server/cmd/root.go
+++ b/backend/bin/server/cmd/root.go
@@ -77,7 +77,7 @@ var (
// disableSample is the flag to disable the sample instance.
disableSample bool
// memoryProfileThreshold is the threshold of memory usage in bytes to trigger a memory profile.
- memoryProfileThreshold int64
+ memoryProfileThreshold uint64
}
rootCmd = &cobra.Command{
@@ -117,7 +117,7 @@ func init() {
rootCmd.PersistentFlags().BoolVar(&flags.debug, "debug", false, "whether to enable debug level logging")
rootCmd.PersistentFlags().BoolVar(&flags.disableMetric, "disable-metric", false, "disable the metric collector")
rootCmd.PersistentFlags().BoolVar(&flags.disableSample, "disable-sample", false, "disable the sample instance")
- rootCmd.PersistentFlags().Int64Var(&flags.memoryProfileThreshold, "memory-profile-threshold", 0, "the threshold of memory usage in bytes to trigger a memory profile")
+ rootCmd.PersistentFlags().Uint64Var(&flags.memoryProfileThreshold, "memory-profile-threshold", 0, "the threshold of memory usage in bytes to trigger a memory profile")
}
// -----------------------------------Command Line Config END--------------------------------------
diff --git a/backend/component/config/profile.go b/backend/component/config/profile.go
index 89d9af2585..c6a1f57e60 100644
--- a/backend/component/config/profile.go
+++ b/backend/component/config/profile.go
@@ -55,7 +55,7 @@ type Profile struct {
// RuntimeMemoryProfileThreshold is the memory threshold in bytes for the server to trigger a pprof memory profile.
// can be set in runtime
// 0 means no threshold.
- RuntimeMemoryProfileThreshold atomic.Int64
+ RuntimeMemoryProfileThreshold atomic.Uint64
}
// UseEmbedDB returns whether to use embedDB.
diff --git a/backend/runner/monitor/monitor.go b/backend/runner/monitor/monitor.go
index 269b87abec..4325ec0ccc 100644
--- a/backend/runner/monitor/monitor.go
+++ b/backend/runner/monitor/monitor.go
@@ -26,14 +26,12 @@ const (
)
type MemoryMonitor struct {
- profile *config.Profile
- memoryThreshold uint64
+ profile *config.Profile
}
-func NewMemoryMonitor(profile *config.Profile, memoryThreshold uint64) *MemoryMonitor {
+func NewMemoryMonitor(profile *config.Profile) *MemoryMonitor {
return &MemoryMonitor{
- profile: profile,
- memoryThreshold: memoryThreshold,
+ profile: profile,
}
}
@@ -47,7 +45,8 @@ func (m *MemoryMonitor) Run(ctx context.Context, wg *sync.WaitGroup) {
case <-ctx.Done():
return
case <-ticker.C:
- m.checkMemory(m.memoryThreshold)
+ threshold := m.profile.RuntimeMemoryProfileThreshold.Load()
+ m.checkMemory(threshold)
}
}
}
diff --git a/backend/server/server.go b/backend/server/server.go
index 803e720790..7c5731821f 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -329,7 +329,7 @@ func (s *Server) Run(ctx context.Context, port int) error {
go s.planCheckScheduler.Run(ctx, &s.runnerWG)
s.runnerWG.Add(1)
- mmm := monitor.NewMemoryMonitor(s.profile, 1024*1024)
+ mmm := monitor.NewMemoryMonitor(s.profile)
go mmm.Run(ctx, &s.runnerWG)
address := fmt.Sprintf(":%d", port)