Fluid compute affecting Prisma + Supabase Postgres connection pool?

Hi there, I recently turned on Fluid Compute in my project which uses Next.js and Supabase Postgres + Prisma ORM. I set up my Prisma like this:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = []
}

datasource db {
  provider  = "postgresql"
  url       = env("SUPABASE_POSTGRES_PRISMA_URL") // uses connection pooling
  directUrl = env("SUPABASE_POSTGRES_URL_NON_POOLING") // uses a direct connection
}

And my keys are:

SUPABASE_POSTGRES_PRISMA_URL     ="postgres://postgres.foo:bar@aws-0-us-east-1.pooler.supabase.com:6543/postgres?pgbouncer=true&connection_limit=1"
SUPABASE_POSTGRES_URL_NON_POOLING="postgres://postgres.foo:bar@aws-0-us-east-1.pooler.supabase.com:5432/postgres"

Recently I have started seeing this error quite often, after 1 year of never seeing it (and no code changes related to this):

Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 1)
    at Hr.handleRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:122:6999)
    at Hr.handleAndLogRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:122:6388)
    at Hr.request (/var/task/node_modules/@prisma/client/runtime/library.js:122:6108)
    at async l (/var/task/node_modules/@prisma/client/runtime/library.js:126:10298)
    at async characterCount (/var/task/apps/web/.next/server/chunks/1576.js:860:21)
    at async GET (/var/task/apps/web/.next/server/app/api/characters/total-pages/route.js:104:23)
    at async /var/task/apps/web/.next/server/chunks/9854.js:4110:37 {
  code: 'P2024',
  clientVersion: '5.1.1',
  meta: { connection_limit: 1, timeout: 10 }
}

So I’m curious, does turning on Fluid compute affect the behavior here?

Note that I have connection limit = 1 because of the advice in this article: Database connections | Prisma Documentation

Thank you!

Hey,

Can you increase the connection pool timeout by setting the pool_timeout parameter to a value larger than the default (10 seconds) in your database connection URL. Here is an example:

datasource db {
	provider = "postgresql"
	url = "postgresql://johndoe:mypassword@localhost:5432/mydb?connection_limit=5&pool_timeout=20"
}

In this example, the pool timeout is set to 20 seconds. Adjust this value according to your needs.

From the link that is part of the error message: Connection pool | Prisma Documentation

1 Like

Sure, I’ll try that. But just to be clear, is the reason you suggest this that Fluid Compute keeps server instances alive for longer? And so we should extend the timeout to better match this?