
OPERATIONAL DEFECT DATABASE
...


...

ConnectBG handles asynchronous connects by spinning up a background thread to call ::connect(). We kick that thread out of connect, after a timeout, by calling close. This isn't safe because: Thread A: Your call to Socket::connect() Thread B: BG connector for A Thread C: Unrelated thread calling Socket::connect() Thread D: BG connector for C Thread A Thread B Thread C Thread D Start Thread B connect(N) Wait 4.9999 seconds get EINTR Trigger timeout shutdown(N) close(N) N = socket() connect(N) connect(N) errno == EISCONN Which can lead us to connect a fd to the wrong endpoint. We can work around this by only calling shutdown from the parent thread, waiting for the child to join, then calling close.
xgen-internal-githook commented on Thu, 8 Dec 2016 19:14:36 +0000: Author: {u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'} Message: SERVER-27240 Replace ConnectBG with poll It's unsafe to close a socket from another thread. Also, after returning EINTR, the connect call converts to an async call. And on non-linux systems that requires a fallback to poll/select to handle errors. Because of that, let's just do the connect without the background thread at all, starting off with poll. (cherry picked from commit a1baabeee5694aa8c4ffa1827233684d6c7fcc49) Branch: v3.0 https://github.com/mongodb/mongo/commit/80775cd49db61ec792313da630158a2904faa75f xgen-internal-githook commented on Thu, 8 Dec 2016 16:57:09 +0000: Author: {u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'} Message: SERVER-27240 Replace ConnectBG with poll It's unsafe to close a socket from another thread. Also, after returning EINTR, the connect call converts to an async call. And on non-linux systems that requires a fallback to poll/select to handle errors. Because of that, let's just do the connect without the background thread at all, starting off with poll. (cherry picked from commit a1baabeee5694aa8c4ffa1827233684d6c7fcc49) Branch: v3.2 https://github.com/mongodb/mongo/commit/30e9f786ee94166adc1b6b3ba98b672d47604f95 xgen-internal-githook commented on Thu, 8 Dec 2016 16:50:53 +0000: Author: {u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'} Message: SERVER-27240 Replace ConnectBG with poll It's unsafe to close a socket from another thread. Also, after returning EINTR, the connect call converts to an async call. And on non-linux systems that requires a fallback to poll/select to handle errors. Because of that, let's just do the connect without the background thread at all, starting off with poll. (cherry picked from commit a1baabeee5694aa8c4ffa1827233684d6c7fcc49) Branch: v3.4 https://github.com/mongodb/mongo/commit/e4113518e7b0f9dcdfe582d91f4f00dcc0589661 xgen-internal-githook commented on Wed, 7 Dec 2016 20:58:30 +0000: Author: {u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'} Message: SERVER-27240 Replace ConnectBG with poll It's unsafe to close a socket from another thread. Also, after returning EINTR, the connect call converts to an async call. And on non-linux systems that requires a fallback to poll/select to handle errors. Because of that, let's just do the connect without the background thread at all, starting off with poll. Branch: master https://github.com/mongodb/mongo/commit/a1baabeee5694aa8c4ffa1827233684d6c7fcc49
MongoDB Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.