Replaying the content graph
How to replay the content graph in production
Never replay the content graph directly on production
During a replay the projection tables will be fully reset. Then batch after batch the events are re-applied and build the state. This can take depending on the size of the events from tens of minutes to hours. During that time the website would show previously existing content which is to be avoided.
Some upgrades like Neos 9.1 to Neos 9.2 require a full replay of the contentGraph projection. There is no way to avoid that. No data transformation from one state/schema to the other is possible. But with event sourcing we can already profit from new projections and schemas by replaying the existing events.
Replaying events requires some time and coordination. Below are a few recommendations how to proceed. Please note that some workflows require your editorial staff to stop working on your Neos in the time of the upgrade.
#Replaying on stage and switch
Note that this process requires a content freeze from the time where the events are replayed on stage and the projection is up to date in production.
The exact steps vary based on your hosting and its possibilities. If possible prepare the upgrade and replay the content graph on the stage instance and switch the containers to be the productive ones.
Or replay the projection on stage and only copy the tables to the production database when you also roll out the new code there. Which tables exactly need to be copied is explained also in the guide #Replaying locally and syncing to production.
#Replaying into separate tables
This is the only workflow which allows a smooth upgrade without content freeze. The spark of the idea was that in event sourcing we exactly have the capabilities to have multiple read-models / projections and that downtime is not acceptable.
For the upgrade to Neos 9.2 we build a package which copies the original sources of the content graph implementation and adjust the namespace so we can effectively install the content graph twice just with different versions.
The package is called neos/contentgraph-doctrinedbaladapter-forward-compatibility and brings all the tooling and documentation needed to allow a smooth upgrade.
Please see the guide on GitHub how to proceed:
#Replaying locally and syncing to production
Note that this process requires a content freeze from the time where the events are downloaded and the replayed projection is synced to live.
A major benefit justifying the complexity is that it speeds up the replay via local processing power and less latency to the database.
Please see the guide on discuss how to proceed:
#For development only: Replay directly
To replay events locally use the CLI commands as you know. Please note if you upgrade from 9.0 or 9.1 to Neos 9.2 you should look into the CLI command ./flow crupgrade:resetupandreplaycontentgraph below.
./flow cr:setup
./flow subscription:replay contentGraphIf you already have projection tables from a previous Neos release, ./flow cr:setup cannot apply a schema update with the tables filled.
In that case use the CR Upgrade to allow to empty, set up and replay the graph projection in one step:
./flow crupgrade:resetupandreplaycontentgraph