-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Allow disabling workaround for since-fixed MongoDB bug #5617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow disabling workaround for since-fixed MongoDB bug #5617
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5617 +/- ##
==========================================
+ Coverage 94.16% 94.18% +0.01%
==========================================
Files 129 129
Lines 9244 9247 +3
==========================================
+ Hits 8705 8709 +4
+ Misses 539 538 -1
Continue to review full report at Codecov.
|
Can't we use a server status to retrieve the MongoDB server version at init ? |
That would definitely be possible. I didn't see anything like that being done at the moment though, so I thought a cli flag would be a less disruptive change |
@NotBobTheBuilder thanks for the detailed issue and pr. Much appreciated. This seems reasonable to me. @davimacedo @dplewis any feedback? |
@oallouch Can you add a test to check if that flag can be set? Also, I'm not asking you to do this but since travis runs Mongo 3.6 and 4.0 you could check if SERVER-13732 is indeed fixed. Getting database version would a good feature in the future. (Maybe MasterKey API / serverInfo) |
I don't really see in which actual object of the API it would fit. (and in which Router) |
FeatureRouter, we can discuss it in a separate issue |
Just a link to the PR with an API for the database version : #5627 |
I just resolved the merge conflict and will keep a look out for whether that merge has broken any tests |
@dplewis is this ready to merge? |
Wouldn't it be better to just use the new database version this PR added ( #5627 ) instead of adding another option ? |
I'll remove the CLI flag and rework on top of the databaseVersion implementation (hadn't noticed that PR has been merged). Thanks! |
Updated as described! |
This reverts commit 042d1ba.
@NotBobTheBuilder I re-added the CLI option because we removed the database version feature #5681 Everything looks good to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for the delay...
Hi!
Sorry in advance for the wall of text in this PR, but I have tried to bring all the relevant context of the problem into one place along with an explanation of my proposed solution.
This is a follow-up PR to #3476 which I filed a couple of years ago.
The original PR was related to this MongoDB bug, SERVER-13732, which at the time was a longstanding bug in index selection in MongoDB.
The bug meant that any queries using both an $or filter and another query predicate at the top level of the query would suffer from needlessly poor index selectivity, resulting in more load on the server per query than needed.
The workaround implemented inside Parse is to have the
DatabaseController
change affected queries with this structureTo have this structure, which is logically equivalent:
The good news is that the bug was fixed in 3.6, meaning the workaround code I filed a PR for a couple of years ago is now redundant for anyone using Parse with MongoDB 3.6 or above.
The bad news is that, in version 3.6, some queries involving $ors and sorts are now less performant with the workaround applied than they would be without it.
I noticed from the README.md file that tests are still running against 3.2 and 3.4, so I didn't want to remove the workaround completely. Those versions of MongoDB do still have the bug, and the benefit of keeping it available is huge. But at the same time for 3.6 and likely later versions too the query planner can benefit from the simpler queries produced when the workaround logic is avoided.
Since most deployments using MongoDB 3.2 and 3.4 will benefit from having the workaround in place, and some deployments using 3.6 or later will benefit from not having the workaround remain, my proposal is to add a flag allowing users running 3.6 and 4.0 to disable the feature, but leave it enabled-by-default.
In future, if Parse drops support for MongoDB versions before 3.6, the flag and the workaround behind it can be removed entirely, as they will be unnecessary.
I did my best to update the code in a way that respects the existing codebase and creates as little disruption as possible. The main changes are the addition of the new CLI flag/env variable, and a new parameter to the
DatabaseController
constructor representing that flag. I also updated the tests to have cases for specifying that flag as enabled & disabled.I'd be very happy to update any relevant documentation as needed or change the PR if you have another approach to this in mind.
Thanks for taking the time to maintain this project!