2 years ago
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?
