[SERVER-13177] mongooplog crashes on assertion when it cannot connect to "from" host Created: 12/Mar/14  Updated: 26/Jul/14  Resolved: 23/Jul/14

Status: Closed
Project: Core Server
Component/s: Tools
Affects Version/s: 2.5.0
Fix Version/s: 2.7.4

Type: Bug Priority: Trivial - P5
Reporter: Shaun Verch Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: community-team, neweng, pull-request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

With nothing running on "localhost:27017" and a mongod on "localhost:30001":

$ ./mongooplog --verbose --from localhost:27017 --host localhost:30001
2014-03-12T17:36:54.783-0400 creating new connection to:localhost:30001
2014-03-12T17:36:54.784-0400 [ConnectBG] BackgroundJob starting: ConnectBG
2014-03-12T17:36:54.785-0400 connected to server localhost:30001 (127.0.0.1)
2014-03-12T17:36:54.785-0400 connected connection!
connected to: localhost:30001
2014-03-12T17:36:54.785-0400 going to connect
2014-03-12T17:36:54.785-0400 [ConnectBG] BackgroundJob starting: ConnectBG
2014-03-12T17:36:54.785-0400 [oplogreplay] warning: Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2014-03-12T17:36:54.785-0400 [oplogreplay] repl: couldn't connect to server localhost:27017 (127.0.0.1), connection attempt failed
2014-03-12T17:36:54.785-0400 connected
2014-03-12T17:36:54.785-0400 starting from Mar 11 17:36:54:0
Assertion failed: (px != 0), function operator->, file src/third_party/boost/boost/smart_ptr/shared_ptr.hpp, line 424.
Abort trap: 6

Participants:

 Description   

When mongooplog tries to connect to the from host, it assumes it has connected successfully and tries to access the connection object.



 Comments   
Comment by Githook User [ 23/Jul/14 ]

Author:

{u'username': u'nitinbhatt', u'name': u'Nitin Bhatt', u'email': u'bhatt_nitin@hotmail.com'}

Message: SERVER-13177 mongooplog - Checking return value of connect. Proceed only if connected.

Closes #715

Signed-off-by: Benety Goh <benety@mongodb.com>
Branch: master
https://github.com/mongodb/mongo/commit/296c18571dd7decd33fdf62f0a23869129682264

Comment by Shaun Verch [ 10/Jun/14 ]

We don't check the return value of trying to connect the oplog reader to the "from" host here: https://github.com/mongodb/mongo/blob/r2.7.1/src/mongo/tools/oplog.cpp#L58 and then use it again here: https://github.com/mongodb/mongo/blob/r2.7.1/src/mongo/tools/oplog.cpp#L65. I suspect that there is some kind of invalid state in the oplog reader that causes the exception we see above, which indicates we are trying to dereference a null shared pointer. The solution would be to check the return value of the "connect()" call on the oplog reader and return a helpful error to the user if we fail to connect.

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