Skip to content

feat: implement the rebuild lifecycle and operator API [FC-0144] - #40

Draft
rpenido wants to merge 25 commits into
openedx:mainfrom
open-craft:rpenido/FAL-4413/rebuild-lifecycle
Draft

rpenido wants to merge 25 commits into
openedx:mainfrom
open-craft:rpenido/FAL-4413/rebuild-lifecycle

Conversation

@rpenido

@rpenido rpenido commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Stacked PR: built on top of #35, which is built on top of #34 and #32. Review only this branch's changes in the diff against rpenido/FAL-4409/tenant-token-api.

Description

Implements FAL-4413 on top of the write API in #32, the search API in #34 and the credential API in #35: the library rebuild lifecycle from ADR 0002 and the operator API.

The source yields SourceBatch(unit, documents). The unit is copied onto each queued WriteReceipt and into a WriteFailed, so a failure names the consumer batch even when the window holds several. The unit is a label, not a checkpoint; a crashed rebuild still restarts from the beginning.

api.rebuild mints a RebuildTarget from the logical index, the schema version and a unique generation; acquires the per-use-case lease with one atomic cache.add in the cache selected by OPENEDX_SEARCH_CACHE_ALIAS (default default); calls begin_rebuild; streams the source batches into the target; keeps up to OPENEDX_SEARCH_REBUILD_WINDOW (default 20) unconfirmed batches, checks them with the adapter's check_writes, refreshes the lease between batches, drains the window, checks that its generation is still the lease holder, and commits or aborts. A crash discards the target: the lease is not a checkpoint.

While a same-version target is recorded, upsert and delete submit to the live index and the target; a target with a different schema version raises SchemaVersionMismatch before the live write, so an old writer fails loudly instead of writing a stale shape.

Adapter.check_writes checks a batch of receipts in order; the default loops check_write, so this branch works with any adapter. The Meilisearch batch call (GET /tasks?uids=) and the commit_rebuild wait for the target's pending tasks land with #33. ADR 0002 documents the bounded window and check_writes.

The operator API is indexes(), which returns an IndexStatus per registered use case with the logical index, schema version, backend and active rebuild target; reconcile(use_case), which creates missing indexes, applies the declared settings and returns the adapter's ReconcileResult; and rebuild(use_case, source). Consumers can wrap them in their own management command or task; this PR does not add Django commands. A read-only drift report remains FAL-4412.

Testing instructions

  • Run the suite with uv run --group test pytest -q, and the linters with uv run tox -e quality.
  • The rebuild is tested against a recording adapter and the Django cache, and the operator functions through indexes and reconcile. The live engine check remains FAL-4410.

Additional Information

Depends on:

Used by:


Private ref: FAL-4413

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Dec 2, 2026
@openedx-webhooks

openedx-webhooks commented Dec 2, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @rpenido!

This repository is currently maintained by @ormsbee.

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.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


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 Dec 2, 2026
@rpenido rpenido changed the title feat: implement the rebuild lifecycle [FC-0144] feat: implement the rebuild lifecycle and management commands [FC-0144] Dec 2, 2026
@rpenido
rpenido force-pushed the rpenido/FAL-4413/rebuild-lifecycle branch from ff6c847 to 87e3982 Compare December 2, 2026 21:44
@rpenido rpenido changed the title feat: implement the rebuild lifecycle and management commands [FC-0144] feat: implement the rebuild lifecycle and operator commands [FC-0144] Dec 2, 2026
@rpenido
rpenido force-pushed the rpenido/FAL-4413/rebuild-lifecycle branch from 87e3982 to e885e12 Compare December 2, 2026 21:53
@rpenido
rpenido marked this pull request as draft December 2, 2026 22:04
@rpenido
rpenido force-pushed the rpenido/FAL-4413/rebuild-lifecycle branch 2 times, most recently from e31d459 to c5ab756 Compare December 2, 2026 22:12
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Dec 2, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Dec 2, 2026
@rpenido rpenido moved this from Todo to In Progress in Search Improvements (FC-0144) Dec 2, 2026
@rpenido
rpenido force-pushed the rpenido/FAL-4413/rebuild-lifecycle branch from c5ab756 to 996095f Compare December 2, 2026 22:22
@rpenido rpenido changed the title feat: implement the rebuild lifecycle and operator commands [FC-0144] feat: implement the rebuild lifecycle and operator API [FC-0144] Dec 2, 2026
@rpenido
rpenido force-pushed the rpenido/FAL-4413/rebuild-lifecycle branch from 996095f to 4a27837 Compare December 2, 2026 22:58
navinkarkera and others added 7 commits December 3, 2026 09:09
SearchQuery carries the text, one bounded page and the same exact filter expression delete() accepts, including id equality and IN lists. api.search() resolves the registration and delegates to Adapter.search(), which the Meilisearch adapter implements against the live index with q, offset, limit and the rendered filter. count_only sends limit 0 so the migrator can count without transferring a page; the estimated total is never reported as exact.
The shared hit count validation it also carried belongs to the
Meilisearch adapter branch.
@rpenido
rpenido force-pushed the rpenido/FAL-4413/rebuild-lifecycle branch 2 times, most recently from 007598d to be19dbb Compare December 3, 2026 22:54
@rpenido
rpenido force-pushed the rpenido/FAL-4413/rebuild-lifecycle branch from be19dbb to 536a3ef Compare December 3, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

Implement generic management commands for listing indexes & status, reindexing content

4 participants