mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
With neither --memory-limit-mib nor GOMEMLIMIT, a cgroup v2 limit that cannot be derived (a membership outside the cgroup2 mount of the holder's mount namespace, an unreadable or malformed memory.max) is the no-limit case: the holder keeps the 256 MiB default and starts, instead of exiting 2. applyMemoryLimit, run once logging is configured, logs one level=WARN line naming the derivation's error and the two ways to choose a limit, and status reports the reason in Memory.SoftLimitFallback (empty otherwise). Only an explicit but invalid limit still refuses. Docs: the flag's help, the operator guide's memory section, the status schema and the v1.1 notes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
846 B
Go
22 lines
846 B
Go
package main
|
|
|
|
import (
|
|
"runtime/debug"
|
|
|
|
"github.com/seaweedfs/seaweed-block/core/host/volume"
|
|
)
|
|
|
|
// applyMemoryLimit sets the process's Go soft memory limit from the parsed
|
|
// flags. When the default is in force because the cgroup v2 limit could not
|
|
// be derived, it logs one WARN naming why and how to choose a limit, and
|
|
// status reports the reason (Memory.SoftLimitFallback).
|
|
func applyMemoryLimit(f flags, logf func(string, ...any)) {
|
|
if f.memoryLimitMiB > 0 {
|
|
debug.SetMemoryLimit(f.memoryLimitMiB << 20)
|
|
}
|
|
volume.SetSoftLimitFallback(f.memoryLimitFallback)
|
|
if f.memoryLimitFallback != "" {
|
|
logf("blockvolume: level=WARN memory limit: the cgroup v2 limit could not be derived (%s); running with the %d MiB default soft limit; set --memory-limit-mib or GOMEMLIMIT to choose a limit", f.memoryLimitFallback, f.memoryLimitMiB)
|
|
}
|
|
}
|