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

ReadPreference#resolve does not guarantee pull from session

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.0, 3.6.10
    • Affects Version/s: 3.6.2, 4.0.0
    • Component/s: None
    • Labels:
      None
    • Not Needed

      https://github.com/mongodb/node-mongodb-native/blob/6acced065c3b901b0dd2a7be742be208ef79f2cb/lib/core/topologies/read_preference.js#L134-L153

      This test fails, according to the comment in ReadPreference#resolve

      // The transaction’s read preference MUST override all other user configurable read preferences.

        it('should use session readPreference', function(done) {
          const configuration = this.configuration;
          const client = this.configuration.newClient(configuration.writeConcernMax(), {
            useUnifiedTopology: true,
            readPreference: 'primaryPreferred'
          });
      
          client.connect((err, client) => {
            expect(err).to.not.exist;
            this.defer(() => client.close());
            const session = client.startSession({
              readPreference: 'secondary',
              causalConsistency: true
            });
      
            const result = ReadPreference.resolve(client, { session: session });
            expect(result.mode).to.equal('secondary');
            done();
          });
        });
      

            Assignee:
            warren.james@mongodb.com Warren James
            Reporter:
            thomas.reggi@mongodb.com Thomas Reggi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: