fix: duplicate course ID detection was not working#38030
fix: duplicate course ID detection was not working#38030bradenmacdonald wants to merge 4 commits intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @bradenmacdonald! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
eab585b to
78ef29a
Compare
|
Do we know if the tests case didn't catch it because they're using SQLite? |
|
@kdmccormick Ah, yeah, probably. For some reason I assumed all this time that our tests ran on MySQL on CI... they never get run on MySQL at all? |
78ef29a to
73ef990
Compare
|
@kdmccormick Yes, there are tests like |
|
@bradenmacdonald It seems to me that we mis-leadingly install MySQL before running unit tests, and then just use SQLite instead. My hypothesis is that this enabled the MySQL 6->8 upgrade team to run tests with MySQL on an ad-hoc basis, which makes sense, but it's unfortunate that we didn't either fully switch over to MySQL tests, or at least clean up the unit-tests.yml github workflow to be less confusing. We suspect that running migrations in MySQL would be horrendously slow, but maybe we could fix that by squashing a lot of migrations. I have a draft PR here just to see what testing with MySQL would look like: #38033 |
|
@kdmccormick Even if running tests on MySQL is slow, we should at least be doing it on the master branch or (if it's extremely slow) on a daily basis, either of which is easy to do with GitHub actions. Thanks for opening that PR to check into it. |
Description
This fixes the following bugs:
SplitModulestoreCourseIndexbut there can only be a singleCourseOverview, so the two different courses are essentially merged and only one can be seen or accessed from Studio. This likely results in all kinds of problems.Bug Explanation
We're seeing this bug because this line isn't working, because Django's
__iexactmatch, which is supposed to force case-insensitive matching doesn't actually force it, but just uses MySQL'sLIKEoperator which is usually case insensitive, but not always, depending on the collation of the strings in question.In this case, because our
course_idfield is case sensitive (to match MongoDB), it means the__iexactoperator is not working properly and is actually working like an__exactoperator (case sensitive). Surprisingly, they don't have any warning about this in the Django docs, and none of our test cases caught it.,even though it has fundamentally broken thebecause we haven't been running the tests against MySQL, and the issue doesn't occur with SQLite.has_course(... ignore_case=True)modulestore API.Testing instructions
Try reproducing the bugs described above.
How could we have caught this sooner?
There are tests like ContentStoreTest::test_course_with_different_cases which are designed to catch this issue, but it seems like we are only running the test suite using SQLite, and it obviously won't catch issues that are specific to MySQL.
Operator Notice
This includes a migration to make sure the database enforces case-insensitive course uniqueness going forward. If any Open edX platform instance has "case duplicate" courses that were accidentally created, the migration will fail to apply with an error like this:
Such courses will likely already be broken to some extent, so it should be safe to delete one of the duplicates. To fix this, go to the Django admin at (studio)/admin/split_modulestore_django/splitmodulestorecourseindex/ and delete the duplicate course indexes (or rename their
course_idvalue).