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

Parent process is not closing after fork

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.8
    • Component/s: Shell
    • Labels:
      None
    • Environment:
      Slackware64 current
    • ALL

      I'm using following small shell script to launch MongoDB:

      #!/bin/sh
      MONGO_DIR='/home/pawel/bin/mongo'
      $MONGO_DIR/bin/mongod --bind_ip 127.0.0.1 --logpath $MONGO_DIR/log/mongo.log --fork --dbpath $MONGO_DIR/db/ --directoryperdb

      When I'll launch this, MongoDB process is starting but main process is not closing, i.e. I've following in my console:

      $ /home/pawel/bin/mongo/start_mongo.sh
      about to fork child process, waiting until server is ready for connections.
      forked process: 10044
      all output going to: /home/pawel/bin/mongo/log/mongo.log

      When checking processes list, I see 3 instances of MongoDB running:

      $ ps ax | grep mongo
      10041 pts/0 S+ 0:00 /bin/sh /home/pawel/bin/mongo/start_mongo.sh
      10042 pts/0 S+ 0:00 /home/pawel/bin/mongo/bin/mongod --bind_ip 127.0.0.1 --logpath /home/pawel/bin/mongo/log/mongo.log --fork --dbpath /home/pawel/bin/mongo/db/ --directoryperdb
      10043 ? Ss 0:00 /home/pawel/bin/mongo/bin/mongod --bind_ip 127.0.0.1 --logpath /home/pawel/bin/mongo/log/mongo.log --fork --dbpath /home/pawel/bin/mongo/db/ --directoryperdb
      10044 ? Sl 0:02 /home/pawel/bin/mongo/bin/mongod --bind_ip 127.0.0.1 --logpath /home/pawel/bin/mongo/log/mongo.log --fork --dbpath /home/pawel/bin/mongo/db/ --directoryperdb

      In log file I've only this:

      Sun Jan 5 11:23:02.114 [initandlisten] MongoDB starting : pid=10044 port=27017 dbpath=/home/pawel/bin/mongo/db/ 64-bit host=metis
      Sun Jan 5 11:23:02.114 [initandlisten] db version v2.4.8
      Sun Jan 5 11:23:02.114 [initandlisten] git version: a350fc38922fbda2cec8d5dd842237b904eafc14
      Sun Jan 5 11:23:02.114 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
      Sun Jan 5 11:23:02.114 [initandlisten] allocator: tcmalloc
      Sun Jan 5 11:23:02.114 [initandlisten] options:

      Unknown macro: { bind_ip}

      Sun Jan 5 11:23:02.322 [initandlisten] journal dir=/home/pawel/bin/mongo/db/journal
      Sun Jan 5 11:23:02.340 [initandlisten] recover : no journal files present, no recovery needed
      Sun Jan 5 11:23:03.332 [websvr] admin web console waiting for connections on port 28017
      Sun Jan 5 11:23:03.333 [initandlisten] waiting for connections on port 27017

      When I'll hit Ctrl+C in console, parent process is closing (PID=10042 from the list above) and rest of 2 are still running (PID: 10043, 10044) and I can use MongoDB.
      When I'm trying to send SIGTERM to first process (PID=10043) nothing happens, and when I'll send SIGTERM to PID=10044, (with kill 10044 shell command) both processes are closing and I've following in log file:

      Sun Jan 5 11:37:05.346 [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
      Sun Jan 5 11:37:05.346 [signalProcessingThread] now exiting
      Sun Jan 5 11:37:05.346 dbexit:
      Sun Jan 5 11:37:05.346 [signalProcessingThread] shutdown: going to close listening sockets...
      Sun Jan 5 11:37:05.346 [signalProcessingThread] closing listening socket: 9
      Sun Jan 5 11:37:05.346 [signalProcessingThread] closing listening socket: 10
      Sun Jan 5 11:37:05.346 [signalProcessingThread] closing listening socket: 11
      Sun Jan 5 11:37:05.346 [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
      Sun Jan 5 11:37:05.346 [signalProcessingThread] shutdown: going to flush diaglog...
      Sun Jan 5 11:37:05.346 [signalProcessingThread] shutdown: going to close sockets...
      Sun Jan 5 11:37:05.346 [signalProcessingThread] shutdown: waiting for fs preallocator...
      Sun Jan 5 11:37:05.346 [signalProcessingThread] shutdown: lock for final commit...
      Sun Jan 5 11:37:05.347 [signalProcessingThread] shutdown: final commit...
      Sun Jan 5 11:37:05.449 [signalProcessingThread] shutdown: closing all files...
      Sun Jan 5 11:37:05.450 [signalProcessingThread] closeAllFiles() finished
      Sun Jan 5 11:37:05.450 [signalProcessingThread] journalCleanup...
      Sun Jan 5 11:37:05.450 [signalProcessingThread] removeJournalFiles
      Sun Jan 5 11:37:05.594 [signalProcessingThread] shutdown: removing fs lock...
      Sun Jan 5 11:37:05.594 dbexit: really exiting now

      And now when I'll start MongoDB server again, the same happens

            Assignee:
            Unassigned Unassigned
            Reporter:
            pawelsmolinski Pawe? Smoli?ski
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: