mongodb starts before network on VM and standalone

Bug #1693122 reported by Luca Cervigni
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
mongodb (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

Hello

Installed in a VM with only mongo running, the mongodb server service in systemd does not wait for network.target for starting up. This makes mongodb.service failing when the server restart, and when started by hand (after the network is restarted) works.

Workaround:

add the line:
After=network.target

in /lib/systemd/system/mongodb.service under the section [Unit]

Impact: mongodb fails to start if server restarted.
Reproducibility: on VMs, mongodb standalone node.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mongodb (Ubuntu):
status: New → Confirmed
Revision history for this message
Nish Aravamudan (nacc) wrote :

Hello and thank you for reporting this bug.

What exactly is the use case / why do you need networking for your database to start?

The MongoDB service is for the mongodb server, as far as I can tell, which is for serving databases. By default that is done locally. If you need to server your MongoDB over the network (perhaps that is the use case here?) you do need to probably make systemd changes if the ordering needs to be different than the default.

Changed in mongodb (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Luca Cervigni (cervigni) wrote :

I mean, it is a database service and 99% of the times can be, or it is used from the network.
In the mongodb configuration mongodb.conf:

...
#Net
net.bindIp: 127.0.0.1,10.4.78.23
net.port: 27017
...

The db tries to start binding on the 10.4.78.23 ip, that is still not up because there is no hierarchy set up when mongodb starts. The default startup process in systemd is managed by the package and therefore this change is probably to be done by your side. MongoDB is a database server and therefore need to be accessible from the network.

In my case, the mongodb database is used on three standalone VMs to support the monitoring of an Openstack installation.

Can you please re-open?

Revision history for this message
Nish Aravamudan (nacc) wrote : Re: [Bug 1693122] Re: mongodb starts before network on VM and standalone

On 01.06.2017 [00:22:44 -0000], Luca Cervigni wrote:
> I mean, it is a database service and 99% of the times can be, or it is used from the network.
> In the mongodb configuration mongodb.conf:
>
> ...
> #Net
> net.bindIp: 127.0.0.1,10.4.78.23
> net.port: 27017
> ...

That is a change you made in your local configuration, correct? By
default, mongodb listens on localhost only.

> The db tries to start binding on the 10.4.78.23 ip, that is still not up
> because there is no hierarchy set up when mongodb starts. The default
> startup process in systemd is managed by the package and therefore this
> change is probably to be done by your side. MongoDB is a database server
> and therefore need to be accessible from the network.

So you made a change to your local configuration without finishing the
change in the systemd service, afaict. It is expected that you will do
the systemd change you mentioned. Similar to if you change where the
database is stored, and that is on some systemd-managed mountpoint, you
might need to wait on that unit as well.

All that being said, MySQL seems to have made this change to their
service file, so there is precedence. I will place this on the server
backlog.

> In my case, the mongodb database is used on three standalone VMs to
> support the monitoring of an Openstack installation.

I think the right approach to this is probably to ask Debian if they
would consider changing the systemd file in the source package. Would
you be willing to file the bug there?

Changed in mongodb (Ubuntu):
status: Incomplete → Triaged
Revision history for this message
Luca Cervigni (cervigni) wrote :

I thought this was the right place to fill the bug to have the source package fixed. Where should I report it to if not here?
Thanks

Revision history for this message
Nish Aravamudan (nacc) wrote :

Hi Luca,

This is the right place for Ubuntu, yes. But Ubuntu (at least in the current release) is syncing from Debian. So the appropriate place to get the fix in, at least at first, is with Debian: http://www.debian.org/Bugs/Reporting. I can also file it when I add the delta, but it's better if a user reports it, if possible.

Revision history for this message
Robie Basak (racb) wrote :

We've seen this pattern being requested in many packages: normally a network service dependency isn't needed because a service by default doesn't bind to a specific address. If a user configures a service to bind on a specific address, then often they also need to add the network dependency locally. Otherwise the service will start before the network interface is brought up and fail.

Policy discussion: https://lists.ubuntu.com/archives/ubuntu-devel/2021-May/041455.html

Other affected services: https://bugs.launchpad.net/ubuntu/+bugs?field.tag=network-online-ordering

However, in the case of mongodb, Ubuntu no longer ships mongodb in its latest releases, so there is no further action that can be taken on this bug specifically. For the Ubuntu development release, I'm therefore setting this bug to Won't Fix.

It seems unlikely to me that we'd make a change to an existing stable release to add the service dependency, but that path remains potentially open. Note though that a workaround is trivially available by overriding the service configuration locally.

tags: added: network-online-ordering
Robie Basak (racb)
Changed in mongodb (Ubuntu):
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.