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

mongoid 3's one-session-per-thread results in file descriptor leak with jruby/tomcat

    • Type: Icon: Task Task
    • Resolution: Done
    • 4.0.0 final
    • Affects Version/s: None
    • Component/s: None

      I have noticed a file descriptor leak when running Rails with Mongoid 3 on a jruby/tomcat setup.

      In my setup, it appears that tomcat only reuses threads for about 30 requests. On thread shutdown, the default session never closes. This results in 3 file descriptors (primary, secondary, and arbiter) being leaked every time a thread is shutdown. See https://github.com/jruby/jruby-rack/issues/118 for more details.

      To solve this problem generally, I suspect mongoid 3 needs connection pooling. Since I am running with multiple runtimes in non-threadsafe mode, I am going to try a workaround where I assign the default session to a global variable instead of a thread-local variable (see https://github.com/tolsen/mongoid/commit/ea11a6ed651fd7323075106a77933dd926a70fea ). If you like, you might want to offer such a non-threadsafe option as a quick fix.

      Tim

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

              Created:
              Updated:
              Resolved: