From 2ee54541aae43e7c0ca2cd863fe455ae8f52bf69 Mon Sep 17 00:00:00 2001
From: bigsheeper <yihao.dai@zilliz.com>
Date: Fri, 5 Feb 2021 10:25:47 +0800
Subject: [PATCH] Fix query node address

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
---
 internal/proxynode/insert_channels.go |  8 +++++---
 internal/querynode/param_table.go     | 19 +++++--------------
 tests/python/requirements.txt         |  2 +-
 3 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/internal/proxynode/insert_channels.go b/internal/proxynode/insert_channels.go
index 90451614b..deda7ef03 100644
--- a/internal/proxynode/insert_channels.go
+++ b/internal/proxynode/insert_channels.go
@@ -134,10 +134,12 @@ func (m *InsertChannelsMap) closeInsertMsgStream(collID UniqueID) error {
 	m.usageHistogram[loc]--
 	if m.usageHistogram[loc] <= 0 {
 		m.insertMsgStreams[loc].Close()
-		m.droppedBitMap[loc] = 1
-		delete(m.collectionID2InsertChannels, collID)
-		log.Print("close insert message stream ...")
 	}
+	log.Print("close insert message stream ...")
+
+	m.droppedBitMap[loc] = 1
+	delete(m.collectionID2InsertChannels, collID)
+
 	return nil
 }
 
diff --git a/internal/querynode/param_table.go b/internal/querynode/param_table.go
index a2254f1bd..d34a04e6e 100644
--- a/internal/querynode/param_table.go
+++ b/internal/querynode/param_table.go
@@ -4,8 +4,8 @@ import (
 	"log"
 	"os"
 	"strconv"
-	"strings"
 
+	"github.com/zilliztech/milvus-distributed/internal/util/funcutil"
 	"github.com/zilliztech/milvus-distributed/internal/util/paramtable"
 )
 
@@ -87,22 +87,13 @@ func (p *ParamTable) Init() {
 		}
 	}
 
-	queryNodeAddress := os.Getenv("QUERY_NODE_ADDRESS")
-	if queryNodeAddress == "" {
+	queryNodeIP := os.Getenv("QUERY_NODE_IP")
+	if queryNodeIP == "" {
 		p.QueryNodeIP = "localhost"
-		p.QueryNodePort = 20010
 	} else {
-		ipAndPort := strings.Split(queryNodeAddress, ":")
-		if len(ipAndPort) != 2 {
-			panic("illegal query node address")
-		}
-		p.QueryNodeIP = ipAndPort[0]
-		port, err := strconv.ParseInt(ipAndPort[1], 10, 64)
-		if err != nil {
-			panic(err)
-		}
-		p.QueryNodePort = port
+		p.QueryNodeIP = queryNodeIP
 	}
+	p.QueryNodePort = int64(funcutil.GetAvailablePort())
 
 	err = p.LoadYaml("advanced/common.yaml")
 	if err != nil {
diff --git a/tests/python/requirements.txt b/tests/python/requirements.txt
index a4136e23e..fcf08cf5d 100644
--- a/tests/python/requirements.txt
+++ b/tests/python/requirements.txt
@@ -2,7 +2,7 @@ grpcio==1.26.0
 grpcio-tools==1.26.0
 numpy==1.18.1
 pytest-cov==2.8.1
-pymilvus-distributed==0.0.17
+pymilvus-distributed==0.0.19
 sklearn==0.0
 pytest==4.5.0
 pytest-timeout==1.3.3
-- 
GitLab