[SERVER-50866] systemd unit mongod.service should use "After=network-online.target" Created: 10/Sep/20  Updated: 29/Oct/23  Resolved: 29/Sep/20

Status: Closed
Project: Core Server
Component/s: Stability
Affects Version/s: None
Fix Version/s: 4.8.0, 4.4.2

Type: Improvement Priority: Major - P3
Reporter: Spencer Brown Assignee: Ryan Egesdahl (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Documented
is documented by DOCS-13899 systemd unit mongod.service should us... Closed
Related
Backwards Compatibility: Minor Change
Backport Requested:
v4.7, v4.4
Sprint: Dev Platform 2020-09-21, Dev Platform 2020-10-05
Participants:
Case:

 Description   

Currently the systemd unil file mongod.service waits for the network.target to be reached, via the line After=network.target. However, most Linux distributions with systemd support network-online.target, which is a better indicator that the network is up and available for MongoDB. When only waiting on network.target, it is possible that the mongod service fails to start upon system reboot.

See this systemd documentation page for a more detailed explanation.

We suggest changing the mongod.service file to specify:

After=network-online.target network.target



 Comments   
Comment by Githook User [ 07/Oct/20 ]

Author:

{'name': 'Ryan Egesdahl', 'email': 'ryan.egesdahl@mongodb.com', 'username': 'deriamis'}

Message: SERVER-50866 SystemD unit should wait for network-online.target

We were previously waiting for network.target, which does not actually
mean the network interface will be up and have an IP address assigned.
During some reboots, it's possible that mongod would start up before the
network interface was fully online, and this caused startup failures if
mongod was configured to listen on a specific IP address. Now we wait
for network-online.target instead to ensure the IP address is available
when mongod starts.

(cherry picked from commit 3dc3db0d78d4d8851ad50dd52ee51fed84ecc7e0)
Branch: v4.4
https://github.com/mongodb/mongo/commit/ca633f01d864257ff9b75c129421c9d4ecccc937

Comment by Githook User [ 29/Sep/20 ]

Author:

{'name': 'Ryan Egesdahl', 'email': 'ryan.egesdahl@mongodb.com', 'username': 'deriamis'}

Message: SERVER-50866 SystemD unit should wait for network-online.target

We were previously waiting for network.target, which does not actually
mean the network interface will be up and have an IP address assigned.
During some reboots, it's possible that mongod would start up before the
network interface was fully online, and this caused startup failures if
mongod was configured to listen on a specific IP address. Now we wait
for network-online.target instead to ensure the IP address is available
when mongod starts.
Branch: master
https://github.com/mongodb/mongo/commit/3dc3db0d78d4d8851ad50dd52ee51fed84ecc7e0

Generated at Thu Feb 08 05:23:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.