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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 4.2.1
    • Component/s: Sharding
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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>
      

       

            Assignee:
            Edwin Zhou
            Reporter:
            vinllen chen
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: