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

Upgrade elasticsearch #1733

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Upgrade elasticsearch #1733

wants to merge 5 commits into from

Conversation

chigby
Copy link
Collaborator

@chigby chigby commented Aug 20, 2021

Fixes #1716

Note: will require upgrading ES on Heroku as this is deployed.

Copy link
Member

@nmorduch nmorduch left a comment

Choose a reason for hiding this comment

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

How do we upgrade on the server? Please write up how

@chigby
Copy link
Collaborator Author

chigby commented Sep 23, 2021

To upgrade Elasticsearch on the server, you must remove the addon and then re-create it at a different version. Then, the data must be re-indexed.

To upgrade the version, use these commands. Insert the appropriate app name for which environment you want this upgrade to affect.

heroku addons:destroy searchbox --app na-develop
heroku addons:create searchbox --es_version=7 --app na-develop

Then, reindex the data:

heroku run python manage.py update_index --app na-develop

@nmorduch nmorduch self-requested a review September 29, 2021 15:04
@nmorduch nmorduch self-assigned this Sep 29, 2021
@nmorduch nmorduch dismissed their stale review September 29, 2021 16:43

Changes were made, now needs review

@nmorduch nmorduch temporarily deployed to na-develop September 29, 2021 17:53 Inactive
Copy link
Member

@nmorduch nmorduch left a comment

Choose a reason for hiding this comment

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

Looks like we should try 7.10.2 for searchbox's sake 🙃

@nmorduch nmorduch temporarily deployed to na-develop September 30, 2021 17:25 Inactive
@nmorduch
Copy link
Member

heroku run python manage.py update_index --app na-develop

Running python manage.py update_index on ⬢ na-develop... up, run.6843 (Hobby)
/app/.heroku/python/lib/python3.8/site-packages/wagtail/admin/rich_text/editors/draftail/__init__.py:42: RuntimeWarning: Draftail received an unknown feature 'undo'.
  warnings.warn(
/app/.heroku/python/lib/python3.8/site-packages/wagtail/admin/rich_text/editors/draftail/__init__.py:42: RuntimeWarning: Draftail received an unknown feature 'redo'.
  warnings.warn(
Updating backend: default
default: Rebuilding index elasticsearch__home_customimage
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.8/site-packages/wagtail/search/management/commands/update_index.py", line 124, in handle
    self.update_backend(
  File "/app/.heroku/python/lib/python3.8/site-packages/wagtail/search/management/commands/update_index.py", line 74, in update_backend
    index = rebuilder.start()
  File "/app/.heroku/python/lib/python3.8/site-packages/wagtail/search/backends/elasticsearch5.py", line 949, in start
    self.reset_index()
  File "/app/.heroku/python/lib/python3.8/site-packages/wagtail/search/backends/elasticsearch5.py", line 945, in reset_index
    self.index.reset()
  File "/app/.heroku/python/lib/python3.8/site-packages/wagtail/search/backends/elasticsearch5.py", line 934, in reset
    self.delete()
  File "/app/.heroku/python/lib/python3.8/site-packages/wagtail/search/backends/elasticsearch5.py", line 833, in delete
    self.es.indices.delete(self.name)
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/client/utils.py", line 152, in _wrapped
    return func(*args, params=params, headers=headers, **kwargs)
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/client/indices.py", line 294, in delete
    return self.transport.perform_request(
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/transport.py", line 392, in perform_request
    raise e
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/transport.py", line 358, in perform_request
    status, headers_response, data = connection.perform_request(
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/connection/http_urllib3.py", line 269, in perform_request
    self._raise_error(response.status, raw_data)
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/connection/base.py", line 315, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(
elasticsearch.exceptions.AuthenticationException: AuthenticationException(401, '{"status":"error", "message":"access denied"}')
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

@nmorduch
Copy link
Member

You're also welcome to do the attempting this directly on na-develop!

@chigby
Copy link
Collaborator Author

chigby commented Oct 1, 2021

This is working for me now.. I had to specify that we wanted the "small" plan for searchbox, e.g.

heroku addons:create searchbox:small --es_version=7 --app na-develop

@chigby
Copy link
Collaborator Author

chigby commented Oct 1, 2021

Well, the update_index command worked, anyway. The actual search function seems to be having problems now.

@chigby chigby temporarily deployed to na-develop October 1, 2021 16:16 Inactive
@chigby
Copy link
Collaborator Author

chigby commented Oct 1, 2021

Continuing to look into this, and this is what error I'm seeing on the develop server:

>>> from wagtail.core.models import Page
>>> Page.objects.public().search('vermont')
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/app/.heroku/python/lib/python3.8/site-packages/wagtail/search/backends/base.py", line 258, in __repr__
    data = list(self[:21])
  File "/app/.heroku/python/lib/python3.8/site-packages/wagtail/search/backends/base.py", line 255, in __len__
    return len(self.results())
  File "/app/.heroku/python/lib/python3.8/site-packages/wagtail/search/backends/base.py", line 218, in results
    self._results_cache = list(self._do_search())
  File "/app/.heroku/python/lib/python3.8/site-packages/wagtail/search/backends/elasticsearch5.py", line 800, in _do_search
    hits = self.backend.es.search(**params)['hits']['hits']
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/client/utils.py", line 152, in _wrapped
    return func(*args, params=params, headers=headers, **kwargs)
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/client/__init__.py", line 1658, in search
    return self.transport.perform_request(
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/transport.py", line 392, in perform_request
    raise e
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/transport.py", line 358, in perform_request
    status, headers_response, data = connection.perform_request(
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/connection/http_urllib3.py", line 269, in perform_request
    self._raise_error(response.status, raw_data)
  File "/app/.heroku/python/lib/python3.8/site-packages/elasticsearch/connection/base.py", line 315, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(
elasticsearch.exceptions.TransportError: TransportError(500, '{"error_id":"f1883ad8-1200-4ced-9e81-61b244cc395a","errors":[{"code":10,"message":"An error occurred while fulfilling the request"}]}')

This is not what I'm seeing locally, with the same version of the ES server (7.10.2). I've tried to figure out what's going on here (the error message is zero help) and the closest thing I can find is that possibly the query we're sending to the server is too large? When I remove all the PageViewRestriction objects (which are what determines which pages appear in the public() query) then the query succeeds. It's possible there's something else going on that this is merely a consequence of.

@nmorduch nmorduch assigned chigby and unassigned nmorduch Apr 7, 2023
@chigby chigby mentioned this pull request Nov 3, 2023
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.

[3h] Upgrade to ElasticSearch 6 or 7
2 participants