-
Notifications
You must be signed in to change notification settings - Fork 3
reindexing changes #1247
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
reindexing changes #1247
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -458,11 +458,26 @@ def wrap_retry_exception(*exception_classes): | |
|
|
||
|
|
||
| @app.task(bind=True) | ||
| def start_recreate_index(self, indexes): | ||
| def start_recreate_index(self, indexes, remove_existing_reindexing_tags): | ||
| """ | ||
| Wipe and recreate index and mapping, and index all items. | ||
| """ | ||
| try: | ||
| if not remove_existing_reindexing_tags: | ||
| existing_reindexing_indexes = api.get_existing_reindexing_indexes(indexes) | ||
|
|
||
| if existing_reindexing_indexes: | ||
| error = ( | ||
| f"Reindexing in progress. Reindexing indexes already exist: " | ||
| f"{', '.join(existing_reindexing_indexes)}" | ||
| ) | ||
| log.exception(error) | ||
| return error | ||
|
|
||
| api.delete_orphaned_indexes( | ||
| indexes, delete_reindexing_tags=remove_existing_reindexing_tags | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there are reindex orphans to delete,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree the conditional is not strictly necessary . |
||
| ) | ||
|
|
||
| new_backing_indices = { | ||
| obj_type: api.create_backing_index(obj_type) for obj_type in indexes | ||
| } | ||
|
|
@@ -768,7 +783,9 @@ def get_update_learning_resource_tasks(resource_type): | |
| ] | ||
|
|
||
|
|
||
| @app.task(autoretry_for=(RetryError,), retry_backoff=True, rate_limit="600/m") | ||
| @app.task( | ||
| acks_late=True, autoretry_for=(RetryError,), retry_backoff=True, rate_limit="600/m" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added acks_late=True here just in case, although I don't think this job failing is how orphaned indexes are generally created |
||
| ) | ||
| def finish_recreate_index(results, backing_indices): | ||
| """ | ||
| Swap reindex backing index with default backing index | ||
|
|
@@ -780,7 +797,9 @@ def finish_recreate_index(results, backing_indices): | |
| errors = merge_strings(results) | ||
| if errors: | ||
| try: | ||
| api.delete_orphaned_indices() | ||
| api.delete_orphaned_indexes( | ||
| list(backing_indices.keys()), delete_reindexing_tags=True | ||
| ) | ||
| except RequestError as ex: | ||
| raise RetryError(str(ex)) from ex | ||
| msg = f"Errors occurred during recreate_index: {errors}" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to check both here and in the management command in case start_recreate_index is stuck behind other jobs and another indexing job is started while this task is in the queue. We could just have the check here but it's nicer for the user to know about the existing reindexing indexes right away if it already exists when the management command runs