Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1271

Fail to read when server topology is not ready.

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • 3.5
    • Affects Version/s: 3.4
    • Component/s: None
    • Environment:

      uwsgi setup on every 4 minutes reload (it's important)
      Connect to MongoDB via register_connection:
      mongo_db =

      {'name': 'name', 'username': 'username', 'password': 'password', 'host': 'host1,host2,host10', 'read_preference': ReadPreference.SECONDARY_PREFERRED, 'ssl': True, 'ssl_certfile': '/etc/ssl/mongodb.pem', 'ssl_ca_certs': '/etc/ssl/mongodb-ca.crt', 'socketKeepAlive': True, 'connectTimeoutMS': 3000, 'socketTimeoutMS': 3000, 'maxIdleTimeMS': 3000, }

      Sometime after reload read operation give error:
      Traceback (most recent call last):
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/flask/app.py", line 1997, in _call_
      return self.wsgi_app(environ, start_response)
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/werkzeug/contrib/fixers.py", line 152, in _call_
      return self.app(environ, start_response)
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
      response = self.handle_exception(e)
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
      return cors_after_request(app.make_response(f(*args, **kwargs)))
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
      reraise(exc_type, exc_value, tb)
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
      response = self.full_dispatch_request()
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
      rv = self.handle_user_exception(e)
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
      return cors_after_request(app.make_response(f(*args, **kwargs)))
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
      reraise(exc_type, exc_value, tb)
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
      rv = self.dispatch_request()
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
      File "./tools/utils.py", line 158, in view_func
      return f(*args, **kwargs)
      File "./bproute/tools.py", line 369, in get_main_statistics
      tenders_num_total = TenderRequest.objects(Q(is_confirmed=True)).count() or 1
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/mongoengine/queryset/manager.py", line 37, in _get_
      queryset = queryset_class(owner, owner._get_collection())
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/mongoengine/document.py", line 206, in _get_collection
      cls.ensure_indexes()
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/mongoengine/document.py", line 836, in ensure_indexes
      collection.create_index(fields, background=background, **opts)
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/pymongo/collection.py", line 1529, in create_index
      self.__create_index(keys, kwargs)
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/pymongo/collection.py", line 1417, in __create_index
      with self._socket_for_writes() as sock_info:
      File "/usr/lib/python2.7/contextlib.py", line 17, in _enter_
      return self.gen.next()
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/pymongo/mongo_client.py", line 823, in _get_socket
      server = self._get_topology().select_server(selector)
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/pymongo/topology.py", line 214, in select_server
      address))
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/pymongo/topology.py", line 202, in select_servers
      selector, address)
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/pymongo/topology_description.py", line 211, in apply_selector
      selector(Selection.from_topology_description(self)))
      File "/home/sudoaccess/backend/lib/python2.7/site-packages/pymongo/topology_description.py", line 188, in apply_local_threshold
      if (s.round_trip_time - fastest) <= threshold]
      TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'
      [pid: 5747|app: 0|req: 1/6] 52.169.30.199 ()

      {30 vars in 437 bytes}

      [Wed Apr 26 22:12:12 2017] GET /api/v1/tools/main_statistics => generated 0 bytes in 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

        1. assert-rtt-not-none.patch
          0.5 kB
          A. Jesse Jiryu Davis

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            alex.kolyshkin@gmail.com Alexander Kolyshkin
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: