neondatabase/neon · error

max file cache size query returned no rows

Error message

max file cache size query returned no rows

What it means

`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.

Source

Thrown at libs/vm_monitor/src/filecache.rs:261

        .map(|bytes| bytes as u64)
        .context("failed to extract file cache size from query result")
    }

    /// Attempt to set the file cache size, returning the size it was actually
    /// set to.
    #[tracing::instrument(skip_all, fields(%num_bytes))]
    pub async fn set_file_cache_size(&mut self, num_bytes: u64) -> anyhow::Result<u64> {
        let max_bytes = self
            // The file cache GUC variable is in MiB, but the conversion with pg_size_bytes
            // means that the end result we get is in bytes.
            .query_with_retry(
                "SELECT pg_size_bytes(current_setting('neon.max_file_cache_size'));",
                &[],
            )
            .await
            .context("failed to query pg for max file cache size")?
            .first()
            .ok_or_else(|| anyhow!("max file cache size query returned no rows"))?
            .try_get::<_, i64>(0)
            .map(|bytes| bytes as u64)
            .context("failed to extract max file cache size from query result")?;

        let max_mb = max_bytes / MiB;
        let num_mb = u64::min(num_bytes, max_bytes) / MiB;

        let capped = if num_bytes > max_bytes {
            " (capped by maximum size)"
        } else {
            ""
        };

        info!(
            size = num_mb,
            max = max_mb,
            "updating file cache size {capped}",
        );

View on GitHub (pinned to 8f60b04da4)

Solutions

  1. Check connection health between vm-monitor and the compute node's postgres, then retry the resize
  2. 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'))`
  3. Inspect the `failed to query pg for max file cache size` context in logs for the underlying transport error
  4. Confirm the endpoint is a Neon compute with the `neon.max_file_cache_size` GUC present
Defensive patterns

Strategy: retry

Try / catch

match filecache.set_file_cache_size(bytes).await {
    Ok(actual) => { /* actual bytes set */ }
    Err(e) if e.to_string().contains("no rows") => {
        reconnect().await?;
        filecache.set_file_cache_size(bytes).await?;
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of neondatabase/neon@8f60b04da4 (2026-08-16). Data as JSON: /api/errors/e752ef92cbdc5b54. Report an issue: GitHub.