Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-10825

mongod debug output when closing a batch of connections from Java API doesn't decrement number of connections

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: Diagnostics, Networking
    • Environment:
      Mac OS 10.8.3, Java 7 (1.7.0_40-b43), MongoDB 2.4.6, Tomcat 7.0.42
    • OS X
    • Platforms 2017-08-21

      This isn't critical at all, just a heads up:

      I'm sharing a single MongoClient across every Servlet on my Tomcat webapp, as per documentation. I manage the MongoClient inside a ServletContextListener, which creates inside contextInitialized(), and closes inside contextDestroyed().

      When I run Tomcat, repeatedly hit my servlet (which gets the MongoClient form getServletContext.getAttribute()), and then Ctrl+C the Tomcat instance when I'm done testing, the log output I get is:

      Thu Sep 19 11:24:47.045 [initandlisten] connection accepted from 127.0.0.1:49507 #37 (1 connection now open)
      Thu Sep 19 11:24:52.952 [initandlisten] connection accepted from 127.0.0.1:49508 #38 (2 connections now open)
      Thu Sep 19 11:24:53.185 [initandlisten] connection accepted from 127.0.0.1:49509 #39 (3 connections now open)
      Thu Sep 19 11:24:53.663 [initandlisten] connection accepted from 127.0.0.1:49518 #40 (4 connections now open)
      Thu Sep 19 11:24:53.881 [initandlisten] connection accepted from 127.0.0.1:49520 #41 (5 connections now open)
      Thu Sep 19 11:24:54.100 [initandlisten] connection accepted from 127.0.0.1:49521 #42 (6 connections now open)
      Thu Sep 19 11:24:54.289 [initandlisten] connection accepted from 127.0.0.1:49522 #43 (7 connections now open)
      Thu Sep 19 11:24:54.505 [initandlisten] connection accepted from 127.0.0.1:49523 #44 (8 connections now open)
      Thu Sep 19 11:24:54.865 [initandlisten] connection accepted from 127.0.0.1:49524 #45 (9 connections now open)
      Thu Sep 19 11:25:08.343 [conn41] end connection 127.0.0.1:49520 (8 connections now open)
      Thu Sep 19 11:25:08.343 [conn43] end connection 127.0.0.1:49522 (8 connections now open)
      Thu Sep 19 11:25:08.343 [conn45] end connection 127.0.0.1:49524 (8 connections now open)
      Thu Sep 19 11:25:08.343 [conn44] end connection 127.0.0.1:49523 (8 connections now open)
      Thu Sep 19 11:25:08.343 [conn40] end connection 127.0.0.1:49518 (8 connections now open)
      Thu Sep 19 11:25:08.343 [conn39] end connection 127.0.0.1:49509 (8 connections now open)
      Thu Sep 19 11:25:08.343 [conn38] end connection 127.0.0.1:49508 (8 connections now open)
      Thu Sep 19 11:25:08.343 [conn42] end connection 127.0.0.1:49521 (8 connections now open)
      Thu Sep 19 11:25:08.343 [conn37] end connection 127.0.0.1:49507 (8 connections now open)

      You notice that the number of connections open doesn't decrement after the first close. It does reset on the next use, however, back to

      Thu Sep 19 11:36:47.538 [initandlisten] connection accepted from 127.0.0.1:49778 #46 (1 connection now open)
      Thu Sep 19 11:36:53.030 [initandlisten] connection accepted from 127.0.0.1:49780 #47 (2 connections now open)

      etc.

      Didn't look at the source code, but this looks like a synchronization issue.

      Cheers,
      Keenon

            Assignee:
            henrik.edin@mongodb.com Henrik Edin
            Reporter:
            keenon Keenon Werling
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: