MongoDB Service Terminated by Linux OOM Killer – Adjusting OOMScoreAdjust to Improve Stability
Original Question or Issue:
MongoDB service becomes unstable or stops unexpectedly due to the Linux OOM (Out-Of-Memory) Killer terminating the process.
Environment:
- Product - FileCloud Server
- Version - Any
- Platform - Linux
Steps to Reproduce:
Error or Log Message:
Kernel logs may show entries similar to:
Out of memory: Kill process xxxx (mongod) score xxx or sacrifice childKilled process xxxx (mongod) total-vm:xxxxkB
MongoDB service may stop unexpectedly.
Defect or Enhancement Number:
Cause:
Linux OOM Killer selects and terminates the MongoDB process during memory pressure due to its OOM score.
Resolution or Workaround:
Adjust the OOMScoreAdjust value for the MongoDB service to reduce the likelihood of it being terminated:
-
Run:
systemctl edit mongod -
Add:
[Service]
OOMScoreAdjust=-900 -
Reload and restart:
systemctl daemon-reload
systemctl restart mongod -
Verify:
systemctl show mongod | grep OOMScoreAdjust
Notes:
-
No updates have been received from the customer after recommending the OOMScoreAdjust change.