@@ -610,7 +610,7 @@ def get_doc_from_es(
610
610
611
611
def handle_ubq_retries (
612
612
self : Task ,
613
- exc : ConnectionError | ConflictError ,
613
+ exc : ConnectionError | ConflictError | ConnectionTimeout ,
614
614
count_query = QuerySet | None ,
615
615
) -> None :
616
616
"""Handles the retry logic for update_children_docs_by_query task based on
@@ -627,9 +627,9 @@ def handle_ubq_retries(
627
627
if retry_count >= self .max_retries :
628
628
raise exc
629
629
630
- if isinstance (exc , ConnectionError ) and count_query :
630
+ if isinstance (exc , ConnectionError | ConnectionTimeout ) and count_query :
631
631
num_documents = count_query .count ()
632
- estimated_time_ms = num_documents * 15 # 15ms per document
632
+ estimated_time_ms = num_documents * 90 # 90ms per document
633
633
# Convert ms to seconds
634
634
estimated_delay_sec = round (estimated_time_ms / 1000 )
635
635
# Apply exponential backoff with jitter
@@ -693,6 +693,9 @@ def update_children_docs_by_query(
693
693
parent_instance = get_instance_from_db (parent_instance_id , Docket )
694
694
if not parent_instance :
695
695
return
696
+ count_query = RECAPDocument .objects .filter (
697
+ docket_entry__docket_id = parent_instance_id
698
+ )
696
699
elif (
697
700
es_document is OpinionDocument or es_document is OpinionClusterDocument
698
701
):
@@ -704,10 +707,7 @@ def update_children_docs_by_query(
704
707
)
705
708
if not parent_instance :
706
709
return
707
-
708
- count_query = RECAPDocument .objects .filter (
709
- docket_entry__docket_id = parent_instance_id
710
- )
710
+ count_query = Opinion .objects .filter (cluster_id = parent_instance_id )
711
711
712
712
if not main_doc :
713
713
# Abort bulk update for a not supported document or non-existing parent
@@ -744,7 +744,7 @@ def update_children_docs_by_query(
744
744
ubq = ubq .script (source = script_source , params = params )
745
745
try :
746
746
ubq .execute ()
747
- except (ConnectionError , ConflictError ) as exc :
747
+ except (ConnectionError , ConflictError , ConnectionTimeout ) as exc :
748
748
handle_ubq_retries (self , exc , count_query = count_query )
749
749
750
750
if settings .ELASTICSEARCH_DSL_AUTO_REFRESH :
0 commit comments