Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-1140

tools do not respect readPreference=secondary when connecting to a mongos

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.13, 3.3.11, 3.2.10
    • Affects Version/s: 3.2.4
    • Component/s: All Tools
    • None
    • Environment:
      GCP n1-highcpu-16(mongod) , n1-highcpu-2(mongoc,mongod-arbitter,mongos), 3sharded cluster
    • Server Tools 13 (04/22/16), Platforms 2016-08-26
    • v3.2, v3.0

      Hi, community.

      When I use mongoexport with --readPreference=secondary, I got bellow error.

      15:33:49 [0] % mongoexport --host mongos-01-b.dummy.com -d dummyDB --port 27017 -c accounts --readPreference=secondary > hoge.json
      2016-04-13T15:34:43.815+0900 Warning: using a non-primary readPreference with a connection to mongos may produce inconsistent duplicates or miss some documents.
      2016-04-13T15:34:46.989+0900 Failed: no reachable servers
      

      When I use mongoexport with --readPreference=secondaryPreferred, All went well.

      15:34:47 [1] % mongoexport --host mongos-01-b.dummy.co -d dummyDB --port 27017 -c accounts --readPreference=secondaryPreferred > hoge.json
      2016-04-13T15:37:35.978+0900 Warning: using a non-primary readPreference with a connection to mongos may produce inconsistent duplicates or miss some documents.
      2016-04-13T15:37:36.018+0900 connected to: mongos-01-b.dummy.co:27017
      2016-04-13T15:37:37.019+0900 [........................] dummyDB.acounts 16000/5700367 (0.3%)
      2016-04-13T15:37:38.019+0900 [........................] dummyDB.acounts 64000/5700367 (1.1%)
      2016-04-13T15:37:39.020+0900 [........................] dummyDB.acounts 96000/5700367 (1.7%)
      

      As far as I read mongo-tool code and mgo.v2 code, mongo-tool only output warning log "Warning: using a non-primary readPreference with a connection -<< omit >> ". And the Error "no reachable servers" is returned in mgo.v2/cluster.go cluster.AcquireSocket().
      why we can't use --readPreference=secondaryPreferred with mongo-tool?

        There are no Sub-Tasks for this issue.

            Assignee:
            gabriel.russell@mongodb.com Gabriel Russell (Inactive)
            Reporter:
            loadtest@abema.tv Yoshikazu Umino
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: