Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-29407

BadValue error when passing readPreference option to usersInfo on a mongos only

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.4
    • Component/s: Sharding
    • None
    • Sharding
    • ALL
    • Hide

      Please run attached mongos_usersinfo_error.js test script, e.g. if placed inside jstests/sharding with command:

      python buildscripts/resmoke.py jstests/sharding/mongos_usersinfo_error.js
      

      Expect to see the following output:

      Show
      Please run attached mongos_usersinfo_error.js test script, e.g. if placed inside jstests/sharding with command: python buildscripts/resmoke.py jstests/sharding/mongos_usersinfo_error.js Expect to see the following output:

      When I run the following mongo shell command against a mongos:

      db.runCommand({$query:{usersInfo:1}, $readPreference:{mode: 'primary'}})
      

      I get the response error:

      {
      	"ok" : 0,
      	"errmsg" : "\"$queryOptions\" is not a valid argument to usersInfo",
      	"code" : 2,
      	"codeName" : "BadValue"
      }
      

      I have also observed similar behaviour in NODE-1012.

      I do not get such an error when:

      • Connecting to a standalone without auth enabled
        { "users" : [ ], "ok" : 1 }
      • Connecting to a replica set primary or secondary(1) without auth enabled
        { "users" : [ ], "ok" : 1 }
      • Connecting to a replica set primary or secondary(1) with auth enabled and not logged in
        "errmsg" : "not authorized on test to execute command { usersInfo: 1.0} "
      • Connecting to a replica set primary or secondary(1) with auth enabled and logged in with appropriate privileges, I get no error and a document containing a list of users and roles
        {
        	"users" : [
        		{
        			"_id" : "admin.limited",
        			"user" : "limited",
        			"db" : "admin",
        			"roles" : [
        				{
        					"role" : "readWrite",
        					"db" : "food"
        				},
        				{
        					"role" : "read",
        					"db" : "foo"
        				}
        			]
        		},
        		{
        			"_id" : "admin.user",
        			"user" : "user",
        			"db" : "admin",
        			"roles" : [
        				{
        					"role" : "dbAdminAnyDatabase",
        					"db" : "admin"
        				},
        				{
        					"role" : "readWriteAnyDatabase",
        					"db" : "admin"
        				},
        				{
        					"role" : "userAdminAnyDatabase",
        					"db" : "admin"
        				},
        				{
        					"role" : "clusterAdmin",
        					"db" : "admin"
        				}
        			]
        		}
        	],
        	"ok" : 1
        }
        

      (1) After the obligatory rs.slaveOk() of course.

        1. macOS expect test to reproduce this error.png
          74 kB
          Peter Schmidt
        2. mongos_usersinfo_error.js
          0.6 kB
          Peter Schmidt

            Assignee:
            backlog-server-sharding [DO NOT USE] Backlog - Sharding Team
            Reporter:
            peter.schmidt Peter Schmidt
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: