Skip to content

Commit 36bf878

Browse files
committed
Final bit of code review
1 parent d8f5366 commit 36bf878

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/palace/manager/celery/tasks/search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def add_documents_to_index(
5252
Submit a batch of documents to the search index.
5353
5454
:raises FailedToIndex: If the index rejected some of the documents.
55+
:raises OpenSearchException: If the index rejected the request.
5556
"""
5657
with elapsed_time_logging(
5758
log_method=log.info,
@@ -120,8 +121,6 @@ def advance_read_pointer(
120121
latest_index = revision.name_for_index(service.base_revision_name)
121122

122123
read_pointer = service.read_pointer()
123-
write_pointer = service.write_pointer()
124-
125124
if read_pointer is not None and read_pointer.version >= revision.version:
126125
return
127126

@@ -140,6 +139,7 @@ def advance_read_pointer(
140139
)
141140
return
142141

142+
write_pointer = service.write_pointer()
143143
if write_pointer is None or write_pointer.index != target_index:
144144
# The write pointer moved partway through, so our documents are split across the
145145
# old and new indexes and neither one received a complete pass.

src/palace/manager/scripts/initialization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ def migrate_search(
125125
revision: SearchSchemaRevision,
126126
) -> None:
127127
# The revision is not the most recent. We need to create a new index.
128-
# and start reindexing our data into it asynchronously. The reindex advances
129-
# the read pointer itself once it has filled the new index, so a run that never
130-
# finishes leaves reads on the old index rather than half-migrating.
128+
# and start reindexing our data into it asynchronously. When the reindex
129+
# is complete, we will switch the read pointer to the new index. The normal
130+
# search_reindex task handles this transition.
131131
cls.logger().info(f"Creating a new index for revision (v{revision.version}).")
132132
cls.create_search_index(service, revision)
133133
task = search_reindex.apply_async()

0 commit comments

Comments
 (0)