Abort SQL statements
collimarco opened this issue · 7 comments
When a timeout exception is raised, the SQL statements are not aborted and continue running on the db (e.g. PostgreSQL).
It would be better to abort those statements, both to protect the db from performance degradation (i.e. very long queries) and to protect the data consistency (since the method will not finish its execution).
You can reproduce that easily by running this command inside a controller method:
ActiveRecord::Base.connection.execute('SELECT pg_sleep(100);')
I think you should handle this with statement_timeout
instead of rack-timeout
Thanks for the reply. However the problem is more related to rack-timeout, rather than to a global setting of the database: for example, my background jobs or any maintenance task should be able to run slow queries, so I cannot change statement_timeout
.
You can use it without setting it globally. In fact, that's the recommended way of using it.
I think this is the same as #30
Ah, not really, that issue seems about rack-timeout not doing anything in certain situations