Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-1037

secondaryPreferred read preference is not forwarded to mongos

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.1.0
    • Affects Version/s: 1.2.3, 2.0.0
    • Component/s: None
    • None

      The Rust driver currently follows the outdated wording of the server selection which instructs drivers not to forward secondaryPreferred read preferences to mongos. This guidance was intended for use with OP_QUERY, not OP_MSG, and results in secondaryPreferred reads always going to the primary.

      repro:

      #[tokio::main(flavor = "multi_thread", worker_threads = 5)]
      async fn main() -> Result<(), Box<dyn Error>> {
          let client = Client::with_uri_str("mongodb://127.0.0.1:27017").await.unwrap();
      
          let rp = ReadPreference::SecondaryPreferred { options: Default::default() };
          let doc = client.database("admin").run_command(doc! { "hello": 1 }, SelectionCriteria::ReadPreference(rp)).await?;
          assert!(!doc.get_bool("isWritablePrimary")?);
      
          Ok(())
      }
      
      

            Assignee:
            abraham.egnor@mongodb.com Abraham Egnor
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: