From 4175ac1f2272c33ce46bd8da57e62868f73eeac4 Mon Sep 17 00:00:00 2001
From: BossZou <40255591+BossZou@users.noreply.github.com>
Date: Wed, 6 Jan 2021 16:49:22 +0800
Subject: [PATCH] [skip ci] mishards upgrade for milvus 0.10.5 (#4581)

Signed-off-by: yinghao.zou <yinghao.zou@zilliz.com>
---
 shards/README.md                                           | 2 +-
 shards/README_CN.md                                        | 2 +-
 shards/all_in_one/all_in_one.yml                           | 4 ++--
 shards/all_in_one_with_mysql/all_in_one.yml                | 4 ++--
 .../mishards/router/plugins/file_based_hash_ring_router.py | 6 ++++--
 shards/mishards/service_handler.py                         | 7 ++++---
 shards/requirements.txt                                    | 4 ++--
 7 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/shards/README.md b/shards/README.md
index 41eb97b9c..1ad7c54a8 100644
--- a/shards/README.md
+++ b/shards/README.md
@@ -54,7 +54,7 @@ Follow below steps to start a standalone Milvus instance with Mishards from sour
 3. Start Milvus server.
 
    ```shell
-   $ sudo nvidia-docker run --rm -d -p 19530:19530 -v /tmp/milvus/db:/var/lib/milvus/db milvusdb/milvus:0.10.4-gpu-d120220-e72454
+   $ sudo nvidia-docker run --rm -d -p 19530:19530 -v /tmp/milvus/db:/var/lib/milvus/db milvusdb/milvus:0.10.5-gpu-d010621-4eda95
    ```
 
 4. Update path permissions.
diff --git a/shards/README_CN.md b/shards/README_CN.md
index 9692091e4..7ab486273 100644
--- a/shards/README_CN.md
+++ b/shards/README_CN.md
@@ -48,7 +48,7 @@ Python 版本为3.6及以上。
 3. 启动 Milvus 服务。
 
    ```shell
-   $ sudo nvidia-docker run --rm -d -p 19530:19530 -v /tmp/milvus/db:/var/lib/milvus/db milvusdb/milvus:0.10.4-gpu-d120220-e72454
+   $ sudo nvidia-docker run --rm -d -p 19530:19530 -v /tmp/milvus/db:/var/lib/milvus/db milvusdb/milvus:0.10.5-gpu-d010621-4eda95
    ```
 
 4. 更改目录权限。
diff --git a/shards/all_in_one/all_in_one.yml b/shards/all_in_one/all_in_one.yml
index 73e3d42a4..bb5bd2cea 100644
--- a/shards/all_in_one/all_in_one.yml
+++ b/shards/all_in_one/all_in_one.yml
@@ -3,7 +3,7 @@ services:
     milvus_wr:
         runtime: nvidia
         restart: always
-        image: milvusdb/milvus:0.10.4-gpu-d120220-e72454
+        image: milvusdb/milvus:0.10.5-gpu-d010621-4eda95
         ports:
             - "0.0.0.0:19540:19530"
         volumes:
@@ -13,7 +13,7 @@ services:
     milvus_ro:
         runtime: nvidia
         restart: always
-        image: milvusdb/milvus:0.10.4-gpu-d120220-e72454
+        image: milvusdb/milvus:0.10.5-gpu-d010621-4eda95
         ports:
             - "0.0.0.0:19541:19530"
         volumes:
diff --git a/shards/all_in_one_with_mysql/all_in_one.yml b/shards/all_in_one_with_mysql/all_in_one.yml
index 9dd6756bb..297a57c31 100644
--- a/shards/all_in_one_with_mysql/all_in_one.yml
+++ b/shards/all_in_one_with_mysql/all_in_one.yml
@@ -18,7 +18,7 @@ services:
     milvus_wr:
         runtime: nvidia
         restart: always
-        image: milvusdb/milvus:0.10.4-gpu-d120220-e72454
+        image: milvusdb/milvus:0.10.5-gpu-d010621-4eda95
         volumes:
             - /tmp/milvus/db:/var/lib/milvus/db
             - ./wr_server.yml:/var/lib/milvus/conf/server_config.yaml
@@ -29,7 +29,7 @@ services:
     milvus_ro:
         runtime: nvidia
         restart: always
-        image: milvusdb/milvus:0.10.4-gpu-d120220-e72454
+        image: milvusdb/milvus:0.10.5-gpu-d010621-4eda95
         volumes:
             - /tmp/milvus/db:/var/lib/milvus/db
             - ./ro_server.yml:/var/lib/milvus/conf/server_config.yaml
diff --git a/shards/mishards/router/plugins/file_based_hash_ring_router.py b/shards/mishards/router/plugins/file_based_hash_ring_router.py
index 93d14022a..0be37fc7a 100644
--- a/shards/mishards/router/plugins/file_based_hash_ring_router.py
+++ b/shards/mishards/router/plugins/file_based_hash_ring_router.py
@@ -66,8 +66,10 @@ class Factory(RouterMixin):
             raise exceptions.DBError(message=str(e), metadata=metadata)
 
         if not collections:
-            logger.error("Cannot find collection {} / {} in metadata".format(collection_name, partition_tags))
-            raise exceptions.CollectionNotFoundError('{}:{}'.format(collection_name, partition_tags), metadata=metadata)
+            logger.error("Cannot find collection {} / {} in metadata during routing. Meta url: {}"
+                         .format(collection_name, partition_tags, db.url))
+            raise exceptions.CollectionNotFoundError("{}:{} not found in metadata".format(collection_name, partition_tags),
+                                                     metadata=metadata)
 
         collection_list = []
         if not partition_tags:
diff --git a/shards/mishards/service_handler.py b/shards/mishards/service_handler.py
index b2e7b99e5..c976f3884 100644
--- a/shards/mishards/service_handler.py
+++ b/shards/mishards/service_handler.py
@@ -132,12 +132,12 @@ class ServiceHandler(milvus_pb2_grpc.MilvusServiceServicer):
                 all_topk_results.append(ret)
             else:
                 futures = []
+                start = time.time()
                 for addr, files_tuple in routing.items():
                     search_file_ids, ud_file_ids = files_tuple
                     if ud_file_ids:
                         logger.debug(f"<{addr}> needed update segment ids {ud_file_ids}")
                     conn = self.router.query_conn(addr, metadata=metadata)
-                    start = time.time()
                     ud_file_ids and conn.reload_segments(collection_id, ud_file_ids)
                     span = kwargs.get('span', None)
                     span = span if span else (None if self.tracer.empty else
@@ -155,6 +155,7 @@ class ServiceHandler(milvus_pb2_grpc.MilvusServiceServicer):
                 for f in futures:
                     ret = f.result(raw=True)
                     all_topk_results.append(ret)
+                logger.debug("Search in routing {} cost {} s".format(routing, time.time() - start))
 
         reverse = collection_meta.metric_type == Types.MetricType.IP
         with self.tracer.start_span('do_merge', child_of=p_span):
@@ -308,7 +309,7 @@ class ServiceHandler(milvus_pb2_grpc.MilvusServiceServicer):
         topk = request.topk
 
         if len(request.extra_params) == 0:
-            raise exceptions.SearchParamError(message="Search parma loss", metadata=metadata)
+            raise exceptions.SearchParamError(message="Search param loss", metadata=metadata)
         params = ujson.loads(str(request.extra_params[0].value))
 
         logger.info('Search {}: topk={} params={}'.format(
@@ -329,7 +330,7 @@ class ServiceHandler(milvus_pb2_grpc.MilvusServiceServicer):
                 metadata=metadata).get_collection_info(collection_name)
             if not status.OK():
                 raise exceptions.CollectionNotFoundError(collection_name,
-                                                    metadata=metadata)
+                                                         metadata=metadata)
 
             self.collection_meta[collection_name] = info
             collection_meta = info
diff --git a/shards/requirements.txt b/shards/requirements.txt
index e0e4a1cf9..b2e0f7dcb 100644
--- a/shards/requirements.txt
+++ b/shards/requirements.txt
@@ -14,8 +14,8 @@ py==1.8.0
 pyasn1==0.4.7
 pyasn1-modules==0.2.6
 pylint==2.5.0
-#pymilvus==0.2.14
-pymilvus-test==0.3.37
+pymilvus==0.2.15
+#pymilvus-test==0.3.37
 pyparsing==2.4.0
 pytest==4.6.3
 pytest-level==0.1.1
-- 
GitLab