[SERVER-67012] Command error on specific combination of compound index Created: 03/Jun/22 Updated: 29/Oct/23 Resolved: 28/Jul/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Query Execution |
| Affects Version/s: | 4.2.20 |
| Fix Version/s: | 4.4.16 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Manuel Cabral | Assignee: | Denis Grebennicov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | compound-index, index | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Backwards Compatibility: | Fully Compatible |
| Operating System: | ALL |
| Sprint: | QE 2022-08-08 |
| Participants: |
| Description |
|
I have a collection with an index declared as: ({siteId: 1, startDate:1, endDate: 1}, {collation: {"locale": "en"}}). Some aggregate queries generate database errors, such as:
The database responds:
It only occurs when there are matches where the startDate field is null (undefined). |
| Comments |
| Comment by Denis Grebennicov [ 28/Jul/22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The associated backports to 4.4 and 4.2 are merged. The fix will be present with the new version release. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Denis Grebennicov [ 26/Jul/22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you for reporting this manuel.cabral@vooban.com and chris.kelly@mongodb.com for investigating it. After me having a look at it, it seems to be a fixed issue, which we didn’t backport to 4.4 and 4.2 versions. The bugfix can be found here: Backporting the fix to 4.4 and 4.2 versions. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Chris Kelly [ 14/Jul/22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Manuel, I'm not sure why it wasn't triggering for me the first time I looked at this. I was able to reproduce it this time by: > creating a fresh collection > inserting all of your data > creating the index only after data was inserted (via CLI) > attempting the aggregation again (to then see it fail) What's weird is it doesn't seem to even be using that index at the time it errors out.
But then, subsequent attempts to run that same aggregation will succeed (and will use the index)
I'll pass this along to QE to see if they may know what causes it to sporadically use the index (or not) and whether that can precipitate this error. The affected code looks to be here. I have also been attempting this on other versions to see if I can replicate the behavior there. So far, I don't see it happening in 5.0.9. If you are able to reproduce this in other versions, please let us know! Thank you for your report! Christopher | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Manuel Cabral [ 05/Jul/22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Chris, I am using exactly the same dataset as the one provided. I have the same error when running it in Compass: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Chris Kelly [ 30/Jun/22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Manuel, Can you elaborate on this: Because I was able to get output from your sample dataset using that object Id instead:
I have also tried it as the first query ran on startup of the DB, so it would be the first thing using that index. Just to verify: is the sample dataset you provided the one that is triggering this behavior? For what it's worth, I also had to manually rewrite your aggregation pipeline to get it to work on Compass for me. I'm not 100% sure how you are passing in that aggregation pipeline, so I'd just want to make sure we're on the same page with it. Christopher | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Manuel Cabral [ 21/Jun/22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I did some tests again and it seems that my assumption was incorrect. I'm not sure of the failing condition, but the pipeline fails using this condition with the match with the specific siteId: ObjectId("629a28f3810498dcb1954637") (the id in the description was from a previous test with a different dataset) I'm running the database in a Docker container (official image). I attached the container logs. Strangely enough, if some similar queries are run before it, the aggregation pipeline succeeds. It only seems to fail if it is the first query using the index since the server has been started. I reproduced the error with two drivers: Node and C# (both latest versions). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Chris Kelly [ 21/Jun/22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Manuel, Thanks for your report. I've gone ahead and tried what you've suggested on MongoDB 4.2.20, but am failing to observe your problem. Specifically, I am:
In order to look into this further I am going to need the following information:
Regards, |