Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1537

Find operations should send read preference correctly when connected to a sharded cluster

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Critical - P2
    • Resolution: Fixed
    • 2.2
    • 2.2.3
    • Operations
    • Client: .Net Driver 2.2.2 on Windows 10 / .Net 4.6.1
      Server: 3.2.1 Shard on Debian

    Description

      Following example shows how to reproduce the Exception

      Command find failed: Failed to parse: { find: "bar", filter: {}, skip: 0, readPreference: { mode: "secondaryPreferred", tags: [ { dc: "ny", rack: "1" }, { dc: "sf" } ] }, noCursorTimeout: false, allowPartialResults: false }. Unrecognized field 'readPreference'..
      

      Driver from NuGet Package: (Legacy) Official C# driver for MongoDB 2.2.2

      var tagSets = new TagSet[]
      {
          new TagSet(new [] { new Tag("dc", "ny"), new Tag("rack", "1") }),
          new TagSet(new [] { new Tag("dc", "sf") })
      };
       
      MongoClientSettings clientSettings = new MongoClientSettings
      {
          Server = new MongoServerAddress("server"),
          ReadPreference = ReadPreference.SecondaryPreferred.With(tagSets)   <---- Exception
          //ReadPreference = ReadPreference.SecondaryPreferred   <----- Working
      };
       
      MongoClient client = new MongoClient(clientSettings);
      MongoServer server = client.GetServer();
      MongoDatabase database = server.GetDatabase("foo");
      MongoCollection<BsonDocument> collection = database.GetCollection<BsonDocument>("bar");
       
      MongoCursor<BsonDocument> cursor = collection.FindAll();
       
      foreach (BsonDocument bsonDocument in cursor)
      {
          Console.WriteLine(bsonDocument.ToString());
      }
      

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            mac866 Alice Mauschberger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: