Keeping the index in sync
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
feed the index from the source of truth without dual-write bugs.
Planned topics
- The database is the source of truth; the index is rebuildable.
- Do not write the database and the index in the same request: one can fail and they diverge (dual write).
- Use events: catalog publishes
ProductUpdated(outbox pattern), an indexer consumes it and upserts the document by product id; deletions as delete events. - Use the product version as an external version so older events do not overwrite newer ones.
- Document a full reindex: new index, bulk load from the database, switch an alias, delete the old index.
Draft outline details
Demonstration
flow: catalog DB → outbox → broker → indexer → OpenSearch alias products → products_v2.
Check your understanding
Why is dual write dangerous?
Show answer
One write can fail, leaving database and index inconsistent.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.