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

Reduce flakiness of elasticsearch synchronization #925

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion isic/core/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def add_to_search_index(image: Image) -> None:
)


def bulk_add_to_search_index(qs: QuerySet[Image], chunk_size: int = 2000) -> None:
def bulk_add_to_search_index(qs: QuerySet[Image], chunk_size: int = 2_000) -> None:
from opensearchpy.helpers import parallel_bulk

# qs must be generated with with_elasticsearch_properties
Expand All @@ -125,6 +125,8 @@ def bulk_add_to_search_index(qs: QuerySet[Image], chunk_size: int = 2000) -> Non
# The default chunk_size is 2000, but that may be too many models to fit into memory.
# Note the default chunk_size matches QuerySet.iterator
chunk_size=chunk_size,
# the thread count should be limited to avoid exhausting the connection pool
thread_count=2,
):
if not success:
logger.error("Failed to insert document into elasticsearch: %s", info)
Expand Down
4 changes: 2 additions & 2 deletions isic/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def share_collection_with_users_task(collection_pk: int, grantor_pk: int, user_p


@shared_task(
soft_time_limit=300,
time_limit=310,
soft_time_limit=900,
time_limit=910,
autoretry_for=(ConnectionError, TimeoutError),
retry_backoff=True,
retry_backoff_max=600,
Expand Down
Loading