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

Rand used to pick Mongo server is not seeded

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • None
    • 1.5.0
    • libmongoc
    • None

    Description

      The call to rand() used when selecting a server is unseeded (https://github.com/mongodb/mongo-c-driver/blob/a4bcfffa9c7ffa2e541a3351ec26cfad417cbdcf/src/mongoc/mongoc-topology-description.c#L693)

      This tends to manifest itself as uneven balancing between nodes in a cluster.

      As a specific example: when libmongoc is used as part of, say, the php-driver:

      1. A sudden increase in traffic creates new children (e.g. Apache workers)
      2. The new workers create new connections to mongo using the php-driver, and therefore libmongoc
      3. All workers initially choose the same server from the cluster as the first value from rand() is always the same
      4. One mongo node takes the vast majority of the queries - possibly causing it to become overloaded while other nodes in the cluster receive little traffic

      Attachments

        Issue Links

          Activity

            People

              jesse@mongodb.com A. Jesse Jiryu Davis
              tomnomnom Tom Hudson
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: