Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2347

How to specify readConcern for mapReduce operation

    • Type: Icon: Task Task
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.3.4
    • Component/s: Native
    • Not Needed

      Imagine you have mongodb connection with {{readConcern: {level: "}}majority"}.

      When you try to perform mapReduce you will get error:

      {{Command does not support read concern { readConcern: { level: "majority" } }
      }}

      You will get this error even when you'll specify readConcern: {level: "local"} for mapReduce operation only (it is not documented, but this option is available according to driver sources).

      When you ask "Why I've got error about ability to specify majority read concern, while I've set local?", you'll find the answer in decorateWithReadConcern? it always use collection readConcern prior to operation readConcern.

      function decorateWithReadConcern(command, coll, options) {
        if (options && options.session && options.session.inTransaction()) {
          return;
        }
        let readConcern = Object.assign({}, command.readConcern || {});
        if (coll.s.readConcern) {
          Object.assign(readConcern, coll.s.readConcern);
        }
        if (Object.keys(readConcern).length > 0) {
          Object.assign(command, { readConcern: readConcern });
        }
      }

      Does it correct behavour or not?

      If no - please fix the bug and clarify readConcern usage cases for mapReduce operations.

      If yes, what is the best practice for mapReduce operations:

      1. Use separate connection with readConcern: {level: "local"}?
      2. Use special collection instance with readConcern: {level: "local"} to perform operations like mapReduce?

      Thank you in advance.

            Assignee:
            Unassigned Unassigned
            Reporter:
            sempasha@gmail.com Pasha Semenov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: