[SERVER-31206] SystemD services depending on mongod will be started before mongo is ready to take connections Created: 21/Sep/17 Updated: 07/Dec/17 Resolved: 07/Nov/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Packaging |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Stephen Lynx | Assignee: | Mark Agarunov |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | init-script, systemd | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Centos 7 |
||
| Issue Links: |
|
||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||
| Steps To Reproduce: | Make a systemD script that is set to start after mongod. |
||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Description |
|
I have the following systemD script for my software:
See "After=mongod.service". Because of that, my software expects mongo to be ready to take connections when it is booted by this init script. |
| Comments |
| Comment by Mark Agarunov [ 07/Nov/17 ] | |
|
Hello stephenlynx, After further investigation of this issue in Thanks, | |
| Comment by Mark Agarunov [ 21/Sep/17 ] | |
|
Hello stephenlynx, I've managed to reproduce this behavior with centos7 and mongodb 3.4.9. We are still investigating this behavior, however as a workaround in my testing I found a 1 second sleep added to ExecStartPre allowed enough time for MongoDB to start listening before attempting to connect. Thanks, | |
| Comment by Stephen Lynx [ 21/Sep/17 ] | |
|
Also, are you telling me that the new systemD init script not being able to do something basic the sysvinit script did isn't a bug? | |
| Comment by Stephen Lynx [ 21/Sep/17 ] | |
|
So you are telling me there is NO WAY for mongod to be actually ready when the service is done starting? | |
| Comment by Mark Agarunov [ 21/Sep/17 ] | |
|
Hello, Thank you for the report. To have your service wait for MongoDB before starting, you could add the following line to your [Service] section:
This should allow enough some time for MongoDB to accept connections. Alternatively, you can modify your service to check if the socket is open before connecting, or to retry on failure to connect. I do not see anything to indicate a bug in the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-user group. See also our Technical Support page for additional support resources. Thanks, |