[SERVER-1253] in Master-Master replication ismaster is 0 on both nodes Created: 18/Jun/10  Updated: 12/Jul/16  Resolved: 13/Jul/10

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 1.5.5

Type: Bug Priority: Major - P3
Reporter: Cheenu Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

all mongo versions


Attachments: Text File mongod-ismaster-fix.patch    
Operating System: ALL
Participants:

 Description   

Configured as per http://www.mongodb.org/display/DOCS/Master+Master+Replication

Startup commands:
/opt/mongodb-1.5.3/bin/mongod --port 27017 --dbpath /opt/tmp/mongodbdata --master --slave --source localhost:27018 --rest
/opt/mongodb-1.5.3/bin/mongod --port 27018 --dbpath /opt/tmp/mongodbdata2 --master --slave --source localhost:27017 --rest

But, neither node are master:
$/opt/mongodb-1.5.3/bin/mongo localhost:27017 --eval "printjson(db.\ $cmd.findOne(

{ismaster:1}

));"
MongoDB shell version: 1.5.3
connecting to: localhost:27017/test

{ "ismaster" : 0, "msg" : "not paired", "ok" : true }

$/opt/mongodb-1.5.3/bin/mongo localhost:27018 --eval "printjson(db.\ $cmd.findOne(

{ismaster:1}

));"
MongoDB shell version: 1.5.3
connecting to: localhost:27018/test

{ "ismaster" : 0, "msg" : "not paired", "ok" : true }

Michael Dirolf confirmed:
Okay I can reproduce this. Seems to me that ismaster should be true
when running w/ both --master and --slave. Mind opening a jira for
this?



 Comments   
Comment by auto [ 14/Jul/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: more tests for ismaster SERVER-1253
http://github.com/mongodb/mongo/commit/b443d7c0b902cac4b03fa6fefaaf08b0da8bf98d

Comment by auto [ 14/Jul/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: fix ismaster for master/master SERVER-1253
http://github.com/mongodb/mongo/commit/564f6d8f1eb916e35f67a28ac40f079259201c0b

Comment by auto [ 13/Jul/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: in master/master ismaster should be 1 SERVER-1253
http://github.com/mongodb/mongo/commit/164efbd0a2138d1612154e857caf90843ed3d697

Comment by Kazuki Ohta [ 03/Jul/10 ]

Thanks for the comment! I want to know about your concern, if this patch leads to something bad.

Comment by Eliot Horowitz (Inactive) [ 03/Jul/10 ]

We'll do something similar - need to test thoroughly before pushing though

Comment by Kazuki Ohta [ 03/Jul/10 ]

The attached patch fixed the problem.

kzk% ./mongo localhost:27017 --eval "printjson(db.\$cmd.findOne(

{ismaster:1}

));"
MongoDB shell version: 1.5.5-pre-
connecting to: localhost:27017/test

{ "ismaster" : 1, "msg" : "not paired", "ok" : true }

kzk% ./mongo localhost:27018 --eval "printjson(db.\$cmd.findOne(

{ismaster:1}

));"
MongoDB shell version: 1.5.5-pre-
connecting to: localhost:27018/test

{ "ismaster" : 1, "msg" : "not paired", "ok" : true }

Also confirmed that ScopedDbConnection correctly worked.

kzk% g++ -I. -I/opt/local/include/ -L. -L/opt/local/lib/ -lmongoclient -lboost_thread-mt -lboost_system-mt test.cpp; ./a.out
kzk% # no error occurred

Finally, I also confirmed that ismaster shows the proper value in the master-slave configuration.

Could you check the patch, and commit to the repository? I'm really happy if this patch is also applied to stable branch. Because we're now trying to use master-master replication in the production environment.

Thanks in advance
Kazuki

Comment by Kazuki Ohta [ 03/Jul/10 ]

This problem prevents using ScopedDbConnection for master-master replication.

int
main()
{
try

{ mongo::ScopedDbConnection c("localhost:27017,localhost:27018"); c.done(); }

catch (exception& e)

{ cerr << e.what() << endl; }

}

kzk% g++ -I. -I/opt/local/include/ -L. -L/opt/local/lib/ -lmongoclient -lboost_thread-mt -lboost_system-mt test.cpp; ./a.out
dbconnectionpool: connect failed [2] localhost:27017,localhost:27018

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