Skip to content

Commit

Permalink
fix: Fix grpc timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
hh-space-invader committed Nov 12, 2024
1 parent 25d452d commit b01d138
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
32 changes: 15 additions & 17 deletions qdrant_client/connection.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import asyncio
import collections
from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Union
Expand Down Expand Up @@ -200,26 +201,23 @@ async def intercept_call(


def parse_channel_options(options: Optional[Dict[str, Any]] = None) -> List[Tuple[str, Any]]:
"""
Client Server
| |
|------ RPC Call -------->| (Initial attempt)
| | (Server not responding)
|<-- 20s timeout reached --| (keepalive_timeout_ms)
| |
|---- wait 10s ------> | (min/max_reconnect_backoff_ms)
| |
|------ RPC Call -------->| (Retry attempt)
| |
|-- Keepalive ping (10s) ->| (keepalive_time_ms)
"""
default_options: List[Tuple[str, Any]] = [
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
("grpc.keepalive_timeout_ms", 20000),
("grpc.keepalive_time_ms", 10000),
("grpc.min_reconnect_backoff_ms", 10000),
("grpc.max_reconnect_backoff_ms", 10000),
("grpc.enable_retries", 1),
(
"grpc.service_config",
json.dumps(
{
"methodConfig": [
{
"name": [{}],
"timeout": "10s", # TODO: propagate timeout
},
]
}
),
),
]
if options is None:
return default_options
Expand Down
3 changes: 1 addition & 2 deletions qdrant_client/uploader/grpc_uploader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import time
import logging
from itertools import count
from typing import Any, Generator, Iterable, Optional, Tuple, Union
Expand Down Expand Up @@ -49,7 +48,7 @@ def upload_batch_grpc(
break
except Exception as e:
logging.warning(f"Batch upload failed {attempt + 1} times. Retrying...")
time.sleep(5)

if attempt == max_retries - 1:
raise e
return True
Expand Down
2 changes: 1 addition & 1 deletion qdrant_client/uploader/rest_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def start(
cls,
collection_name: Optional[str] = None,
uri: str = "http://localhost:6333",
max_retries: int = 3,
max_retries: int = 5,
**kwargs: Any,
) -> "RestBatchUploader":
if not collection_name:
Expand Down

0 comments on commit b01d138

Please sign in to comment.