[SERVER-16292] mongod isn't ready for connections when it finishes a fork Created: 24/Nov/14  Updated: 22/Sep/17  Resolved: 22/Sep/16

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

Type: Improvement Priority: Minor - P4
Reporter: Asya Kamsky Assignee: Samantha Ritter (Inactive)
Resolution: Done Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-16581 Init script should return only after ... Closed
related to SERVER-31225 The mongod process forks before liste... Closed
is related to SERVER-7306 Mongod as windows service should not ... Closed
Backwards Compatibility: Fully Compatible
Sprint: Platforms 2016-08-26, Platforms 2016-09-19, Platforms 2016-10-10
Participants:

 Description   

Not sure which component this is but I have a script which starts mongod and then runs a status command against it:

Mon Nov 24 02:25:04 CST 2014  Starting mmapv1-ycsb test
about to fork child process, waiting until server is ready for connections.
forked process: 26239
child process started successfully, parent exiting
2014-11-24T02:26:50.744-0600 W NETWORK  Failed to connect to 127.0.0.1:27077, reason: errno:111 Connection refused
2014-11-24T02:26:50.746-0600 I QUERY    Error: couldn't connect to server 127.0.0.1:27077 (127.0.0.1), connection attempt failed
    at connect (src/mongo/shell/mongo.js:181:14)
    at (connect):1:21 at src/mongo/shell/mongo.js:181
exception: connect failed

Corresponding lines from the log:

2014-11-24T02:26:50.667-0600 I CONTROL  [initandlisten] MongoDB starting : pid=26239 port=27077 dbpath=/disk1/db/mmapv1-ycsb 64-bit host=asya.mongodb.com
2014-11-24T02:26:50.668-0600 I CONTROL  [initandlisten] db version v2.8.0-rc2-pre-
2014-11-24T02:26:50.668-0600 I CONTROL  [initandlisten] git version: e4329ae5e7bfb56ef9b63a8388285b70b7ec9634
2014-11-24T02:26:50.668-0600 I CONTROL  [initandlisten] build info: Linux build11.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-11-24T02:26:50.668-0600 I CONTROL  [initandlisten] allocator: tcmalloc
2014-11-24T02:26:50.668-0600 I CONTROL  [initandlisten] options: { net: { port: 27077 }, processManagement: { fork: true }, storage: { dbPath: "/disk1/db/mmapv1-ycsb", engine: "mmapv1", journal: { enabled: false }
}, systemLog: { destination: "file", path: "/home/asya/logs/mmapv1-ycsb.log" } }
2014-11-24T02:26:50.706-0600 I INDEX    [initandlisten] allocating new ns file /disk1/db/mmapv1-ycsb/local.ns, filling with zeroes...
2014-11-24T02:26:50.732-0600 I STORAGE  [FileAllocator] allocating new datafile /disk1/db/mmapv1-ycsb/local.0, filling with zeroes...
2014-11-24T02:26:50.732-0600 I STORAGE  [FileAllocator] creating directory /disk1/db/mmapv1-ycsb/_tmp
2014-11-24T02:26:50.745-0600 I STORAGE  [FileAllocator] done allocating datafile /disk1/db/mmapv1-ycsb/local.0, size: 64MB,  took 0 secs
2014-11-24T02:26:50.748-0600 I NETWORK  [initandlisten] waiting for connections on port 27077
2014-11-24T02:26:51.159-0600 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:53032 #1 (1 connection now open)

You can see that it is waiting for connections as of T02:26:50.748 but it passed control back before T02:26:50.744 as by then the shell already tried to connect again to run command.



 Comments   
Comment by Githook User [ 22/Sep/16 ]

Author:

{u'username': u'samantharitter', u'name': u'samantharitter', u'email': u'samantha.ritter@10gen.com'}

Message: SERVER-16292 Wait to fork until the server is listening
Branch: master
https://github.com/mongodb/mongo/commit/c4e24cbbfd3948273c27726c0170b562eca30bb4

Comment by Mira Carey [ 20/May/16 ]

3.3 required that we should either decide to do this or decide that this isn't what we want (if we want to remove constraints on new transport layers)

Comment by Eric Milkie [ 24/Nov/14 ]

The code has never intentionally signaled a successful fork after the child started listening for connections; it merely was "pretty close" to such time and was never guaranteed. If this is a feature that we want to have, we should switch this to a feature ticket; otherwise it's Works as designed.

Generated at Thu Feb 08 03:40:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.