[SERVER-37200] $match stage following $listSessions not working against mongos Created: 19/Sep/18 Updated: 29/Oct/23 Resolved: 19/Nov/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 3.6.7, 4.0.3 |
| Fix Version/s: | 3.6.10, 4.0.5, 4.1.6 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Josef Ahmad | Assignee: | Jacob Evans |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Backport Requested: |
v4.0, v3.6
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: | The following is a modified jstests/core/list_all_sessions.js test which demonstrates this issue. The following will pass when run against the core suite but will fail against the sharding_jscore_passthrough suite:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sprint: | Query 2018-11-19, Query 2018-12-03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
Observed on 3.6.7. I haven't checked if previous/later versions are also affected. It seems that a $match stage following $listSessions is ignored. Without $match stage:
With $match stage:
|
| Comments |
| Comment by Githook User [ 07/Dec/18 ] |
|
Author: {'name': 'Charlie Swanson', 'email': 'charlie.swanson@mongodb.com', 'username': 'cswanson310'}Message: (cherry picked from commit d3c939f0fa71118cb7d65296bd449265c52f67eb) |
| Comment by Githook User [ 07/Dec/18 ] |
|
Author: {'name': 'Charlie Swanson', 'email': 'charlie.swanson@mongodb.com', 'username': 'cswanson310'}Message: |
| Comment by Githook User [ 19/Nov/18 ] |
|
Author: {'name': 'Jacob Evans', 'email': 'jacob.evans@10gen.com'}Message: |
| Comment by James Wahlin [ 08/Oct/18 ] |
|
asya- injecting a stage in-between the 2 won't work unless it can trick our optimizer into not combining match stages. I think the best way to work around this would be to query the config.system.sessions collection directly, without using $listSessions. |
| Comment by Asya Kamsky [ 08/Oct/18 ] |
|
james.wahlin is there a workaround? Would injecting a stage between $listSessions and $match negate what's happening? |
| Comment by James Wahlin [ 05/Oct/18 ] |
|
This issue arises because DocumentSourceListSessions is derived from DocumentSourceMatch and does not account for pipeline optimization which will merge a subsequent DocumentSourceMatch into a DocumentSourceListSessions stage. While the optimization itself works correctly, the merged result is written to the DocumentSourceMatch::_predicate. When this optimization occurs on mongos, DocumentSourceListSessions serialization then ignores the merged DocumentSourceMatch::_predicate field and sends a $listSessions command to mongod without the $match predicates. |
| Comment by James Wahlin [ 05/Oct/18 ] |
|
I can reproduce this against 4.0.3 as well. This is an issue for aggregations run against mongos only. When run on mongod, the $match stage filters as expected. |