{"record":{"id":"0111e97efc77a3ec","repo":"risingwavelabs/risingwave","slug":"reserved-memory-total-memory","errorCode":null,"errorMessage":"reserved memory ({}) >= total memory ({}).","messagePattern":"reserved memory \\((.+?)\\) >= total memory \\((.+?)\\)\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/compute/src/memory/config.rs","lineNumber":70,"sourceCode":"pub fn reserve_memory_bytes(opts: &ComputeNodeOpts) -> (usize, usize) {\n    if opts.total_memory_bytes < MIN_COMPUTE_MEMORY_MB << 20 {\n        panic!(\n            \"The total memory size ({}) is too small. It must be at least {} MB.\",\n            convert(opts.total_memory_bytes as _),\n            MIN_COMPUTE_MEMORY_MB\n        );\n    }\n\n    // If `reserved_memory_bytes` is not set, calculate total_memory_bytes based on gradient reserve memory proportion.\n    let reserved = opts\n        .reserved_memory_bytes\n        .unwrap_or_else(|| gradient_reserve_memory_bytes(opts.total_memory_bytes));\n\n    // Should have at least `MIN_SYSTEM_RESERVED_MEMORY_MB` for reserved memory.\n    let reserved = std::cmp::max(reserved, MIN_SYSTEM_RESERVED_MEMORY_MB << 20);\n\n    if reserved >= opts.total_memory_bytes {\n        panic!(\n            \"reserved memory ({}) >= total memory ({}).\",\n            convert(reserved as _),\n            convert(opts.total_memory_bytes as _)\n        );\n    }\n\n    (reserved, opts.total_memory_bytes - reserved)\n}\n\n/// Calculate the reserved memory based on the total memory size.\n/// The reserved memory size is calculated based on the following gradient:\n/// - 30% of the first 16GB\n/// - 20% of the rest\npub fn gradient_reserve_memory_bytes(total_memory_bytes: usize) -> usize {\n    let mut total_memory_bytes = total_memory_bytes;\n    let mut reserved = 0;\n    for i in 0..RESERVED_MEMORY_LEVELS.len() {\n        let level_diff = if i == 0 {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/compute/src/memory/config.rs#L52-L88","documentation":"reserve_memory_bytes panics when the reserved memory amount (after being clamped up to at least MIN_SYSTEM_RESERVED_MEMORY_MB) is greater than or equal to the configured total_memory_bytes. This invariant guarantees there is actual memory left for user workloads; if the reservation swallows all memory, the configuration is invalid.","triggerScenarios":"total_memory_bytes is only slightly above MIN_COMPUTE_MEMORY_MB while the gradient-based or explicit reservation, clamped to MIN_SYSTEM_RESERVED_MEMORY_MB, meets or exceeds it; setting an explicit reserved-bytes option larger than the total; running with a tiny container memory limit.","commonSituations":"Very small k8s memory limits (e.g. 256MB) where the minimum system reservation already covers everything; mismatched config where reserved memory was pinned high but total memory was lowered.","solutions":["Increase total_memory_bytes so it comfortably exceeds MIN_SYSTEM_RESERVED_MEMORY_MB (leaving room for workload memory).","Lower the explicit reserved-memory option if one was set, letting the gradient-based default apply.","Review the computed 'reserved' value in reserve_memory_bytes (src/compute/src/memory/config.rs:60-70) and size total memory as reserved + expected workload memory."],"exampleFix":"// before\n--total-memory-bytes 268435456 --reserved-memory-bytes 268435456  # reserved >= total\n// after\n--total-memory-bytes 2147483648  # let reservation be derived, leaving workload memory","handlingStrategy":"validation","validationCode":"# Ensure total memory leaves room after the minimum system reservation\nmin_reserved_bytes = 512 * 1024 * 1024  # check MIN_SYSTEM_RESERVED_MEMORY_MB\ntotal_bytes = 2147483648\nassert total_bytes > min_reserved_bytes, 'total memory must exceed minimum system reservation'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Size total_memory_bytes as reserved + expected workload memory, never close to the reservation floor.","Avoid pinning reserved-memory values higher than total memory.","Test memory configs with reserve_memory_bytes unit tests (test_reserve_memory_bytes) before deploying."],"tags":["rust","memory","config","compute-node","startup"],"backgroundTag":"conflicting-config-options","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}