Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-467

Calling setReadPreference(ReadPreference.SECONDARY) is not reading from secondary servers

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.7.2
    • Component/s: Cluster Management
    • Labels:
      None
    • Operating System:
      Windows
    • # Replies:
      7
    • Last comment by Customer:
      true

      Description

      In a test environment with 4 MongoDB instances, all the reads in the attached test code are executed against only the master server. This is identified by the watching the console of each of the instances, and the CPU of the machines on which the instances are running.

      The call the DBCursor.getServerAddress() is not working either, it only returns a null, so that we cannot verify where the reads are being executed. (Not sure if this is related.)

        Issue Links

          Activity

          Hide
          jason nethercott Jason Nethercott added a comment -

          Affected version is 2.7.0, however, it's not listed in JIRA.

          Show
          jason nethercott Jason Nethercott added a comment - Affected version is 2.7.0, however, it's not listed in JIRA.
          Hide
          auto auto (Inactive) added a comment -

          Author:

          {u'login': u'rgnitz', u'name': u'Ryan', u'email': u'rgnitz@gmail.com'}

          Message: Moved variable calls to method to fix read preference hierarchy - JAVA-467
          Branch: master
          https://github.com/mongodb/mongo-java-driver/commit/253ca0772dc5cdca8c3092d62dfd434690fcf337

          Show
          auto auto (Inactive) added a comment - Author: {u'login': u'rgnitz', u'name': u'Ryan', u'email': u'rgnitz@gmail.com'} Message: Moved variable calls to method to fix read preference hierarchy - JAVA-467 Branch: master https://github.com/mongodb/mongo-java-driver/commit/253ca0772dc5cdca8c3092d62dfd434690fcf337
          Hide
          auto auto (Inactive) added a comment -

          Author:

          {u'login': u'rgnitz', u'name': u'Ryan', u'email': u'rgnitz@gmail.com'}

          Message: added _check call to getServerAddress if _it is null - JAVA-467
          Branch: master
          https://github.com/mongodb/mongo-java-driver/commit/daa7f7416a4facb295e6b596558a6dc57bac88b0

          Show
          auto auto (Inactive) added a comment - Author: {u'login': u'rgnitz', u'name': u'Ryan', u'email': u'rgnitz@gmail.com'} Message: added _check call to getServerAddress if _it is null - JAVA-467 Branch: master https://github.com/mongodb/mongo-java-driver/commit/daa7f7416a4facb295e6b596558a6dc57bac88b0
          Hide
          rgnitz Ryan Nitz (Inactive) added a comment -

          Hi Jason,

          Thanks for bringing this to our attention (and sorry about the headaches).

          I attached a patched library. Can you run in your environment and confirm everything is working properly?

          Thanks,

          -Ryan

          Show
          rgnitz Ryan Nitz (Inactive) added a comment - Hi Jason, Thanks for bringing this to our attention (and sorry about the headaches). I attached a patched library. Can you run in your environment and confirm everything is working properly? Thanks, -Ryan
          Hide
          auto auto (Inactive) added a comment -

          Author:

          {u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

          Message: JAVA-467: removed call to _check() from within getServerAddress because this method should not block.
          It is used for information purpose and docs states it is null until data has been returned.
          One example is that it made cursor.toString() block on long queries.
          Branch: master
          https://github.com/mongodb/mongo-java-driver/commit/9ae9483639d064a41f873b4063582c7b782000b8

          Show
          auto auto (Inactive) added a comment - Author: {u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'} Message: JAVA-467 : removed call to _check() from within getServerAddress because this method should not block. It is used for information purpose and docs states it is null until data has been returned. One example is that it made cursor.toString() block on long queries. Branch: master https://github.com/mongodb/mongo-java-driver/commit/9ae9483639d064a41f873b4063582c7b782000b8
          Hide
          auto auto (Inactive) added a comment -

          Author:

          {u'login': u'bwmcadams', u'name': u'Brendan W. McAdams', u'email': u'brendan@10gen.com'}

          Message: Tests utterly fail with this commit; as a result, rolling back.

          Revert "JAVA-467: removed call to _check() from within getServerAddress because this method should not block."

          This reverts commit 9ae9483639d064a41f873b4063582c7b782000b8.
          Branch: master
          https://github.com/mongodb/mongo-java-driver/commit/85f0f750bb10ecb44c42204b096c039c2dd7c222

          Show
          auto auto (Inactive) added a comment - Author: {u'login': u'bwmcadams', u'name': u'Brendan W. McAdams', u'email': u'brendan@10gen.com'} Message: Tests utterly fail with this commit; as a result, rolling back. Revert " JAVA-467 : removed call to _check() from within getServerAddress because this method should not block." This reverts commit 9ae9483639d064a41f873b4063582c7b782000b8. Branch: master https://github.com/mongodb/mongo-java-driver/commit/85f0f750bb10ecb44c42204b096c039c2dd7c222
          Hide
          auto auto (Inactive) added a comment -

          Author:

          {u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

          Message: JAVA-467: cur.toString() should not block
          Branch: master
          https://github.com/mongodb/mongo-java-driver/commit/45b2dd89505fb155af34d194205ebc8461e04e0f

          Show
          auto auto (Inactive) added a comment - Author: {u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'} Message: JAVA-467 : cur.toString() should not block Branch: master https://github.com/mongodb/mongo-java-driver/commit/45b2dd89505fb155af34d194205ebc8461e04e0f

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                3 years, 24 weeks, 2 days ago
                Date of 1st Reply: