[SERVER-10190] Upstart configuration fails to start server if other instances are running Created: 12/Jul/13  Updated: 14/Nov/14  Resolved: 30/Jun/14

Status: Closed
Project: Core Server
Component/s: Packaging
Affects Version/s: 2.4.4
Fix Version/s: 2.7.3

Type: Bug Priority: Minor - P4
Reporter: Nick Stenning Assignee: Ernie Hershey
Resolution: Done Votes: 0
Labels: polish, pull-request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 12.04


Issue Links:
Related
is related to SERVER-7268 Add numactl to upstart scripts Closed
Tested
Operating System: Linux
Steps To Reproduce:

1. Install Mongo from the 10gen apt repository.
2. Run mongod in a shell, perhaps with different configuration, port bindings, etc.
3. Run "/sbin/start mongodb"

Expected behaviour:

  • starts MongoDB and outputs something like mongodb start/running, process 12345

Actual behaviour:

  • refuses to start MongoDB due to second running instance, and prints mongodb stop/waiting
Sprint: Server 2.7.3
Participants:

 Description   

The upstart configuration installed by the mongodb-10gen package from http://downloads-distro.mongodb.org/repo/ubuntu-upstart uses start-stop-daemon(8) to control the spawn of /usr/bin/mongod. It currently doesn't use a pidfile to track the lifecycle of the process, and thus falls back to the default behaviour of scanning the process table for an extant instance of a mongod process.

This means that when, for example, mongod is running inside an LXC container on the host, the upstart script will fail to start MongoDB.



 Comments   
Comment by Githook User [ 30/Jun/14 ]

Author:

{u'username': u'nickstenning', u'name': u'Nick Stenning', u'email': u'nick@whiteink.com'}

Message: SERVER-10190 Upstart conf: use pidfile, not 'ps'

The default upstart config installed with MongoDB doesn't provide the
`-pidfile` or `-make-pidfile` options to `start-stop-daemon`, which
means it determines whether or not MongoDB is running by inspecting the
process table to see if there are any instances of "mongod" running.

This is a pretty crude mechanism, and we can make it substantially more
reliable (not susceptible to mongod instances running inside LXC
containers or similar) by simply getting start-stop-daemon to write a
pidfile.
Branch: master
https://github.com/mongodb/mongo/commit/5d4b3fe40cfe91857850d89a7a99a07d41b1d48d

Comment by Githook User [ 30/Jun/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-10190 reformat start-stop-daemon command line with newlines
Branch: master
https://github.com/mongodb/mongo/commit/4350bfad7cea746d081190063a6f5a2b00531132

Comment by Guilhem Lettron [ 17/Jul/13 ]

Can you test https://github.com/mongodb/mongo/pull/454 to see if it resolve your issue?

Comment by Tad Marshall [ 16/Jul/13 ]

When testing pidfile, be aware of SERVER-10034 in case it would skew your results.

Comment by Ernie Hershey [ 15/Jul/13 ]

Looks good to me. We should test though, especially in both ubuntu 10.4 and 12.4 to make sure the syntax is supported to start-stop-daemon.

Also this might conflict with setting a pidfile in the config file, so we should test with and without a pidfile in the config file (none is our default on ubuntu packaged installs).

Comment by Matt Kangas [ 12/Jul/13 ]

Ernie, please review.

Generated at Thu Feb 08 03:22:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.