New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database connection timeouts after some time and strapi crashed #8436
Comments
Based on this error it leads me to believe the issue lies above Strapi, either some kind of DB proxy/load balancer or an issue with the database itself. That error means Strapi is trying to reconnect to the database and is unable to (database is killing the connection). I'm marking this as closed as without steps to reconstruct the environment to look at directly this will be almost impossible to debug. Please do feel free to respond, though I recommend in cases like this we move the discussion over to the forum as it's highly unlikely this is an issue with the code base (thus a bug) and is more likely environmental or configuration issue. |
I found solution - the problem is knex related that happens together with docker swarn. Because it is not unusual deployment, I am writing solution here. The problem is, that docker swarn closes inactive connections in about 15 minutes. However, default knex configuration is to have connection pool with The problem is described there: https://success.mirantis.com/article/ipvs-connection-timeout-issue The solution is to set knex to have
|
Ah yes you are correct @Satrya2405 for some reason I though Knex's default was 0, but it is in fact 2: http://knexjs.org/#Installation-pooling I'll add this to our documentation backlog, though I don't think it's good to provide these by default in the code-base as it really only applies to containers that kill connections. |
Reopening to get @alexandrebodin's thoughts on this, as our existing documentation and structure doesn't really give any suggestions on modifying the database.js within the container. @alexandrebodin is this better in the docs or should we just apply the |
We had also postgres connection problems, which caused |
Bumping this for visibility. I initially thought it was a network issue since all my services (including DB) are behind Traefik/on Docker. If you could add that |
we coudl certainly add min:0 as default. if any one wants to make a PR at some point feel free to do it & reference this issue :) |
This issue has been mentioned on Strapi Community Forum. There might be relevant details there: https://forum.strapi.io/t/strapi-service-that-stops-when-it-loses-its-database-connection/11782/1 |
Bug report
Describe the bug
I am using Strapi as dockerised app inside Caprover PAAS. What happens is that when some time of inactivity, the app crashed in the next request. It looks like that connection to database is terminated.
This happens with both mysql and posgresql backend.
The strapi crashes then.
Steps to reproduce the behavior
Logs:
System
The text was updated successfully, but these errors were encountered: