For a very intensive database scan, I turned to denormalizing / caching the database to reduce the need for server resources and increase productivity for users. A view is a summary view consisting of data from many different tables, so many different data changes also update the cache.
To reduce cache outflow, I turned to the Rack middleware. My middleware is as follows:
class MyMiddleware def initialize(app) @app = app end def call(env)
Everything looked great until the application was downloaded for a while. Then in the logs, I accidentally noticed the following error:
Status: 500 Internal Server Error could not obtain a database connection within 5 seconds. The max pool size is currently 5; consider increasing it.
When I uninstall the middleware, the application works fine again.
How to fix connection leaks when using ActiveRecord from Rack middleware?
user1454117
source share