Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-508

db.runCommand not inheriting readPreference

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 0.7.7
    • Affects Version/s: None
    • Component/s: Shell API
    • Labels:
      None
    • 3
    • Needed
    • Hide

      1. If a read preference has been explicitly specified using `readPreference` in the connection string or `mongo.setReadPref()`, this `readPreference` will be applied to db.runCommand(), db.adminCommand(), and generally all db/rs/sh methods. If no read preference has been explicitly specified, the driver’s default is currently being used (i.e. a read preference of `primary`). This behavior differs from both the drivers’ behavior and the old shell’s behavior.

      2. The `show dbs`/`show databases` and `show tables`/`show collections` commands always use a read preference of `primaryPreferred`, regardless of any otherwise specified read preference. This also differs from the old shell’s behavior.

      Show
      1. If a read preference has been explicitly specified using `readPreference` in the connection string or `mongo.setReadPref()`, this `readPreference` will be applied to db.runCommand(), db.adminCommand(), and generally all db/rs/sh methods. If no read preference has been explicitly specified, the driver’s default is currently being used (i.e. a read preference of `primary`). This behavior differs from both the drivers’ behavior and the old shell’s behavior. 2. The `show dbs`/`show databases` and `show tables`/`show collections` commands always use a read preference of `primaryPreferred`, regardless of any otherwise specified read preference. This also differs from the old shell’s behavior.
    • Iteration Uglifruit

      db.runCommand should inherit readPreference from the connection / db.getMongo as in the old shell.

      To reproduce, connect to a secondary, set read preference of secondary in the mongo object, and try a db.runCommand(

      {listDatabases: 1}

      ), that should work if the read preference is inherited.

            Assignee:
            anna.henningsen@mongodb.com Anna Henningsen
            Reporter:
            maurizio.casimirri@mongodb.com Maurizio Casimirri
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: