Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2445

Mongoid identity map is not fully cleared after a Rails request if Rails streaming is used

    • Type: Icon: Task Task
    • Resolution: Done
    • 4.0.0 final
    • 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.

            Assignee:
            durran Durran Jordan
            Reporter:
            tolsen Tim Olsen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: