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

Initscript does not stop a running mongod daemon

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.5, 3.1.5
    • Affects Version/s: 3.0.3
    • Component/s: Packaging
    • None
    • Fully Compatible
    • ALL
    • Hide

      1. Start mongod

      # service mongod start
      # service mongod status
      mongod (pid 22345) is running...
      

      2. Remove the mongod pid file

      rm -f /var/run/mongod/mongod.pid
      

      3. Stop mongod

      # service mongod stop
      

      4. Observe mongod is still running

      # service mongod status
      mongod (pid 22345) is running...
      
      Show
      1. Start mongod # service mongod start # service mongod status mongod (pid 22345) is running... 2. Remove the mongod pid file rm -f / var /run/mongod/mongod.pid 3. Stop mongod # service mongod stop 4. Observe mongod is still running # service mongod status mongod (pid 22345) is running...
    • Build 5 06/26/16

      I believe this problem may have been misdiagnosed. I'm seeing this issue on CentOS-6.5 with `mongodb-org-server-3.0.3-1.el6.x86_64`

      The problem is that `service mongod stop` reports that mongo was successfully stopped.

      # service mongod stop
      Stopping mongod:                                           [  OK  ]
      

      However, hours later `mongod` is still running:

      # service mongod status
      mongod (pid 22345) is running...
      

      Repeated attempts to stop mongod are unsuccessful:

      # service mongod stop
      Stopping mongod:                                           [  OK  ]
      # service mongod status
      mongod (pid 22345) is running...
      

      The problem is that the pidfile has been removed, but mongod is still running. The current initscript uses a shell function mongo_killproc which relies on the function pidofproc to determine the pid of a running mongo. This function does not work when the pid file has been removed, but mongo is still running.

      # service mongod status
      mongod (pid 22345) is running...
      
      # cat /var/run/mongodb/mongod.pid
      cat: /var/run/mongodb/mongod.pid: No such file or directory
      
      # pidof mongod ; echo $?
      22345
      0
      
      # pidofproc -p /var/run/mongod/mongod.pid mongod ; echo $?
      3
      

      The solution (for CentOS-6.5) appears to be using pidof rather than pidofproc in mongo_killproc

            Assignee:
            sam.kleinman Sam Kleinman (Inactive)
            Reporter:
            jlaska James Laska
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: