[SERVER-54373] read from mongos with readPref=secondary and readConcern=local/majority return empty data Created: 07/Feb/21 Updated: 18/Jun/21 Resolved: 09/Feb/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | 4.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | vinllen chen | Assignee: | Edwin Zhou |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Case: | (copied to CRM) | ||||||||
| Description |
|
I can't read data from mongos that was just inserted through another mongos. The test is very simple, I have two mongos:
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.
|
| Comments |
| Comment by Edwin Zhou [ 09/Feb/21 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
Thank you for your ticket. This appears to be a duplicate of Best, | |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Xin Wang [ 07/Feb/21 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
The same question with @vinllen chen And I supply the reproduce step with js code here:
With the first round done , everything runs ok. And when we run `.find({_id: one_doc_id}).readPref("secondary")` through st.s1, we see the refresh log: s21230| 2021-02-07T23:11:35.291+0800 I SH_REFR [ConfigServerCatalogCacheLoader-0] Refresh for collection testdb.testcoll to version 1|3||602003276ef388a5caf68456 took 1 ms The result for both "find doc with secondary pref" and "find doc with secondary pref and local concern" is 1.
But when we run the second round (another collection), there is something unexpected. The result for both "find doc with secondary pref" and "find doc with secondary pref and local concern" is 0, but 1 is expected. And there is no refresh log.
I further added some logs to determine the root cause, and I see ( the second round)
I think the root cause is that secondary only load routeinfo to CatalogCache when the collection is marked as needRefresh, but it will not be marked in this scenario, because there are logical partitions
Of course, there is no problem if there are many requests with different shardKeys randomly distributed to mongos. But the scenario described above does exists.
Is my guess correct? And is there any good solution or will this scenario be fixed in the future?
|