[SERVER-76541] documents can't be find with secondary readPref from mongos after create an sharded collection Created: 26/Apr/23  Updated: 26/Apr/23  Resolved: 26/Apr/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.4 Required
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Chao Yin Assignee: Yuan Fang
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-53474 Cannot read from another mongos with ... Closed
Related
related to SERVER-54625 Maybe the root case for reading from ... Closed
Operating System: ALL
Steps To Reproduce:
  1. Prepare a sharded mongodb4.4 cluster with two mongos and two shards
  2.  Login mongosA,
  3.  sh.enableSharding("yc");  sh.shardCollection("yc.coll1", {a:"hashed"});
  4. insert some data; db.coll1.insert({a:1} ;db.coll1.insert({a:2} ;db.coll1.insert({a:3} ;
  5.  login mongosB,
  6. run find command to flush route of  'yc' db.
  7. use yc; db.coll1.find({a:1}); db.coll1.find({a:2}); db.coll1.find({a:3}); 
  8. Login mongosA, shard another collection
  9. sh.shardCollection("yc.coll2", {a:"hashed"}); // shard another collection
  10. insert some data; db.coll2.insert({a:1}); db.coll2.insert({a:2});db.coll2.insert({a:3})
  11. login mongosB
  12. db.getMongo().setReadPref("secondary")
  13. use yc; db.coll2.find({a:1}); db.coll2.find({a:2}); db.coll2.find({a:3}). some documents could not be found
Participants:

 Description   

After creating a sharded collection and inserting some documents, thoese documents  may not be read from other mongos with secondary readPref, even by setting local readConcern.

Another mongos thinks that the table is a unsharded unshared collection and sends the request to the primaryshard, but the data may be distributed on another shard.

And if secondary readpref is set, the request sent to the shard will not carry routing information, and will not check whether the route is dirty, so the route cannot be refreshed.

https://github.com/mongodb/mongo/blob/r4.4.13/src/mongo/db/service_entry_point_common.cpp#L1157

 

https://github.com/mongodb/mongo/blob/r4.4.13/src/mongo/db/s/collection_sharding_runtime.cpp#L328

 

With local readconcern, this phenomenon still exists.

Although the routing information is carried, the routing is empty and can pass the inspection.

 

5.0 does not have this problem, it seems that because the code of the route cache is modified, mongos will refresh the route after receiving the first request.

 

 

 



 Comments   
Comment by Yuan Fang [ 26/Apr/23 ]

Hi 1321280378feng@gmail.com,

Thank you for submitting your report. It appears that the issue you reported is a duplicate of SERVER-53474 and the root cause seems to be SERVER-32198, which has been fixed in version 4.7.

I am closing this ticket for now. However, if you see any evidence indicating this is a separate issue, please let us know and we will reopen the ticket.

Regards,
Yuan

Generated at Thu Feb 08 06:32:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.