-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
Rack::Mongoid::Middleware defines call() to be:
def call(env) ::Mongoid.unit_of_work { @app.call(env) } end
But consider what happens in the case of Rails streaming. call() returns before the page is finished rendering. Any Mongoid queries that happen after call() returns are added to a cleared-out IdentityMap, but the values from these queries are not cleared out until call() returns from the next request on the same thread.
I found evidence for this when taking a heap dump of my jruby on rails app. The heap dump was taken with no requests in flight (I had taken down the front-end apache server).
I am not sure if Rails or Rack provides a after-response hook for streaming. Without such a hook, I'm not sure if this can be fixed easily.