Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2312

Sending $readPreference in command helper does not work

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Operations
    • None

      In the shell I can send $readPreference by hand:

      MongoDB Enterprise ruby-driver-rs:PRIMARY> db.runCommand({find:"foo",$readPreference:{}})
      {
      	"operationTime" : Timestamp(1594232502, 1),
      	"ok" : 0,
      	"errmsg" : "Missing expected field \"mode\"",
      	"code" : 4,
      	"codeName" : "NoSuchKey",
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1594232502, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      

      The driver does not allow the corresponding request:

      irb(main):002:0> c.database.command(find: "foo", '$readPreference': {})
      
      localhost:14420 #1:1 | admin.find | STARTED | {"find"=>"foo", "$readPreference"=>{"mode"=>"primary"}, "$db"=>"admin", "lsid"=>{"id"=><BSON::Binary:0x1020 type=uuid data=0x6e42f7d4fd24479a...>}}
      D, [2020-07-08T14:22:45.203680 #7382] DEBUG -- : MONGODB | [10] localhost:14420 | admin.find | FAILED | BSON field 
      
      'OperationSessionInfo.$readPreference' is a duplicate field (40413) | 0.000546408s
      Traceback (most recent call last):
             16: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/op_msg_or_command.rb:26:in `execute'
             15: from /home/w/apps/ruby-driver/lib/mongo/server.rb:425:in `with_connection'
             14: from /home/w/apps/ruby-driver/lib/mongo/server/connection_pool.rb:590:in `with_connection'
             13: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/op_msg_or_command.rb:28:in `block in execute'
             12: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/executable.rb:44:in `execute'
             11: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/executable.rb:44:in `tap'
             10: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/executable.rb:45:in `block in execute'
              9: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/response_handling.rb:26:in `validate_result'
              8: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/response_handling.rb:82:in `unpin_maybe'
              7: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/response_handling.rb:27:in `block in validate_result'
              6: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/response_handling.rb:43:in `add_error_labels'
              5: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/response_handling.rb:28:in `block (2 levels) in validate_result'
              4: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/response_handling.rb:96:in `add_server_diagnostics'
              3: from /home/w/apps/ruby-driver/lib/mongo/operation/shared/response_handling.rb:29:in `block (3 levels) in validate_result'
              2: from /home/w/apps/ruby-driver/lib/mongo/operation/result.rb:289:in `validate!'
              1: from /home/w/apps/ruby-driver/lib/mongo/operation/result.rb:321:in `raise_operation_failure'
      Mongo::Error::OperationFailure (BSON field 'OperationSessionInfo.$readPreference' is a duplicate field (40413) (on localhost:14420))
      
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: