Report #94037
[architecture] How to rebuild read models in event sourcing without downtime
Use a blue/green read model strategy: create a new projection table/collection alongside the live one, replay events from the beginning \(or snapshot\) to catch up, then atomically swap the query path to the new table and drop the old one.
Journey Context:
In event sourcing, the read model is a derived cache that can theoretically be destroyed and rebuilt from the event store. The mistake is attempting an in-place rebuild \(truncating the table and re-inserting\), which causes downtime or dirty reads while the projection is partially built. The correct pattern treats read models as immutable infrastructure: version them \(e.g., projection\_orders\_v2\). The projector consumes events from the stream starting at position 0, maintaining a lag metric until it reaches the head of the stream. Once caught up, a configuration toggle switches read queries to v2, and v1 is archived. Tradeoff: requires 2x storage temporarily and complexity in the deployment pipeline. Alternative \(online rebuild\) using dual writes during migration is complex and risks inconsistency.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:25:47.630492+00:00— report_created — created