Skip to content

fix: make studio reindex more robust, provide better logging [FC-0117]#38498

Open
bradenmacdonald wants to merge 1 commit intoopenedx:masterfrom
open-craft:braden/fix-reindex-bugs
Open

fix: make studio reindex more robust, provide better logging [FC-0117]#38498
bradenmacdonald wants to merge 1 commit intoopenedx:masterfrom
open-craft:braden/fix-reindex-bugs

Conversation

@bradenmacdonald
Copy link
Copy Markdown
Contributor

@bradenmacdonald bradenmacdonald commented Apr 30, 2026

Description

Part of #36868 , also fixes a bug reported on the forum

This PR:

  1. Improves the reindex_studio management command so that it will gracefully log and continue when it tries to index a deleted course, rather than crashing.
    • The list of course IDs is retrieved from CourseOverview, but if there is a CourseOverview entry that no longer exists in modulestore, the whole reindex process would crash.
  2. Addresses a warning seen when running reindex_studio:
    UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list:
    <class 'openedx.core.djangoapps.content.course_overviews.models.CourseOverview'> QuerySet.
    
  3. Improves the logging when resuming an interrupted reindex. In such cases, it would say something like "Found 28 courses, 0 libraries." even when you have more courses or libraries than that, which was confusing. It now explicitly says "Resuming incremental index - NNN courses/libraries already indexed."
  4. Fixes a bug where a library could be marked as indexed before its containers were fully indexed.
  5. Improves formatting and verbosity of the logging.

Logging before: (note the numbers are quite confusing - are there 34 or 11 or 4 different things to index? Several levels of progress are all mixed together)

1/34. Now indexing blocks in library lib:OpenCraftX:NEWTEST
0/11. Now indexing collections in library lib:OpenCraftX:NEWTEST
11/11 collections indexed for library lib:OpenCraftX:NEWTEST
0/4. Now indexing containers in library lib:OpenCraftX:NEWTEST
4/4 containers indexed for library lib:OpenCraftX:NEWTEST
2/34. Now indexing blocks in library lib:BradenX:552
0/0. Now indexing collections in library lib:BradenX:552
0/0 collections indexed for library lib:BradenX:552
0/14. Now indexing containers in library lib:BradenX:552
14/14 containers indexed for library lib:BradenX:552
3/34. Now indexing blocks in library lib:OpenCraftX:RO
0/0. Now indexing collections in library lib:OpenCraftX:RO
0/0 collections indexed for library lib:OpenCraftX:RO
0/0. Now indexing containers in library lib:OpenCraftX:RO
0/0 containers indexed for library lib:OpenCraftX:RO
4/34. Now indexing blocks in library lib:OpenCraftX:BNTL

Logging after: (the overall progress is always shown at the beginning, like 1/34, and sub-tasks state their progress differently.)

1/34. Now indexing blocks in library lib:OpenCraftX:NEWTEST
Now indexing 11 collections in library lib:OpenCraftX:NEWTEST
Indexed 11/11 collections in library lib:OpenCraftX:NEWTEST
Now indexing 4 containers in library lib:OpenCraftX:NEWTEST
Indexed 4/4 containers in library lib:OpenCraftX:NEWTEST
2/34. Now indexing blocks in library lib:BradenX:552
Indexed 0/0 collections in library lib:BradenX:552
Now indexing 14 containers in library lib:BradenX:552
Indexed 14/14 containers in library lib:BradenX:552
3/34. Now indexing blocks in library lib:OpenCraftX:RO
Indexed 0/0 collections in library lib:OpenCraftX:RO
Indexed 0/0 containers in library lib:OpenCraftX:RO
4/34. Now indexing blocks in library lib:OpenCraftX:BNTL

Testing instructions

  1. First, don't check out this branch yet.
  2. Open tutor dev exec cms bash and ./manage.py cms shell and use the following commands to create an invalid CourseOverview entry:
    from opaque_keys.edx.locator import CourseLocator
    co = CourseOverview.objects.all()[10]
    co.id = CourseLocator('non', 'existent', 'course', None, None)
    co.save()  # Saves a copy without affecting the original.
    
  3. Run ./manage.py cms reindex_studio . It should fail with the error reported on the forum (AttributeError: 'NoneType' object has no attribute 'has_children')
  4. Run ./manage.py cms reindex_studio again. Note the confusing numbering, like no libraries to index even if you have some.
  5. Check out this PR and repeat steps 3-4. Confirm they're fixed.
  6. Delete that invalid CourseOverview entry that we created in step 2 so it doesn't cause any more trouble. 🐒

Deadline

No particular deadline.

@bradenmacdonald bradenmacdonald added the FC Relates to an Axim Funded Contribution project label Apr 30, 2026
@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 Apr 30, 2026
@openedx-webhooks
Copy link
Copy Markdown

Thanks for the pull request, @bradenmacdonald!

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.

1 similar comment
@openedx-webhooks
Copy link
Copy Markdown

Thanks for the pull request, @bradenmacdonald!

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.

@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 Apr 30, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Apr 30, 2026
@farhaanbukhsh farhaanbukhsh self-requested a review May 2, 2026 09:24
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). FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants