-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 2.9.0, 2.9.1
-
Component/s: Cluster Management
-
None
-
Environment:Windows 7 x64
mongodb 2.0.4
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I have faced with possibility to specify two (or more) independent nodes as replica set via MongoURI(...) parameter.
E.g. I started two independent nodes...
mongod.exe --dbpath .\1\db\ --rest --logappend --logpath .\1\mongo\log --port=1234 mongod.exe --dbpath .\2\db\ --rest --logappend --logpath .\2\mongo\log --port=5678
... and configured connection like following:
Mongo con = new Mongo(new MongoURI("mongodb://127.0.0.1:1234,127.0.0.1:5678"));
There are no warnings or errors and following code behaves with illusion of correctly passed replica set configuration:
ReplicaSetStatus status = con.getReplicaSetStatus(); status.isMaster(new ServerAddress("127.0.0.1", 1234)); // true status.isMaster(new ServerAddress("127.0.0.1", 5678)); // false status.getMaster().toString(); // 127.0.0.1:1234 WriteResult r = con.getDB("x").getCollection("y").save(new BasicDBObject("a", "b")); r.getLastError().throwOnError(); // there are no errors
The only way to detect that configuration is incorrect - specify REPLICA_SAFE write concern:
con.getDB("x").getCollection("y").save(new BasicDBObject("a", "b"), WriteConcern.REPLICAS_SAFE); // com.mongodb.MongoException: norepl
- duplicates
-
JAVA-930 Detect misconfigured clusters
-
- Closed
-