{"record":{"id":"cb0e36ebd0e2b181","repo":"risingwavelabs/risingwave","slug":"not-a-number","errorCode":null,"errorMessage":"not a number","messagePattern":"not a number","errorType":"error_code","errorClass":"std::io::Error","httpStatus":null,"severity":"warning","filePath":"src/utils/resource_util/src/lib.rs","lineNumber":314,"sourceCode":"            Ok(available_parallelism) => available_parallelism.get() as f32,\n            Err(e) => panic!(\n                \"Failed to get available parallelism, error: {}\",\n                e.as_report()\n            ),\n        }\n    }\n\n    /// Returns the CPU limit when cgroup v1 is utilised.\n    pub fn get_cpu_limit_v1(\n        quota_path: &str,\n        period_path: &str,\n        max_value: f32,\n    ) -> Result<f32, std::io::Error> {\n        let content = std::fs::read_to_string(quota_path)?;\n        let cpu_quota = content\n            .trim()\n            .parse::<i64>()\n            .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidData, \"not a number\"))?;\n        // According to the kernel documentation, if the value is negative, it means no limit.\n        // https://docs.kernel.org/scheduler/sched-bwc.html#management\n        if cpu_quota < 0 {\n            return Ok(max_value);\n        }\n\n        let cpu_period = super::util::read_usize(period_path)?;\n\n        Ok((cpu_quota as f32) / (cpu_period as f32))\n    }\n\n    /// Returns the CPU limit when cgroup v2 is utilised.\n    pub fn get_cpu_limit_v2(limit_path: &str, max_value: f32) -> Result<f32, std::io::Error> {\n        let cpu_limit_string = fs_err::read_to_string(limit_path)?;\n\n        let cpu_data: Vec<&str> = cpu_limit_string.split_whitespace().collect();\n        match cpu_data.get(0..2) {\n            Some(cpu_data_values) => {","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/utils/resource_util/src/lib.rs#L296-L332","documentation":"In cgroup v1 CPU limit detection, `get_cpu_limit_v1` reads the quota file and parses it as `i64`. If the trimmed content is not an integer, it maps the parse failure to `io::Error(InvalidData, \"not a number\")`.","triggerScenarios":"Reading a cgroup v1 `cpu.cfs_quota_us` file whose content is not a plain integer (unexpected format, whitespace artifacts, placeholder text, or wrong path passed as quota_path).","commonSituations":"Unusual container runtimes mounting nonstandard files at the cgroup path; misconfigured override of the quota path in tests/custom environments; cgroup v2 systems where the v1 file does not exist as expected.","solutions":["Verify the path points to a real cgroup v1 cpu quota file containing an integer.","Check the host is running cgroup v1 (on cgroup v2 hosts the v1 path logic won't find valid data).","Ensure the container mounts /sys/fs/cgroup properly (privileged or correct volume).","Upgrade RisingWave to prefer cgroup v2 detection where applicable."],"exampleFix":"// before\nlet content = std::fs::read_to_string(\"/sys/fs/cgroup/cpu/cpu.cfs_quota_us\")?;\n// after (guard against non-numeric content)\nlet content = std::fs::read_to_string(\"/sys/fs/cgroup/cpu/cpu.cfs_quota_us\")?;\nif content.trim().parse::<i64>().is_err() {\n    log::warn!(\"unexpected cgroup quota content: {content:?}, falling back\");\n    return Ok(max_value);\n}","handlingStrategy":"fallback","validationCode":"fn cgroup_v1_quota_ok(path: &str) -> bool {\n    std::fs::read_to_string(path).map(|c| c.trim().parse::<i64>().is_ok()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match get_cpu_limit_v1(path, max) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidData => fallback_to_system_cpu(),\n    other => other?,\n}","preventionTips":["Verify cgroup v1 paths exist before reading them.","Run containers with proper cgroup mounts.","Detect cgroup version (v1 vs v2) before choosing the reader."],"tags":["rust","cgroup","cpu","parse"],"backgroundTag":"invalid-argument-format","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}