Red Hat Bugzilla – Bug 824405
Mongodb server reports it's started to systemd but it's not accepting connections
Last modified: 2015-01-12 11:17:06 EST
Description of problem:
When you start mongodb and immediately try to connect to the database, it will sometimes fail because server is not ready. Currently mongodb uses "fork" systemd type.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. service mongod stop
2. service mongod start && mongo
# service mongod start && mongo
Redirecting to /bin/systemctl start mongod.service
MongoDB shell version: 2.0.2
connecting to: test
Wed May 23 14:10:49 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
It breaks our Katello installer, we need to implement a "sleep" workaround until this is fixed: https://bugzilla.redhat.com/show_bug.cgi?id=824362
I see that mongodb already uses a pipe to communicate the readiness of the child process to the parent after writing its PID file. So far so good. However, it sets up its listening sockets later than this.
A common meaning of readiness is that the daemon is accepting connections.
Hey, I just found the timeout is caused by mongo data files preallocation during its very first start. This is nasty behaviour, I'd like to see a script or sysvinit command that would allow external preallocation. Something like:
service mongod init
with this content:
dd if=/dev/zero of=/var/lib/mongodb/journal/prealloc.0 bs=1M count=1K
dd if=/dev/zero of=/var/lib/mongodb/journal/prealloc.1 bs=1M count=1K
dd if=/dev/zero of=/var/lib/mongodb/journal/prealloc.2 bs=1M count=1K
(In reply to comment #2)
> dd if=/dev/zero of=/var/lib/mongodb/journal/prealloc.0 bs=1M count=1K
> dd if=/dev/zero of=/var/lib/mongodb/journal/prealloc.1 bs=1M count=1K
> dd if=/dev/zero of=/var/lib/mongodb/journal/prealloc.2 bs=1M count=1K
That doesn't work with smallfiles=True, right?
I guess it would work - the file would be left unused then. But the init script could grep this option yeah...
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.
(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)
More information and reason for this action is here:
This message is a notice that Fedora 19 is now at end of life. Fedora
has stopped maintaining and issuing updates for Fedora 19. It is
Fedora's policy to close all bug reports from releases that are no
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.
Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.
Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 19 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.
Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.
This is fixed in rawhide (also in F21). Closed...
Feel free to reopen.