@@ -3446,9 +3446,7 @@ def annotator_queue_items_progress_update(
34463446 annotation_state = req .annotation_state ,
34473447 pb = update_pb ,
34483448 cluster_name = self .clickhouse_cluster_name ,
3449- table_name = self ._mutation_table_name (
3450- "annotator_queue_items_progress"
3451- ),
3449+ table_name = self ._mutation_table_name ("annotator_queue_items_progress" ),
34523450 )
34533451 self ._command (
34543452 update_query ,
@@ -5557,9 +5555,15 @@ def _obj_read_with_retry(
55575555 name = "clickhouse_trace_server_batched._file_content_read_with_retry"
55585556 )
55595557 def _file_content_read_with_retry (
5560- self , req : tsi .FileContentReadReq , max_attempts : int = 2
5558+ self , req : tsi .FileContentReadReq , max_attempts : int = 5
55615559 ) -> tsi .FileContentReadRes :
5562- """Read file content with retry for ClickHouse eventual consistency."""
5560+ """Read file content with retry for ClickHouse eventual consistency.
5561+
5562+ Higher attempt count than `_obj_read_with_retry` because chunked-file
5563+ reads need all chunks visible across all shards/replicas: in
5564+ replicated/distributed mode each missing chunk on any replica trips
5565+ the retry, and lag can briefly exceed the 50ms-1s window.
5566+ """
55635567 return self ._read_with_retry (
55645568 lambda : self ._file_content_read_once (req ), max_attempts = max_attempts
55655569 )
@@ -5995,7 +5999,12 @@ def _file_content_read_once(
59955999 result_rows = list (query_result .result_rows )
59966000
59976001 if len (result_rows ) < n_chunks :
5998- raise ValueError ("Missing chunks" )
6002+ # Treat as not-found so the tenacity retry in `_read_with_retry`
6003+ # picks it up. Replicated/distributed reads can transiently see
6004+ # fewer rows than `n_chunks` while replication catches up.
6005+ raise NotFoundError (
6006+ f"File with digest { req .digest } has { len (result_rows )} /{ n_chunks } chunks visible"
6007+ )
59996008 elif len (result_rows ) > n_chunks :
60006009 # The general case where this can occur is when there are multiple
60016010 # writes of the same digest AND the effective `FILE_CHUNK_SIZE`
0 commit comments