R
Railway3mo ago
lludol

Queue, prisma and postgres

Hello, I have a classic rest API with Fastify (node.js) that is connected to two databases: postgres mongo Then, I also have a queue instance, it's also a Fastify but for the queue I am using https://github.com/mgcrea/prisma-queue (why? because it uses the lock feature of postgres). Both use Prisma to connect to the database. My problem is that the second instance has some cron job that are executed for example every day at 6am but sometimes they can't finish their job because there is this error: PrismaClientKnownRequestError Invalid prisma.queueJob.count() invocation: Can't reach database server at monorail.proxy.rlwy.net:30404 Please make sure your database server is running at monorail.proxy.rlwy.net:30404. To handle the prisma connection, I instanciate on both instances the prisma client through a Fastify plugin that will save the prisma instance to share it with either the routes or the jobs. Is there something I need to configure on Railway? I already have disabled the sleeping instance feature. Do I need to switch and use for example a queue library that use redis for example? Is it because of the "serverless" state of railway that the connection is terminated? Here my project ID where you have the 4 instances: 7c6b4b90-5182-4863-88ba-99fbd7a64056
GitHub
GitHub - mgcrea/prisma-queue: Minimalist postgresql job queue for P...
Minimalist postgresql job queue for Prisma. Contribute to mgcrea/prisma-queue development by creating an account on GitHub.
6 Replies
Percy
Percy3mo ago
Project ID: 7c6b4b90-5182-4863-88ba-99fbd7a64056
Brody
Brody3mo ago
please do not create duplicate threads railway is not serverless at all, apps are not stopped after any amount of time unless you have app sleeping enabled. you should also be using the private network to avoid egress fees when connecting to the database
lludol
lludolOP3mo ago
the bot closed my thread because I didn't put the project id, I didn't know what else to do I could not manage to make private network work when I tried it few weeks ago. I can try again (between the backend and the queue instance) For the DATABASE_URL, I am using the ${{Postgres.DATABASE_URL}}, doesn't it use per default the private network?
Brody
Brody3mo ago
that depends on when you deployed the database, simply check the value
lludol
lludolOP3mo ago
I put the DATABASE_PRIVATE_URL env Var. Same for Mongo at the end
Brody
Brody3mo ago
perfect!
Want results from more Discord servers?
Add your server