Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-752

Server selection times out immediately on Solaris

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 1.2-beta0
    • Affects Version/s: 1.2.0
    • Component/s: None
    • None
    • Environment:
      Solaris 11, x86_64

      In 1.2.0-dev, mongoc_topology_select is responsible for selecting a server from your deployment for an operation. In pooled clients, if mongoc_topology_select doesn't know of a suitable server, it uses a condition variable to wait up to serverSelectionTimeoutMS for the monitor thread to discover one.

      To use pthread_cond_wait, the driver begins by calculating the current time in milliseconds since the epoch:

         struct timeval tv;
         int64_t msec;
      
         bson_gettimeofday (&tv);
         msec = (tv.tv_sec * 1000) + (tv.tv_usec / 1000) + timeout_msec;
      

      This works on platforms where tv_sec is a 64-bit int, but on Solaris it's 32 bits and overflows. (These days, representing tv_sec requires 31 bits, so multiplying it by 1000 overflows.)

      The driver constructs a negative timespec from this calculation and passes it to pthread_cond_wait, which returns EINVAL and mongoc_topology_select quits.

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: