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

Shardset: Unrecognized command: $readPreference, code: 13390

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.6.1
    • Affects Version/s: 1.6
    • Component/s: None
    • Environment:
      Win 8 Client, connecting to either win8 MongoDB 2.2 shardset or Ubuntu 2.2 shardset

      Connecting to a 2.2 shard-set using the 1.6 driver results in the following exception:

      MongoDB.Driver.MongoQueryException was unhandled
        HResult=-2146233088
        Message=QueryFailure flag was unrecognized command: $readPreference (response was {"$err" : "unrecognized command: $readPreference", "code" : 13390 }).
        Source=MongoDB.Driver
        StackTrace:
             at MongoDB.Driver.Internal.MongoReplyMessage`1.ReadFrom(BsonBuffer buffer, IBsonSerializationOptions serializationOptions) in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Internal\MongoReplyMessage.cs:line 99
             at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument](BsonBinaryReaderSettings readerSettings, IBsonSerializationOptions serializationOptions) in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Internal\MongoConnection.cs:line 475
             at MongoDB.Driver.MongoCursorEnumerator`1.GetReply(MongoConnection connection, MongoRequestMessage message) in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Core\MongoCursorEnumerator.cs:line 296
             at MongoDB.Driver.MongoCursorEnumerator`1.GetFirst() in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Core\MongoCursorEnumerator.cs:line 253
             at MongoDB.Driver.MongoCursorEnumerator`1.MoveNext() in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Core\MongoCursorEnumerator.cs:line 141
             at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
             at MongoDB.Driver.MongoCollection.FindOneAs[TDocument](IMongoQuery query) in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Core\MongoCollection.cs:line 557
             at MongoDB.Driver.MongoCollection`1.FindOne(IMongoQuery query) in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Core\MongoCollection.cs:line 1734
             at MongoDB.Driver.MongoDatabase.RunCommandAs(Type commandResultType, IMongoCommand command) in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Core\MongoDatabase.cs:line 973
             at MongoDB.Driver.MongoDatabase.RunCommandAs[TCommandResult](IMongoCommand command) in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Core\MongoDatabase.cs:line 950
             at MongoDB.Driver.MongoDatabase.RunCommand(IMongoCommand command) in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Core\MongoDatabase.cs:line 928
             at MongoDB.Driver.MongoCollection.Count(IMongoQuery query) in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Core\MongoCollection.cs:line 158
             at MongoDB.Driver.MongoCollection.Count() in c:\mongodb-mongo-csharp-driver-v1.6.0.4624-4-g10826e1\mongodb-mongo-csharp-driver-10826e1\Driver\Core\MongoCollection.cs:line 143
             at MongoTest.Program.Main(String[] args) in c:\Users\kennyi\Documents\Visual Studio 2012\Projects\MongoTest\MongoTest\Program.cs:line 18
             at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
             at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
             at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
             at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
             at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
             at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
             at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
             at System.Threading.ThreadHelper.ThreadStart()
        InnerException: 
      

      To repro, start a simple sharded replicaset:

      mongod.exe --shardsvr --replSet rs_a --port 27020 --dbpath c:\data\rs_a\n1
      mongod.exe --shardsvr --replSet rs_a --port 27021 --dbpath c:\data\rs_a\n2
      mongod.exe --shardsvr --replSet rs_a --port 27022 --dbpath c:\data\rs_a\n3
      
      mongod.exe --configsvr --port 27030 --dbpath c:\data\config\c1
      mongod.exe --configsvr --port 27031 --dbpath c:\data\config\c2
      mongod.exe --configsvr --port 27032 --dbpath c:\data\config\c3
      
      mongos.exe --configdb my-machine:27030,my-machine:27031,my-machine:27032
      
      cfg = {
          _id : "rs_a",
          members : [
              {_id : 0, host : "my-machine:27020", priority : 1},
              {_id : 1, host : "my-machine:27021", priority : 1},
              {_id : 2, host : "my-machine:27022", priority : 0}
          ]}
      rs.initiate(cfg)
      db.adminCommand( { addShard : "rs_a/my-machine:27020,my-machine:27021,my-machine:27022" } )
      

      And call with the following code:

                  var server = MongoServer.Create("mongodb://my-machine");
                  var db = server.GetDatabase("test");
                  Console.WriteLine("Found {0} transactions", db.GetCollection("test").Count());
      

      However, if I connect to the same shard-set with the same code, but using version 1.4.2 of the driver, it works fine

            Assignee:
            craig.wilson@mongodb.com Craig Wilson
            Reporter:
            kenny.inggs Kenny Inggs
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: