{"record":{"id":"8b5e9cc802d3ce8b","repo":"neondatabase/neon","slug":"frequency-must-be-1000-hz","errorCode":null,"errorMessage":"frequency must be <=1000 Hz","messagePattern":"frequency must be <=1000 Hz","errorType":"http","errorClass":"ApiError","httpStatus":400,"severity":"warning","filePath":"libs/http-utils/src/endpoint.rs","lineNumber":388,"sourceCode":"        Pprof,\n        Svg,\n    }\n\n    // Parameters.\n    let format = match get_query_param(&req, \"format\")?.as_deref() {\n        None => Format::Pprof,\n        Some(\"pprof\") => Format::Pprof,\n        Some(\"svg\") => Format::Svg,\n        Some(format) => return Err(ApiError::BadRequest(anyhow!(\"invalid format {format}\"))),\n    };\n    let seconds = match parse_query_param(&req, \"seconds\")? {\n        None => 5,\n        Some(seconds @ 1..=60) => seconds,\n        Some(_) => return Err(ApiError::BadRequest(anyhow!(\"duration must be 1-60 secs\"))),\n    };\n    let frequency_hz = match parse_query_param(&req, \"frequency\")? {\n        None => 99,\n        Some(1001..) => return Err(ApiError::BadRequest(anyhow!(\"frequency must be <=1000 Hz\"))),\n        Some(frequency) => frequency,\n    };\n    let force: bool = parse_query_param(&req, \"force\")?.unwrap_or_default();\n\n    // Take the profile.\n    static PROFILE_LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));\n    static PROFILE_CANCEL: Lazy<Notify> = Lazy::new(Notify::new);\n\n    let report = {\n        // Only allow one profiler at a time. If force is true, cancel a running profile (e.g. a\n        // Grafana continuous profile). We use a try_lock() loop when cancelling instead of waiting\n        // for a lock(), to avoid races where the notify isn't currently awaited.\n        let _lock = loop {\n            match PROFILE_LOCK.try_lock() {\n                Ok(lock) => break lock,\n                Err(_) if force => PROFILE_CANCEL.notify_waiters(),\n                Err(_) => {\n                    return Err(ApiError::Conflict(","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/neondatabase/neon/blob/8f60b04da47ffefe0e52bda2440134b42874eb75/libs/http-utils/src/endpoint.rs#L370-L406","documentation":"Returned as HTTP 400 BadRequest by profile_cpu_handler in neon's http-utils when the frequency query parameter of /profile/cpu is >= 1001 Hz. Sampling frequencies above 1000 Hz are rejected to keep profiling overhead and file size sane; the default is 99 Hz and any value up to 1000 is accepted.","triggerScenarios":"GET /profile/cpu?frequency=2000 or ?frequency=1001 — any integer of 1001 or more returns this 400.","commonSituations":"Copy-pasting a pprof tutorial that recommends high frequencies; trying to get finer-grained stacks on an idle system; Grafana agent config with a high sample rate pointed at the endpoint.","solutions":["Lower frequency to <=1000, e.g. ?frequency=250 or keep the default 99","If you need finer resolution, profile a longer duration instead of a higher frequency","Verify no profile-frequency default in your scrape config exceeds 1000"],"exampleFix":"# before\ncurl 'http://localhost:9898/profile/cpu?frequency=2000'   # 400 frequency must be <=1000 Hz\n\n# after\ncurl 'http://localhost:9898/profile/cpu?frequency=250'","handlingStrategy":"validation","validationCode":"const freq = Number(process.env.PROFILE_FREQUENCY ?? 99);\nconst safeFreq = Number.isInteger(freq) && freq <= 1000 && freq > 0 ? freq : 99;\nawait fetch(`/profile/cpu?frequency=${safeFreq}`);","typeGuard":"function isValidProfileFrequency(f) { const n = Number(f); return Number.isInteger(n) && n >= 1 && n <= 1000; }","tryCatchPattern":null,"preventionTips":["Cap sampling frequency at 1000 Hz client-side; default 99 is usually enough","Prefer longer windows over higher frequencies for resolution","Check agent defaults when changing profiling configs"],"tags":["neon","http-utils","profiling","query-param","cpu-profile"],"backgroundTag":"out-of-range-parameter","analyzedSha":"8f60b04da47ffefe0e52bda2440134b42874eb75","analyzedAt":"2026-08-16T23:39:28.135Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}