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

SecondaryPreferred fails if primary matches tags but secondaries don't.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.2.0
    • Fix Version/s: 1.4.0
    • Component/s: None
    • Labels:
      None
    • Story Points:
      8
    • Sprint:
      C Driver 2016 sprint 5

      Description

      Server Selection logic bug. Assume a primary P and secondary S, and a read preference with mode SecondaryPreferred and a tag set. S doesn't match the tag set, so the driver should fall back to using the primary.

      There's a bug if P happens to match the read preference's tag set. The driver selects no servers instead of using the primary.

      mongoc_topology_description_suitable_servers's logic is:

      1. Set has_secondary true, because there is a secondary S.
      2. Select "eligible" servers according to the tag set: this leaves only P.
      3. Since there is at least one eligible server, leave has_secondary true.
      4. Since has_secondary is true and mode is SecondaryPreferred, remove P from suitable servers.
      5. Now there are no suitable servers, selection fails.

      The bug is near #3: has_secondary should only be true if there is an eligible secondary, rather than if there is any eligible server?

      Another option is to partly rewrite the C Driver's server selection based on how other clients do SecondaryPreferred: try selection with mode Secondary, if that fails then select with mode Primary. For PrimaryPreferred, vice versa.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: