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

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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.4.0
    • Affects Version/s: 1.2.0
    • Component/s: None
    • None

      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.

            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: