fix: sync block structure cache before building navigation sidebar#38812
fix: sync block structure cache before building navigation sidebar#38812BryanttV wants to merge 1 commit into
Conversation
|
Thanks for the pull request, @BryanttV! 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. |
b1706db to
5b80802
Compare
Description
This PR fixes stale content in the Learning MFE left navigation sidebar after course publish (e.g., content group visibility changes in Studio OR updates in the block names).
On sidebar cache miss, synchronously refresh the block structure cache before building the outline tree, so the sidebar is not populated from outdated block structure data while the async Celery task is still pending.
Problem
After publishing course changes in Studio, the Learning MFE sidebar (
GET /api/course_home/v1/navigation/{course_key}) can show outdated blocks for up to one hour.Root cause
The navigation endpoint caches the intermediate outline tree for one hour, keyed in part by
course_version(the published structureversion_guid).When a course is published:
course_versionchanges > sidebar cache miss (new cache key).get_course_outline_block_tree>get_blocks>get_collected().get_collected()can return stale block structure from cache because it does not re-check freshness on a cache hit.update_course_in_cache_v2), with a 30-second delay after course_published (BLOCK_STRUCTURES_SETTINGS['COURSE_PUBLISH_TASK_DELAY']).If the sidebar is requested in that window, stale block structure is cached under the new
course_versionkey for one hour, even though Celery later updates block structure correctly.Solution
On sidebar cache miss, call
update_course_in_cache(course_key)synchronously before building the outline tree. This uses the existingupdate_collected_if_needed()path, which refreshes the block structure only when it is outdated.Supporting information
Testing instructions
Using Tutor local:
Deadline
Verawood