We sometimes get this error ERROR: canceling statement due to statement timeout : SELECT and "unplugging and plugging back in" does the trick in te...
For further actions, you may consider blocking this person and/or reporting abuse
What Heroku plan is dev.to on? It looks like it has something to do with Heroku's Postgres balancer.
Have you tried investigating with
SELECT * FROM pg_stat_activity
when that happens?Here are the details of the table: postgresql.org/docs/10/static/moni...
Even though I guess that if you run out of connections there's no time to investigate...
Install pghero somewhere via docker container for example and then you keep watching live queries and how much time it's taking. Probably you could find the bottleneck in your queries or blocking table statements.
I have no experience with anything ruby-related, let alone ActiveRecord, but a quick Google search for "postgres statement timeout" brought me to a page listing connection settings, including statement_timeout. So maybe you can find a way to increase this setting from its default value.
It might also be worth inspecting your query to see if you can optimise it a bit.
I think that's the right thought, but on that note I think decreasing the timeout value is probably more likely to be helpful I think in the macro. This seems to be a symptom of resource over-utilization where quitting early in order to avoid locking things up is probably the right course of action.
Anyway, that's where my head goes.
This might be stupid. But are your database queries efficient? It's possible that a bad execution plan is generated