R
Railway

✋|help

Postgres drops connection when inactive, is this by default?

Eeldisgustin8/25/2023
I'm developing a node app using AdonisJS@5 and on a prolonged inactivity period (more than 5 hours) the database drops the connection, I wanted to know if this is expected and by design on railway
Solution:
Straight up pool.min: 0 as you said

In my config/database.ts
// My other imports

const databaseConfig: DatabaseConfig = {
   connections: {
    pg: {
      /// Rest of my config
      pool: {
        min: 0,
      }
    }
};
Jump to solution
Eeldisgustin8/25/2023
54c2ba8f-05f3-48a7-8347-7fe20afe05a8
Rrayofbytes8/25/2023
Nope, we don't "pause" databases (unless you exceed trial limits, which you didn't). Some questions to help narrow this down:
- Are you able to connect to the db externally when this happens?
- Are you pooling connections/prematurely releasing them ahead of next query?
- Can you elaborate on what "drops the connection" mean here? What error are you seeing from your application?
- ^ anything in your database logs on Railway (database -> Logs tab) that would suggest it's dropping connections within similar timestamp ranges?
Eeldisgustin8/25/2023
Are you able to connect to the db externally when this happens?
Yeah, the app eventually re-connects after we try to perform 1 request,

Are you pooling connections/prematurely releasing them ahead of next query?
I'll have to do some digging because we are using a ORM to handle queries

Can you elaborate on what "drops the connection" mean here? What error are you seeing from your application?
^ anything in your database logs on Railway (database -> Logs tab) that would suggest it's dropping connections within similar timestamp ranges?

{"level":40,"time":1692989569205,"pid":20,"hostname":"railway","name":"axer-backend","msg":"Connection Error: Connection ended unexpectedly"}

I'm just digging into this problem so I'm not discarding the posibility of the framework being at fault
Rrayofbytes8/25/2023
👍 could also try increasing conn timeout and see if that helps
Eeldisgustin8/25/2023
Will try that, with the info that the db doesn't drop the connection narrows my problem
Thanks!
Bbrody1928/25/2023
would you be using knex or something that uses knex?
Eeldisgustin8/25/2023
adonis uses lucid
https://github.com/adonisjs/lucid
Aaand it has knex declared as a dependency
Bbrody1928/26/2023
read the note from knex
https://knexjs.org/guide/#pool
you'll need a way to pass pool.min: 0 to knex through lucid
lucid's docs are not great, so I have yet to find out how to do that, but I imagine it wouldn't be hard for you to figure out
Eeldisgustin8/26/2023
I totally agree on this one, awesome thank you!
Bbrody1928/26/2023
hey where you able to find a way to set pool.min to 0?
Eeldisgustin8/26/2023
Yeah, its on the basic pool config
Solution
Eeldisgustin8/26/2023
Straight up pool.min: 0 as you said

In my config/database.ts
// My other imports

const databaseConfig: DatabaseConfig = {
   connections: {
    pg: {
      /// Rest of my config
      pool: {
        min: 0,
      }
    }
};
Bbrody1928/26/2023
awsome, and you havent had any issues since?
Eeldisgustin8/26/2023
We just deployed it so I will come back to you in a few hours
Bbrody1928/26/2023
sounds good!
Eeldisgustin8/26/2023
Seems like that did the trick
Bbrody1928/26/2023
awsome!

Looking for more? Join the community!

Recommended Posts
Fontconfig to canvasHi, I've been using the node-canvas in default railway when I use that, only libuuid and libGL are ivolumehey guys! quick question, I've got a golang project. I need it to create a json file on railway and system ran out of memoryCan someone help me? When I try to run my react app i get this error message. > tuya_react_frontend@Litestar command not foundHey all apologies for the possibly silly question. I am looking to deploy this repo: https://github.save temporary archivesCan i save temporary pdfs to a back-end host ? I'm trying to save a pdf file from a client upload bHow to host websockets?This is my first time hosting socket server, how can i do that on railway? I docs there are only webI cannot use opencv2 and received ImportError: libgl.so.1 cannot open shared object file no such filCan anyone help me with that ??LibreofficeHi I need libreoffice installed to use in my code. I attempted using the below nixpacks.toml ``` [Random app crash, no logs or other indicatorWhen trying my healtcheck I get random crashes, no recent deploy was made, I don't see any logs on mModify build commandHow would I modify the build command so it does a pip install of `psycopg2` ? I was told to remove tPayment method removalHey, how do I remove my payment method? I opted in for a credit subscriptions but still see my crediDeploying crashedHello, i'm facing a problem when deploying my spring boot application to railway, my application worInternal server error when accessing TypebotI noticed that since yesterday the new installations with the Typebot template present the error IntRAILWAY_PUBLIC_DOMAIN replaces RAILWAY_STATIC_URLHi team, we've been hunting down a bug with our app today, occurring on many PR Environments and it'My Subscription issueHello dear support guys: I found that I have been downgraded to No Subscription.. If my memory is rIs it normal for hello world json to return in 600ms? - GO FIBERHelp setting up a monorepoI'm getting this error when deploying my project. I made sure no other deployments are running, but Deployment and logging issues (Maven)Hello, My program is running fine locally, but when I deploy it with Railway, I start seeing issuesIssues with Postgres DBI don't really understand why I am not seeing any tables in my DB. Seeding works, but the database sversion 'GLIBC 2.29' not foundweird error that seems to be because of my code, but it works on my computer <:bing_shrug:5837915814