[SERVER-70811] SHARDING_FILTER stage missing from db.coll.count({predicate}) Created: 24/Oct/22 Updated: 05/Dec/22 Resolved: 24/Oct/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Matt Boros | Assignee: | Backlog - Query Optimization |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Query Optimization
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
This bug has different severity depending on the version. The query is
with secondary reads. On 4.4, the result is incorrect, and includes orphan documents. A SHARDING_FILTER is missing from the explain plan. On 5.0 and 6.0, orphan documents are filtered out and the count is correct, but the SHARDING_FILTER stage is not reported in the explain plan. This makes me think the explain is incorrect, and the stage is actually included. Repro script (based on shard_filtering.js): load("jstests/libs/analyze_plan.js"); // Deliberately inserts orphans outside of migration. assert.commandWorked(st.s.adminCommand( {enableSharding: "test"})); // Put a chunk with no data onto shard0 in order to make sure that both shards get targeted. , to: st.shard0.shardName})); // Shard the collection and insert some docs. , d: {e: {f: 1}}, g: 100, z: "z"}, , d: {e: {f: 2}}, g: 100.9, z: "z"}, , d: {e: {f: 3}}, g: "a", z: "z"}, , d: {e: {f: 3}}, g: [1, 2, 3], z: "z"}, , d: {e: {f: "c"}}, g: null, z: "z"}, , d: {e: {f: Infinity}}, g: NaN, z: "z"}, // Insert some documents with valid partial shard keys to both shards. The versions of these , d: {e: {f: 1}}, z: "z"}, , d: {e: {f: 1}}, z: "z"}, , d: {e: {f: null}}, z: "z"}, // Insert orphan docs without missing or null shard keys onto shard0 and test that they get filtered , d: {e: {f: 999}}, g: "a", z: "z"}, , d: {e: {f: 1000}}, g: "b", z: "z"} // With primary read pref, count with predicate filters out orphans ), 10); )); mongosDb.shardfilter.getMongo().setReadPref("secondary"); ), 10); )); st.stop(); |
| Comments |
| Comment by Matt Boros [ 24/Oct/22 ] |
|
Apologies, Jira was acting funny and created two of these tickets. |