Bug 1077369 - mongodb-server requires too much free space
Summary: mongodb-server requires too much free space
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: mongodb
Version: rawhide
Hardware: All
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Marek Skalický
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-03-17 19:55 UTC by Konrad Gądek
Modified: 2015-02-23 14:26 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-02-23 14:26:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Konrad Gądek 2014-03-17 19:55:47 UTC
Description of problem:
Can't do 'service mongod start' when only 3GB of free space. MongoDB is not only used in "big systems" but often for simple applications, so IMHO it shall not default to using so much disk space. Plain users/hobbyists are less often expected to checking for run options than admins that run "webscale DBs" anyway.

My case here is a usage of mongo on thin VM.

AFAIK, other DBs adapt to free disk space and not 



Version-Release number of selected component (if applicable):
$ yum list mongodb{,-server}
mongodb.x86_64                                              2.4.6-1.fc20                                       @fedora
mongodb-server.x86_64                                       2.4.6-1.fc20                                       @fedora


How reproducible:
Just try to start mongod on system with around 3GB of free space.

Steps to Reproduce:
1. yum install mongodb{,-server}
2. sudo service mongod start

Actual results (from second command):
Redirecting to /bin/systemctl start  mongod.service
Job for mongod.service failed. See 'systemctl status mongod.service' and 'journalctl -xn' for details.

Expected results:
That mongod starts.

Fix:
Three alternatives (from proposed best to worst):
1) In postinstall add checking for disk space, patching mongod.service file if necessary.
2) Patching mongod.service file.
3) Show notification from postinstall about space requirement if there's no enough disk space.

The patch is to edit /usr/lib/systemd/system/mongod.service, change ExecStart line (add --smallfiles) so that it reads:
ExecStart=/usr/bin/mongod $OPTIONS run --smallfiles



Additional info:

$ sudo grep mongod /var/log/audit/audit.log
type=SERVICE_START msg=audit(1395054025.262:432): pid=1 uid=0 auid=4294967295 ses=4294967295  subj=system_u:system_r:init_t:s0 msg=' comm="mongod" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
type=SERVICE_START msg=audit(1395055325.031:459): pid=1 uid=0 auid=4294967295 ses=4294967295  subj=system_u:system_r:init_t:s0 msg=' comm="mongod" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
type=SERVICE_START msg=audit(1395055341.278:475): pid=1 uid=0 auid=4294967295 ses=4294967295  subj=system_u:system_r:init_t:s0 msg=' comm="mongod" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
type=SERVICE_START msg=audit(1395055446.763:481): pid=1 uid=0 auid=4294967295 ses=4294967295  subj=system_u:system_r:init_t:s0 msg=' comm="mongod" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'

$ journalctl -xn
-- Logs begin at pią 2013-12-27 02:39:02 CET, end at pon 2014-03-17 12:28:17 CET. --
mar 17 12:28:17 f20.vmfusion sudo[2405]: konrad : TTY=pts/0 ; PWD=/home/konrad ; USER=root ; COMMAND=/sbin/service mon
mar 17 12:28:17 f20.vmfusion systemd[1]: Starting High-performance, schema-free document-oriented database...
-- Subject: Unit mongod.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mongod.service has begun starting up.
mar 17 12:28:17 f20.vmfusion mongod[2418]: about to fork child process, waiting until server is ready for connections.
mar 17 12:28:17 f20.vmfusion mongod[2418]: forked process: 2420
mar 17 12:28:17 f20.vmfusion mongod[2418]: all output going to: /var/log/mongodb/mongodb.log
mar 17 12:28:17 f20.vmfusion mongod[2418]: log file [/var/log/mongodb/mongodb.log] exists; copied to temporary file [/
mar 17 12:28:17 f20.vmfusion mongod[2418]: ERROR: child process failed, exited with error number 100
mar 17 12:28:17 f20.vmfusion systemd[1]: mongod.service: control process exited, code=exited status=100
mar 17 12:28:17 f20.vmfusion systemd[1]: Failed to start High-performance, schema-free document-oriented database.
-- Subject: Unit mongod.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mongod.service has failed.
--
-- The result is failed.
mar 17 12:28:17 f20.vmfusion systemd[1]: Unit mongod.service entered failed state.

$ cat /var/log/mongodb/mongodb.log
Mon Mar 17 12:28:17.395 [initandlisten] MongoDB starting : pid=2420 port=27017 dbpath=/var/lib/mongodb 64-bit host=f20.vmfusion
Mon Mar 17 12:28:17.395 [initandlisten] db version v2.4.6
Mon Mar 17 12:28:17.395 [initandlisten] git version: nogitversion
Mon Mar 17 12:28:17.395 [initandlisten] build info: Linux buildvm-12.phx2.fedoraproject.org 3.10.9-200.fc19.x86_64 #1 SMP Wed Aug 21 19:27:58 UTC 2013 x86_64 BOOST_LIB_VERSION=1_54
Mon Mar 17 12:28:17.395 [initandlisten] allocator: tcmalloc
Mon Mar 17 12:28:17.395 [initandlisten] options: { bind_ip: "127.0.0.1", command: [ "run" ], config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", fork: "true", journal: "true", logpath: "/var/log/mongodb/mongodb.log", nohttpinterface: "true", pidfilepath: "/var/run/mongodb/mongodb.pid", port: 27017, quiet: true }
Mon Mar 17 12:28:17.397 [initandlisten] journal dir=/var/lib/mongodb/journal
Mon Mar 17 12:28:17.397 [initandlisten] recover : no journal files present, no recovery needed
Mon Mar 17 12:28:17.397 [initandlisten]
Mon Mar 17 12:28:17.397 [initandlisten] ERROR: Insufficient free space for journal files
Mon Mar 17 12:28:17.397 [initandlisten] Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
Mon Mar 17 12:28:17.397 [initandlisten]
Mon Mar 17 12:28:17.397 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
Mon Mar 17 12:28:17.397 dbexit:
Mon Mar 17 12:28:17.397 [initandlisten] shutdown: going to close listening sockets...
Mon Mar 17 12:28:17.397 [initandlisten] shutdown: going to flush diaglog...
Mon Mar 17 12:28:17.397 [initandlisten] shutdown: going to close sockets...
Mon Mar 17 12:28:17.397 [initandlisten] shutdown: waiting for fs preallocator...
Mon Mar 17 12:28:17.397 [initandlisten] shutdown: lock for final commit...
Mon Mar 17 12:28:17.397 [initandlisten] shutdown: final commit...
Mon Mar 17 12:28:17.397 [initandlisten] shutdown: closing all files...
Mon Mar 17 12:28:17.397 [initandlisten] closeAllFiles() finished
Mon Mar 17 12:28:17.397 [initandlisten] journalCleanup...
Mon Mar 17 12:28:17.397 [initandlisten] removeJournalFiles
Mon Mar 17 12:28:17.398 [initandlisten] shutdown: removing fs lock...
Mon Mar 17 12:28:17.398 dbexit: really exiting now

$ df -h .
System plików           rozm. użyte dost. %uż. zamont. na
/dev/mapper/fedora-root   15G   11G  3,2G  77% /

Comment 1 Marek Skalický 2015-02-23 14:26:46 UTC
I discussed this problem in devel mailing list [1]. And also with upstream [2].

Your fixes:
1) + 3) "Generally, making such a decision at install time is bad, because that
might not reflect _runtime_. For example, in the cloud image, we use a
/ filesystem as small as Anaconda will allow, but that grows to fill
available storage when the image is booted." (Matthew Miller)

2) I think in .service file it is possible to dynamically turn on using smallfiles. MongoDB is also used in "big systems" and smallfiles by default could decrease their performance. And this default configuration is also used by upstream.

You can easily fix your problem by setting smallfiles=true in mongod.conf (mongodb.conf before f22).


[1] - https://lists.fedoraproject.org/pipermail/devel/2015-February/207578.html
[2] - https://groups.google.com/forum/#!topic/mongodb-dev/2nGDFeU2hI4


Note You need to log in before you can comment on or make changes to this bug.