Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to improve the search index update logic to reduce the risk of downtime.
Search downtime will still happen with these changes, but the goal is to reduce the likelihood of it happening, and when it does happen, we inform the user more gracefully.
The current issues
Running a schema only update while also using an atomic rebuild process results in an empty index being pushed. The Wagtail documentation doesn't warn users of this behaviour, but it appears that this is what is happening.
Not running a schema only update results in our search views returning 500 errors as the mapping of the documents doesn't match the expected mapping of our code, resulting in the query failing.
Proposed solution
We update the logic so that we no longer do a schema only update, this will result in 500 errors.
We catch the error and raise a nicer more user friendly message that says something along the lines of "Search is currently down, it should be back up in X minutes" etc.
We reduce the likelihood of users seeing this on deployment, by only running the update index command on deployments that we think NEED the index updating.
The outcome of this will be that deployments that change search mappings will result in an update index and users seeing an error message (a much nicer error message). However, most deployments shouldn't effect the search at all.
Changes made so far: