{"record":{"id":"e752ef92cbdc5b54","repo":"neondatabase/neon","slug":"max-file-cache-size-query-returned-no-rows","errorCode":null,"errorMessage":"max file cache size query returned no rows","messagePattern":"max file cache size query returned no rows","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/vm_monitor/src/filecache.rs","lineNumber":261,"sourceCode":"        .map(|bytes| bytes as u64)\n        .context(\"failed to extract file cache size from query result\")\n    }\n\n    /// Attempt to set the file cache size, returning the size it was actually\n    /// set to.\n    #[tracing::instrument(skip_all, fields(%num_bytes))]\n    pub async fn set_file_cache_size(&mut self, num_bytes: u64) -> anyhow::Result<u64> {\n        let max_bytes = self\n            // The file cache GUC variable is in MiB, but the conversion with pg_size_bytes\n            // means that the end result we get is in bytes.\n            .query_with_retry(\n                \"SELECT pg_size_bytes(current_setting('neon.max_file_cache_size'));\",\n                &[],\n            )\n            .await\n            .context(\"failed to query pg for max file cache size\")?\n            .first()\n            .ok_or_else(|| anyhow!(\"max file cache size query returned no rows\"))?\n            .try_get::<_, i64>(0)\n            .map(|bytes| bytes as u64)\n            .context(\"failed to extract max file cache size from query result\")?;\n\n        let max_mb = max_bytes / MiB;\n        let num_mb = u64::min(num_bytes, max_bytes) / MiB;\n\n        let capped = if num_bytes > max_bytes {\n            \" (capped by maximum size)\"\n        } else {\n            \"\"\n        };\n\n        info!(\n            size = num_mb,\n            max = max_mb,\n            \"updating file cache size {capped}\",\n        );","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/neondatabase/neon/blob/8f60b04da47ffefe0e52bda2440134b42874eb75/libs/vm_monitor/src/filecache.rs#L243-L279","documentation":"`FileCache::set_file_cache_size` first queries `SELECT pg_size_bytes(current_setting('neon.max_file_cache_size'))` to learn the hard cap before clamping the requested size. This error fires when that scalar SELECT returns zero rows. Since Postgres always produces one row for `current_setting`, an empty result indicates a broken connection/query path rather than a missing GUC.","triggerScenarios":"Calling `set_file_cache_size(num_bytes)` when the postgres connection returns an empty result set for the max-size query — degraded connection, mocked test client without a programmed row, or an interfering proxy.","commonSituations":"Tests with mocked SQL clients lacking fixtures for the max_file_cache_size statement; connection pool exhaustion or flaky links between vm-monitor and postgres; unusual proxies stripping result rows.","solutions":["Check connection health between vm-monitor and the compute node's postgres, then retry the resize","In tests, program the mocked client to return one row (e.g. `pg_size_bytes('1GB')`) for `SELECT pg_size_bytes(current_setting('neon.max_file_cache_size'))`","Inspect the `failed to query pg for max file cache size` context in logs for the underlying transport error","Confirm the endpoint is a Neon compute with the `neon.max_file_cache_size` GUC present"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match filecache.set_file_cache_size(bytes).await {\n    Ok(actual) => { /* actual bytes set */ }\n    Err(e) if e.to_string().contains(\"no rows\") => {\n        reconnect().await?;\n        filecache.set_file_cache_size(bytes).await?;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Ensure vm-monitor's postgres connection is healthy before triggering cache resizes","Program test mocks with rows for both file_cache_size and max_file_cache_size statements","Distinguish 'no rows' transport anomalies from genuine GUC errors in alerting"],"tags":["rust","neon","vm-monitor","postgres","sqlx"],"backgroundTag":"sql-query-returned-no-rows","analyzedSha":"8f60b04da47ffefe0e52bda2440134b42874eb75","analyzedAt":"2026-08-16T23:39:28.135Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}