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

Fix "mongod --shutdown" to check size of "mongod.lock" instead of existence

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 5.2.0
    • 5.1.0-rc3
    • None
    • Fully Compatible
    • ALL
    • Hide

      Start a 5.1+ server, run mongod --shutdown

      Show
      Start a 5.1+ server, run  mongod --shutdown
    • Security 2021-12-13
    • 135

    Description

      In a07dc7, the code for `mongod --shutdown` was refactored, and appears to have inadvertently changed from `while (boost::filesystem::exists(procPath))` to `while (boost::filesystem::exists(pidfile))`, which never becomes false as the `mongod.lock` file this new version is waiting for is only ever emptied, not deleted.

      This fixes that to wait for the file to be either deleted or emptied. I debated switching back to `procPath` like the previous code, but I figured maybe it was changed on purpose? I'm not sure how that previous change was tested, though.

      The difference between the behavior currently in 5.0 and this new implementation is that the old `--shutdown` would exit even if the server exited uncleanly (because it was waiting for the PID to no longer exist) while the new implementation would instead hang forever (which is what happens on the 5.1 RCs when you run `mongod --shutdown` whether the server shuts down or not, and how I discovered this issue).

      I'll add my standard disclaimer that I'm happy to adjust, rebase, amend, etc this change in any way. :smile:

      Original Summary

      mongod --shutdown" hangs forever

      Original Description

      In a07dc78, the code for mongod --shutdown was refactored, and appears to have inadvertently changed from while (boost::filesystem::exists(procPath)) to while (boost::filesystem::exists(pidfile)), which never becomes false as the mongod.lock file this new version is waiting for is only ever emptied, not deleted.

       

      I've got a PR open at https://github.com/mongodb/mongo/pull/1428

      Attachments

        Activity

          People

            sara.golemon@mongodb.com Sara Golemon
            tianon Tianon Gravi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: