[JAVA-648] The driver does not start if the replica set is not available Created: 19/Sep/12  Updated: 21/Sep/12  Resolved: 20/Sep/12

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 2.9.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Lukas Krecan Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

We want our application to start even though no replica-set seed is accessible.
Version 2.8.0 just logged an error message. Version 2.9.1 gets stuck in an infinite loop in com.mongodb.DynamicConnectionStatus.initExecutorService() printing

WARNING: Server seen down: /127.0.0.1:27017 - java.io.IOException - message: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused
Sep 19, 2012 10:30:49 AM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: /127.0.0.1:27017 - java.io.IOException - message: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused
Sep 19, 2012 10:30:49 AM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: /127.0.0.1:27017 - java.io.IOException - message: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused
Sep 19, 2012 10:30:49 AM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: /127.0.0.1:27017 - java.io.IOException - message: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused
Sep 19, 2012 10:30:49 AM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: /127.0.0.1:27017 - java.io.IOException - message: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused
Sep 19, 2012 10:30:49 AM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: /127.0.0.1:27017 - java.io.IOException - message: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused
Sep 19, 2012 10:30:49 AM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: /127.0.0.1:27017 - java.io.IOException - message: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused
Sep 19, 2012 10:30:49 AM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: /127.0.0.1:27017 - java.io.IOException - message: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused
Sep 19, 2012 10:30:49 AM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: /127.0.0.1:27017 - java.io.IOException - message: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused
Sep 19, 2012 10:30:49 AM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: /127.0.0.1:27017 - java.io.IOException - message: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused
Sep 19, 2012 10:30:49 AM com.mongodb.ConnectionStatus$UpdatableNode update
...

The Mongo constructor never finishes.

Would it be possible to change the behavior? Or is it a feature?



 Comments   
Comment by Lukas Krecan [ 21/Sep/12 ]

Created JAVA-649

Comment by Jeffrey Yemin [ 20/Sep/12 ]

Confirmed that connectTimeout is being ignored in this case. Thanks for finding this, and please do open a new bug for it.

Comment by Lukas Krecan [ 20/Sep/12 ]

Sorry, our first investigation was wrong. Our situation was like this:

        MongoOptions options = new MongoOptions();
        options.connectTimeout = 1000;
 
        Mongo m = new Mongo(Arrays.asList(new ServerAddress("localhost:27017")), options);
        try {
            m.getDB("test").collectionExists("test");
        } finally {
            m.close();
        }

Connection timeout is ignored in this case. Default 20s timeout is applied in the constructor of ConnectionStatus. I guess it's a bug but a different one. Feel free to close this issue and I can file a new one about the connection timeout if you confirm that it's indeed a bug.

Comment by Jeffrey Yemin [ 19/Sep/12 ]

I can't reproduce what you're seeing. If I run the following code with the replica set entirely down, the program completes:

        Mongo m = new Mongo(Arrays.asList(new ServerAddress("localhost:27017"), new ServerAddress("localhost:27018"),
                new ServerAddress("localhost:27019")));
        m.close();

You will see those error messages, but they are generated in a separate thread, and are not preventing the Mongo constructor from completing.

Generated at Thu Feb 08 08:52:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.