Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-54373

read from mongos with readPref=secondary and readConcern=local/majority return empty data

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 4.2.1
    • Fix Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Operating System:
      ALL

      Description

      I can't read data from mongos that was just inserted through another mongos.

      The test is very simple, I have two mongos:

      1. connect mongos1
      2. shard Collection with hash index
      3. insert data
      4. query in mongos2 with readPref=secondary and readConcern=local/majority, no data returned.
      5. If I read from primary to trigger the cache route refresh, then data can be read.

       

      This only happens in MongoDB 4.2 version with hash index key shardCollection method. If shard key is a range, everything works ok. If I shard Collection with hash index after data inserted, also everything is ok.

      mongos> db.y.find({"_id" : ObjectId("601faa86dc371c32b4f58f6b")}).readPref("secondaryPreferred")
      mongos> db.y.find({"_id" : ObjectId("601faa86dc371c32b4f58f6b")}).readPref("secondaryPreferred").readConcern("local")
      mongos> db.y.find({"_id" : ObjectId("601faa86dc371c32b4f58f6b")}).readPref("secondaryPreferred").readConcern("majority")
      mongos>
      mongos> db.y.find({"_id" : ObjectId("601faa86dc371c32b4f58f6b")})
      { "_id" : ObjectId("601faa86dc371c32b4f58f6b"), "y" : 1 }
      mongos> db.y.find({"_id" : ObjectId("601faa86dc371c32b4f58f6b")}).readPref("secondaryPreferred").readConcern("majority")
      { "_id" : ObjectId("601faa86dc371c32b4f58f6b"), "y" : 1 }
      mongos>
      mongos>
      mongos> db.z.find({"_id" : ObjectId("601faae5dc371c32b4f58f6e")}).readPref("secondaryPreferred")
      mongos> db.z.find({"_id" : ObjectId("601faae5dc371c32b4f58f6e")}).readPref("secondaryPreferred").readConcern("majority")
      mongos>
      mongos>
      

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              edwin.zhou Edwin Zhou
              Reporter:
              cvinllen@gmail.com vinllen chen
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: