Skip to content
PostgreSQL Transaction Pooling vs Session Pooling
b-e-a-f
OP

2 years ago

Hello, I'm currently trying to use Bun + ElysiaJS (adding this context in case anyone else runs into this issue). I'm running into an interesting error:

prepared statement ";.string.string" already exists

I actually reached out to the Bun team initially because I had assumed maybe it was a Bun issue.

https://github.com/oven-sh/bun/issues/17173

However, they've asked me whether or not I'm using transaction pooling or session pooling. I'm genuinely not sure what the default is set to for railway, and this is not a searchable setting on my database. What is the default for Railway's PostgreSQL db? Where can I find this in the future?

Also adding the nixpacks tag since it is the default for Railway's postgresql databases.

Solved

38 Replies

b-e-a-f
OP

2 years ago

c74d4143-faff-4947-823a-6f31b414bdf5


2 years ago

Afaik the default postgres service doesn't include any type of connection pooling functionality so that's maybe why it's failing since Bun may be not closing/opening connections properly? Or maybe it's related to Bun using prepared statements by default?

But I'm just guessing here and I would try to deploy a Pgbouncer in front of your postgres DB (https://railway.com/template/OpUzwe, it's very lightweight) together with the suggested config in the gh issue: prepare: false


b-e-a-f
OP

2 years ago

I like this idea actually, and it might be the solution. I think what you mean to say (or maybe I misinterpreted) is: if I do use PgBouncer then I likely will not have to set prepare: false. Because I can setup PgBouncer to do session pooling. Does that sound right to you?


2 years ago

Yep! But if it doesn't work with just PgBouncer you can also try adding that config


b-e-a-f
OP

2 years ago

I'm going to try this and get back to you. If it works I'll add it to the github issue so other people can find this solution!


b-e-a-f
OP

2 years ago

Looks like I'm back to not being able to connect to my database, after adding PgBouncer and restarting :/

https://discord.com/channels/713503345364697088/1365619106249838613


b-e-a-f
OP

2 years ago

34386048:error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT:..\..\third_party\boringssl\src\crypto\fipsmodule\cipher\e_aes.c.inc:1065:


2 years ago

Did u restart it or did u redeploy?


2 years ago

Do you have any data on it? Otherwise you can deploy a new one and point pgbouncer to it


2 years ago

Also make sure to follow the instructions at the bottom of the Pgbouncer template page


b-e-a-f
OP

2 years ago

Yeah it unfortunately has nothing to do with PgBouncer. Last time I restarted my db it did this as well.


b-e-a-f
OP

2 years ago

I redeployed and restarted several times <:Sadge:762395417526403113>


b-e-a-f
OP

2 years ago

Hey again 😅, still can't access my database. Is this something that we can resolve?


b-e-a-f
OP

2 years ago

Okay server back after restarting & redeploying several times


2 years ago

Can you confirm that the pgbouncer and the bun queries are working as intended?


2 years ago

Sorry for not being of much help with this bug, never seen this issue tbh.


b-e-a-f
OP

2 years ago

Adding PGBouncer didn't fix the issue :(. I am starting to believe it's a bun issue. I tried deploying with prepare: false and now my project crashes.

https://github.com/oven-sh/bun/issues/17173#issuecomment-2847477067


b-e-a-f
OP

2 years ago

Oh it seems my server is running bun v1.1.43 .... Maybe that's the issue


2 years ago

You can also try explaining that you are just running postgres with ssl enabled since that's what Railway deploys



b-e-a-f
OP

2 years ago

Hmm. Okay. Do you know the easiest way to update bun to latest without having to edit nixpacks configurations? If I have to run bun upgrade somewhere where would I do that?



b-e-a-f
OP

2 years ago

<:SadCat:1065694982826102804>


2 years ago

oh, you're using nixpacks?


b-e-a-f
OP

2 years ago

Yeah, it's the default.


2 years ago

what about 🌠 Railpack 🌠? https://railpack.com/languages/node/#bun


2 years ago

the new kid in town


b-e-a-f
OP

2 years ago

Ohhhhh this has what I'm looking for too. You can set the version of bun in a variable


b-e-a-f
OP

2 years ago

Ahhhh!!! It worked


b-e-a-f
OP

2 years ago

nixpacks is using a really old version of bun


b-e-a-f
OP

2 years ago

Hey thanks @Medim for your help, I think swapping to railpack is the solution for now. I also commented on the issue in case anyone else is running bun on railway.


2 years ago

Everything works fine now?


b-e-a-f
OP

2 years ago

Yeah. I'm also just going to keep PGBouncer because bun docs say to use it.


b-e-a-f
OP

2 years ago

It may be unnecessary


b-e-a-f
OP

2 years ago

!s


2 years ago

cool! Can I mark this thread as solved?


b-e-a-f
OP

2 years ago

Yes please!


2 years ago

!s


Status changed to Solved medim • over 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...