Skip to content

Commit

Permalink
enhance: retry on inconsistent requery (#1975) (#1976)
Browse files Browse the repository at this point in the history
Signed-off-by: longjiquan <[email protected]>
  • Loading branch information
longjiquan authored Mar 18, 2024
1 parent 5332f09 commit 2110394
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pymilvus/client/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ def _execute_search(
return SearchFuture(None, None, e)
raise e from e

@retry_on_rpc_failure()
@retry_on_rpc_failure(retry_on_inconsistent_requery=True)
def search(
self,
collection_name: str,
Expand Down
11 changes: 9 additions & 2 deletions pymilvus/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def retry_on_rpc_failure(
initial_back_off: float = 0.01,
max_back_off: float = 3,
back_off_multiplier: int = 3,
retry_on_inconsistent_requery: bool = False,
):
def wrapper(func: Any):
@functools.wraps(func)
Expand Down Expand Up @@ -106,8 +107,14 @@ def timeout(start_time: Optional[float] = None) -> bool:
raise MilvusException(
code=e.code, message=f"{to_msg}, message={e.message}"
) from e
if _retry_on_rate_limit and (
e.code == ErrorCode.RATE_LIMIT or e.compatible_code == common_pb2.RateLimit
if (
_retry_on_rate_limit
and (
e.code == ErrorCode.RATE_LIMIT
or e.compatible_code == common_pb2.RateLimit
)
or retry_on_inconsistent_requery
and e.code == 2200
):
time.sleep(back_off)
back_off = min(back_off * back_off_multiplier, max_back_off)
Expand Down

0 comments on commit 2110394

Please sign in to comment.