Avoid duplicating read preference when running an exhaust query in the shell

XMLWordPrintableJSON

    • Workload Scheduling
    • Fully Compatible
    • ALL
    • v8.0, v7.3, v7.0
    • Hide

      In the shell, run the following code:

      db.getMongo().setReadPref('secondary');
      db.getCollection("argleBargle").find().addOption(DBQuery.Option.exhaust).itcount()
      
      Show
      In the shell, run the following code: db.getMongo().setReadPref( 'secondary' ); db.getCollection( "argleBargle" ).find().addOption(DBQuery.Option.exhaust).itcount()
    • Workload Scheduling 2024-08-05
    • 0
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      When running an exhaust query in the shell, we call the built-in find rather than runCommand: https://github.com/10gen/mongo/blob/3639fdb2758f07a85958fcf28e24cf0056c1d8e8/src/mongo/shell/query.js#L130-L156

      Since find has read preference as an explicit argument, we get the read preference (if any) from the command object and pass it to find, which internally ends up adding it to the op message, resulting in a duplicate read preference.

            Assignee:
            Vojislav Stojkovic
            Reporter:
            Vojislav Stojkovic
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: