mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 08:36:55 +03:00
lib/memory: add validation for remaining system memory
Previously, if user defined value for `memory.allowedBytes` flag exceeded system memory limit, remaining memory could take negative value. It results into incorrect memory auto-detect calculations for various components. Such as vmstorage unique timeseries limit and parts size. This commit adds negative value check. And also logs system memory limit at start-up of vm components. Fixes https://github.com/VictoriaMetrics/VictoriaMetrics/issues/10083
This commit is contained in:
@@ -39,6 +39,8 @@ See also [LTS releases](https://docs.victoriametrics.com/victoriametrics/lts-rel
|
||||
|
||||
* BUGFIX: [vmsingle](https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/) and `vmselect` in [VictoriaMetrics cluster](https://docs.victoriametrics.com/victoriametrics/cluster-victoriametrics/): disable rollup result cache for [instant queries](https://docs.victoriametrics.com/keyConcepts.html#instant-query) that contain [`rate`](https://docs.victoriametrics.com/MetricsQL.html#rate) function with a lookbehind window larger than `-search.minWindowForInstantRollupOptimization`. Previously, utilizing the cache might yield incorrect results when time series samples are not continuous. See [#10098](https://github.com/VictoriaMetrics/victoriaMetrics/issues/10098) for more details.
|
||||
|
||||
* BUGFIX: all VictoriaMetrics components: properly validate remaining system memory limit. Previously it could have negative values. See this issue [#10083](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/10083) for details.
|
||||
|
||||
## [v1.131.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.131.0)
|
||||
|
||||
Released at 2025-11-28
|
||||
|
||||
@@ -39,12 +39,19 @@ func initOnce() {
|
||||
percent := *allowedPercent / 100
|
||||
allowedMemory = int(float64(memoryLimit) * percent)
|
||||
remainingMemory = memoryLimit - allowedMemory
|
||||
logger.Infof("limiting caches to %d bytes, leaving %d bytes to the OS according to -memory.allowedPercent=%g", allowedMemory, remainingMemory, *allowedPercent)
|
||||
if remainingMemory <= 0 {
|
||||
logger.Fatalf("BUG: remaining memory %d bytes cannot be less than or equal to zero, detected system memory limit %d bytes, -memory.allowedPercent=%g", remainingMemory, memoryLimit, *allowedPercent)
|
||||
}
|
||||
logger.Infof("limiting caches to %d bytes, leaving %d bytes to the OS according to -memory.allowedPercent=%g, system memory limit %d bytes", allowedMemory, remainingMemory, *allowedPercent, memoryLimit)
|
||||
} else {
|
||||
allowedMemory = allowedBytes.IntN()
|
||||
remainingMemory = memoryLimit - allowedMemory
|
||||
logger.Infof("limiting caches to %d bytes, leaving %d bytes to the OS according to -memory.allowedBytes=%s", allowedMemory, remainingMemory, allowedBytes.String())
|
||||
if remainingMemory <= 0 {
|
||||
logger.Fatalf("FATAL: remaining memory %d bytes cannot be less than or equal to zero, detected system memory limit %d bytes, -memory.allowedBytes=%s", remainingMemory, memoryLimit, allowedBytes.String())
|
||||
}
|
||||
logger.Infof("limiting caches to %d bytes, leaving %d bytes to the OS according to -memory.allowedBytes=%s, system memory limit %d bytes", allowedMemory, remainingMemory, allowedBytes.String(), memoryLimit)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Allowed returns the amount of system memory allowed to use by the app.
|
||||
|
||||
Reference in New Issue
Block a user