When testing DB connection from local PC, every 2nd query fails
I am running a .NET 8.0 app from my local machine, and attempting to connect to my Supabase DB, which has been configured and has data imported into it. When I first startup the app, the first query that I make to the DB succeeds, but then the second one fails every time.
I'm using EF Core and ngpsql to connect to the DB, configured like this:
https://imgur.com/a/LIFq7H0
These are the errors I get:
https://imgur.com/a/gcTWhIP
This same behavior happens on every even call... The first call works, second fails, third works, fourth fails, etc. The failure also happens regardless of which API I use as long as it queries the DB. Even if I retry the same endpoint. Additionally, I tested calling my method that queries the DB twice in the same API call, and it fails as well. I've tested with both DBContext and DBContextPool and neither works. I'm not sure if this is a Supabase issue or a .NET issue, so I'm not sure where to look to figure out what's going on, or how to get better logs to try to diagnose the issue.
My Pool Size for my database is 15, and my max client connections is 200.
Thanks in advance for any help!
Imgur
Untitled Album
Imgur
Untitled Album
4 Replies
I found that I had to explicitly disable database connection pooling in the connection string.
Adding "Pooling:False" fixed the issue and everything is working properly now.
Are you using a pooling port (6543) when you should not be (5432)?
I'm using 5432
I didn't know there were different ports for pooling, glad to know that now!
So must be a flag for your "driver/libary". Wonder if it would have worked if you used 6543.