Skip to content

fix: ensure navigation sidebar serves fresh data after course publish…#38880

Merged
wgu-taylor-payne merged 1 commit into
openedx:release/ulmofrom
WGU-Open-edX:stale-navigation-sidebar-backport-ulmo
Jul 14, 2026
Merged

fix: ensure navigation sidebar serves fresh data after course publish…#38880
wgu-taylor-payne merged 1 commit into
openedx:release/ulmofrom
WGU-Open-edX:stale-navigation-sidebar-backport-ulmo

Conversation

@holaontiveros

@holaontiveros holaontiveros commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Important! there's a check regarding code style failing, this seems to be related with some styling choices in later OEX versions.

… (#38852)

Replace course_version in the sidebar cache key with a block_structure_version derived from BlockStructureModel.data_version. course_version changes eagerly on publish, causing a cache miss before the block structure is rebuilt — poisoning the cache with stale data for 1 hour. block_structure_version only changes after the async rebuild completes, so cache misses only occur when fresh data is available.

This is a backport of #38785.

(cherry picked from commit 929815f)

Description

Describe what this pull request changes, and why. Include implications for people using this change.
Design decisions and their rationales should be documented in the repo (docstring / ADR), per
OEP-19, and can be
linked here.

Useful information to include:

  • Which edX user roles will this change impact? Common user roles are "Learner", "Course Author",
    "Developer", and "Operator".
  • Include screenshots for changes to the UI (ideally, both "before" and "after" screenshots, if applicable).
  • Provide links to the description of corresponding configuration changes. Remember to correctly annotate these
    changes.

Supporting information

Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.

Testing instructions

Please provide detailed step-by-step instructions for testing this change.

Deadline

"None" if there's no rush, or provide a specific date or event (and reason) if there is one.

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.
  • If your database migration can't be rolled back easily.

…openedx#38852)

Replace course_version in the sidebar cache key with a
block_structure_version derived from BlockStructureModel.data_version.
course_version changes eagerly on publish, causing a cache miss before
the block structure is rebuilt — poisoning the cache with stale data for
1 hour. block_structure_version only changes after the async rebuild
completes, so cache misses only occur when fresh data is available.

This is a backport of openedx#38785.

(cherry picked from commit 929815f)
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Jul 13, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @holaontiveros!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jul 13, 2026
@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Jul 13, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a cache-race where the course navigation sidebar could cache and serve stale block structure data for up to 1 hour immediately after a Studio publish. It does so by switching the sidebar cache key from the eagerly-changing course_version to a block_structure_version derived from BlockStructureModel.data_version, which only changes once the async block structure rebuild completes.

Changes:

  • Add a block_structure_version cache key (writer-owned) backed by BlockStructureModel.data_version.
  • Update the navigation sidebar cache key to use block_structure_version instead of course_version.
  • Add a regression test covering the “publish → stale window → rebuild completes → fresh sidebar” scenario.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
openedx/core/djangoapps/content/block_structure/api.py Adds block_structure_version read/write helpers and updates cache rebuild flow to refresh the version key.
lms/djangoapps/course_home_api/outline/views.py Switches sidebar cache keying to use block_structure_version to avoid caching stale outlines post-publish.
lms/djangoapps/course_home_api/outline/tests/test_view.py Adds regression test to ensure sidebar doesn’t remain stale after rebuild completion.
Comments suppressed due to low confidence (1)

openedx/core/djangoapps/content/block_structure/api.py:78

  • clear_course_from_cache deletes the underlying BlockStructureModel row via the store, but it doesn't clear the new block_structure_version:{course_key} cache entry. Because that version key is cached with timeout=None, subsequent readers can keep using a now-stale version value even after the block structure has been cleared/deleted, which can prevent navigation sidebar cache keys from shifting away from stale entries.
    _update_block_structure_version(course_key)


def clear_course_from_cache(course_key):
    """

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wgu-taylor-payne wgu-taylor-payne merged commit f7f9508 into openedx:release/ulmo Jul 14, 2026
49 of 50 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for Review to Done in Contributions Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants