[SERVER-32766] net.bindIpAll with net.ipv6 fails with "listen: Address already in use, terminating" Created: 18/Jan/18  Updated: 30/Oct/23  Resolved: 28/Jan/18

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: 3.6.2
Fix Version/s: 3.6.3, 3.7.2

Type: Bug Priority: Minor - P4
Reporter: Olav Morken Assignee: Sara Golemon
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Debian Jessie


Attachments: Text File mongodb-ipv6-bindall-log.txt    
Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6
Steps To Reproduce:

1. Create a temporary empty data directory for the database: mkdir /tmp/delete-me-test-mongodb-bindall
2. Try to start MongoDB with the --ipv6 and bind_ip_all options: mongod --port 35723 --ipv6 --bind_ip_all --dbpath /tmp/delete-me-test-mongodb-bindall/

Participants:

 Description   

Enabling both net.bindIpAll (--bind_ip_all) and net.ipv6 (--ipv6) results in the server failing to start with the following error message:

exception in initAndListen std::exception: listen: Address already in use, terminating

The same thing occurs if specifying --bind_ip 0.0.0.0,:: with the --ipv6 option.

A workaround for this issue is to specify --bind_ip with all IPv4 & IPv6 addresses of the server.

The log output is attached as mongodb-ipv6-bindall-log.txt.



 Comments   
Comment by Githook User [ 31/Jan/18 ]

Author:

{'email': 'sara.golemon@mongodb.com', 'name': 'Sara Golemon', 'username': 'sgolemon'}

Message: SERVER-32766 Address already in use with bind_ip_all and ipv6

(cherry picked from commit d887ee0da56d4f099e3bec9f1079467ec465850c)
Branch: v3.6
https://github.com/mongodb/mongo/commit/cffb06a769d4f59fed460de930cfc51cd0cc4b09

Comment by Sara Golemon [ 28/Jan/18 ]

Issue fixed on master branch. Backport for 3.6 requested.

Comment by Githook User [ 28/Jan/18 ]

Author:

{'email': 'sara.golemon@mongodb.com', 'name': 'Sara Golemon', 'username': 'sgolemon'}

Message: SERVER-32766 Address already in use with bind_ip_all and ipv6
Branch: master
https://github.com/mongodb/mongo/commit/d887ee0da56d4f099e3bec9f1079467ec465850c

Comment by Sara Golemon [ 28/Jan/18 ]

Hello Olav;
Indeed, thank you for the clear description. It took some digging, but I found the issue and I'm genuinely surprised both that we didn't have a test for this, and that it took a couple releases for someone to notice.

The fix is currently in review, and should hopefully find its way back to 3.6 shortly. In the mean time, you should be able to bind all addresses on your 3.6 system by specifying:

--bind_ip '::' --ipv6

Note the lack of of the IPv4 formatted "0.0.0.0". Ordinarily this would NOT work, but our new transport layer was missing an option which disables IPv4-in-IPv6 mapped addresses. Since both 0.0.0.0 and :: would therefore cover the 0.0.0.0 range, we get the "address already in use" message.

Once the fix is in, and you upgrade to a version which has the fix, you'll want to put 0.0.0.0 back into that list, or better yet just use --bind_ip_all directly at that time.

Comment by Kelsey Schubert [ 19/Jan/18 ]

Thanks for the clear reproduction steps, olavmrk – we're investigating the issue and will update this ticket as we progress.

Comment by Olav Morken [ 18/Jan/18 ]

Sorry for the incorrectly formatted issue description; It was appears that using monospaced with option names in some cases result in JIRA formatting it as strike-through instead. Unfortunately I cannot edit the description to fix it.

Generated at Thu Feb 08 04:31:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.