What I've tried: I was hoping that this was a case where the dyno managers restarts were causing this. I boot up mattermost using a bash script (it's complicated, ask me sometime!), and I thought that it may be killing that process and not stopping the child process gracefully. I added a trap to the bash script that intercepts SIGKILL and sends it to the mattermost process, in the hopes that mattermost would gracefully close connections to the database. That does not seem to have worked though, since I've still seen the database connection count hit 20 since deploying that script - although, it does crash less often, I think... Might just be wishful thinking
What I know: When mattermost is shut down ( see this article on restart activities done by the dyno manager ), [some?/all?] of the idle connections to Heroku PG remain idle and don't timeout/close.
What I've tried: I was hoping that this was a case where the dyno managers restarts were causing this. I boot up mattermost using a bash script (it's complicated, ask me sometime!), and I thought that it may be killing that process and not stopping the child process gracefully. I added a trap to the bash script that intercepts SIGKILL and sends it to the mattermost process, in the hopes that mattermost would gracefully close connections to the database. That does not seem to have worked though, since I've still seen the database connection count hit 20 since deploying that script - although, it does crash less often, I think... Might just be wishful thinking