Content pfp
Content
@
0 reply
0 recast
3 reactions

welter pfp
welter
@fun
⚠️ FarcasterUserStats.com is down i really need help, this is frustrating ‼️ postgres db connection limit maxed, i have a pool in place, not sure if that actually works or not sql queries to the db should be less than 1-2s max, but now they're going over 15s timing out
22 replies
12 recasts
32 reactions

TobyJaguar pfp
TobyJaguar
@tobyjaguar
so the issue is the connections, not the query timeouts? As already stated, how are connections being released? Does each query open a new connection, and does that connection get released after the query? Kind of need to know the setup
1 reply
0 recast
0 reaction

welter pfp
welter
@fun
simplified version of what im doing, feel free to correct me if i'm wrong import { pool } from '../db' const client = await pool.connect(); const response = await pool.query(`query here`); client.release()
2 replies
0 recast
0 reaction

Ben pfp
Ben
@data-nerd
Are you wrapping this logic in a try - catch - finally block? I wonder if maybe an error is occurring pool.query(`query here`) but because of the error the connection never gets released. const client = await pool.connect(); try { const response = await pool.query(`query here`); } ... finally { client.release(); }
1 reply
0 recast
1 reaction

TobyJaguar pfp
TobyJaguar
@tobyjaguar
the errors should be caught though as well, so you could use the finally block or move the release to the catch block. Of course all async/await calls should be wrapped in a try/catch ;)
1 reply
0 recast
1 reaction

TobyJaguar pfp
TobyJaguar
@tobyjaguar
aight, I am a little confused by the repo, did you mock the code snippet that you posted? You can follow me so I can DM you, but I don't see the release in the catch, which may make @data-nerd 's point accurate, also...
1 reply
0 recast
0 reaction

TobyJaguar pfp
TobyJaguar
@tobyjaguar
I see this client connect in every route: const client = await pool.connect(); Does this not make a new connection for every api request? That is a lot of connections. Can you move the connect to the top level, and reuse the same connection until it auto disconnects, and then reest the connx?
0 reply
0 recast
0 reaction