[SERVER-61494] Fix "mongod --shutdown" to check size of "mongod.lock" instead of existence Created: 15/Nov/21 Updated: 29/Oct/23 Resolved: 01/Dec/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 5.1.0-rc3 |
| Fix Version/s: | 5.2.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Tianon Gravi | Assignee: | Sara Golemon |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | pull-request | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Operating System: | ALL | ||||||||||||
| Steps To Reproduce: | Start a 5.1+ server, run mongod --shutdown |
||||||||||||
| Sprint: | Security 2021-12-13 | ||||||||||||
| Participants: | |||||||||||||
| Linked BF Score: | 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 Summarymongod --shutdown" hangs forever Original DescriptionIn 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 |
| Comments |
| Comment by Githook User [ 30/Nov/21 ] |
|
Author: {'name': 'Tianon Gravi', 'email': 'tianon@infosiftr.com', 'username': 'tianon'}Message: Signed-off-by: Sara Golemon <sara.golemon@mongodb.com> Closes: https://github.com/mongodb/mongo/pull/1428 |