[SERVER-71380] Restart mongod upon RPM update conditionally Created: 15/Nov/22  Updated: 29/Oct/23  Resolved: 06/Dec/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.3.0-rc0

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

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:
  • install mongod RPM
  • ensure the service is disabled and not started
  • update the mongod server RPM
  • observe that the mongod process is started, with the service still being disabled

This was tested on Amazon Linux 2, but should hold true on other distros using the RPM.

Participants:

 Description   

In the RPM spec the mongod service is (re)started upon an update, no matter if mongod service is running or not:
https://github.com/mongodb/mongo/blob/49d34008db892e6a89498ecdd68fcd26e1d7ffab/rpm/mongodb-org.spec#L284

With help of systemctl is-active this can be changed to restart only a running mongod service:

/usr/bin/systemctl is-active --quiet mongod && /usr/bin/systemctl restart mongod



 Comments   
Comment by Githook User [ 06/Dec/22 ]

Author:

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

Message: SERVER-71380 Use `systemctl try-restart` during `postun`
Branch: master
https://github.com/mongodb/mongo/commit/6a8d2a5eb450093cadca0043b7de6925e093c5f5

Comment by Ryan Egesdahl (Inactive) [ 05/Dec/22 ]

systemd also has a try-restart action, which is essentially the same as is-active followed by restart. Also, for the sake of parity, I'll make sure the same is happening in our Debian packages. Turns out we don't restart mongod during Debian package updates. That seems not great for a variety of reasons, but it's also not something I would like to just do without some thought and discussion first. I've opened SERVER-71852 to track that.

Generated at Thu Feb 08 06:18:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.