I just started using render yesterday after using heroku for a while. The daily cycles were getting pretty annoying for my online websocket game I’m developing interrupting online play. So I want to give render a go!
I made a static site for the client game files, a web service for the node server and a postgreSQL database for the server database.
Everything was looking good yesterday until I logged into my game this morning, which the node server authenticates with the postgres database.
The database had disconnected from the server since my last query about 15 hours earlier.
But it just gets the error “the database system is shutting down”. And I need to restart the server which I’m trying to avoid.
Do the postgres databases restart manually? I noticed in the logs every 10 seconds it gets spammed with a connection/disconnection from a different port while not in use.
Or could it be because the database is on the free tier, which I’m using to test alongside the starter 7$ plan for the server?
I’m trying to have minimum downtime if possible as it’s an online persistent game. Please let me know if you have any help or suggestions. Thanks!
Edit: I just got it again “Error: Connection terminated unexpectedly”
It can depend on the client libraries that you’re using to communicate between your service and the database and whether or not it holds connections open once they’ve been used. We don’t restart databases typically and I’m not seeing any issues with the DB at the moment. How are things looking now for you?
It could be coincidence but I enabled keepAlive: true and the database has not disconnected since!
That makes sense about the health checks and the 90 days limit good point.
I really would like to figure out coding it to auto-reconnect in case there is any kind of maintenance or temporary unavailability. Do you have any recommendations or examples/resources of how to handle it correctly?
Thanks again! I’m really enjoying working with render so far.
We do perform maintenance periodically, but where we know about it we would inform you beforehand. Of course, hardware can fail and instances will need to be brought up on new hardware so you should always assume that a database can disappear - I’ve certainly never seen anything that requires you to restart anything as the connection should just be reattempted when it’s next needed.
Previously I was attempting to reconnect in the on error callback and without the setTimeout.
So now when the connection ends, it tries every few seconds and eventually database functionality is restored (about 10-20 seconds). It works for now and without making a crazy amount of reconnection attempts!
Thanks for your replies @John_B I appreciate your help!