Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1434

Document low server selection timeout in development mode

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.8.0.rc0, 2.7.1
    • Affects Version/s: None
    • Component/s: Docs
    • Labels:
      None

      On my machine, attempting to connect to a port on which nothing is listening is virtually instantaneous:

      speed% time telnet localhost 27017
      Trying ::1...
      Trying 127.0.0.1...
      telnet: Unable to connect to remote host: Connection refused
      telnet localhost 27017  0.00s user 0.00s system 90% cpu 0.003 total
      

      If I have a web application using mongo, mongod is on the local machine to the web server and is not running, the application hangs for 30 seconds doing nothing. As it is normal for applications to take some time to load, every time I hit an application whose mongod is not running I am initially thinking that the application is loading, then I start wondering why it's taking so long, and eventually it dawns on me that there is no loading going on because mongod is turned off and the application is just sitting there wasting my time. This realization is rather unpleasant every time it has happened so far, and the fact that I know that this is the driver's behavior doesn't make it any less unpleasant.

      I also know that on my local machine a mongod is not going to magically start if it's not running. Mongod starting is a result of me performing a manual start. Hence the application (or test suite) sitting there for 30 seconds doing nothing in the hopes that a mongod will materialize only delays the time when mongod will actually spring into existence.

      Therefore what I would like to have is an option to the driver to immediately raise Mongo::Error::NoServerAvailable in the following situations:

      1. The driver checked all servers in the seed list and all of those connections failed. I think it's fine to allow all networks errors here including timeouts, not just connection refused, but we can start with non-timeout network errors.
      2. The driver was able to connect to some/all servers in the seed list, and topology was configured to be replica set, and none of the servers had a replica set name matching what the driver was expecting. If the driver then normally attempts (or is meant to attempt) to reconnect to all seeds in the hope that they would change their replica set name, with the fail fast option turned on an immediate failure would instead be produced.
      3. The driver was able to connect to some/all servers and the topology that it discovered did not match the topology that it wanted, hence it removed or discarded all servers.

      This fail fast option could then be turned on by default by mongoid in development and test environments.

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: