Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve index update #645

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Improve index update #645

wants to merge 6 commits into from

Conversation

CamLamb
Copy link
Contributor

@CamLamb CamLamb commented Jun 12, 2024

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:

  • No more schema only updates
  • Catch the search error and return a nicer error message to the user
  • Only update search on deployments that alter the mapping

# hash of the search mapping dict that was stored in the cache, then
# update the search index.
if sm_hash != new_sm_hash:
cache.set("search_mapping_hash", new_sm_hash)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not currently settled on using the cache for this, but this is just to capture the concept first.
Happy to discuss alternatives as the negative impact of this not being in the cache is higher than "just a longer page load time"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant