未验证 提交 7326784e 编写于 作者: X XuanYang-cn 提交者: GitHub

Fix Server get stuck if create index with invalide metric types after entities inserted (#3428)

* add create index with invalid metric type case
Signed-off-by: Nyangxuan <xuan.yang@zilliz.com>

* fix bin index validation
Signed-off-by: Nyangxuan <xuan.yang@zilliz.com>

* change changelog
Signed-off-by: Nyangxuan <xuan.yang@zilliz.com>
Co-authored-by: Nyangxuan <xuan.yang@zilliz.com>
上级 6133c095
......@@ -29,6 +29,7 @@ Please mark all changes in change log and use the issue from GitHub
- \#2869 Create index failed with binary vectors
- \#2893 Insert binary data failed
- \#2957 There is no exisitence check of annoy search parameter
- \#3407 Server get stuck if create index after entities inserted with no manual flush
## Feature
- \#2319 Redo metadata to support MVCC
......
......@@ -362,15 +362,15 @@ ValidateIndexMetricType(const std::string& metric_type, const std::string& index
milvus::knowhere::Metric::SUPERSTRUCTURE,
};
if (index_type == knowhere::IndexEnum::INDEX_FAISS_IDMAP ||
index_type == knowhere::IndexEnum::INDEX_FAISS_BIN_IDMAP) {
if (index_type == knowhere::IndexEnum::INDEX_FAISS_IDMAP) {
if (s_valid_metric.find(metric_type) == s_valid_metric.end()) {
std::string msg =
"Invalid index metric type: " + metric_type + ". " + "Make sure the metric type is in MetricType list.";
LOG_SERVER_ERROR_ << msg;
return Status(SERVER_INVALID_INDEX_METRIC_TYPE, msg);
}
} else if (index_type == knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT) {
} else if (index_type == knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT ||
index_type == knowhere::IndexEnum::INDEX_FAISS_BIN_IDMAP) {
// binary
if (metric_type != knowhere::Metric::HAMMING && metric_type != knowhere::Metric::JACCARD &&
metric_type != knowhere::Metric::TANIMOTO) {
......
......@@ -513,6 +513,14 @@ class TestIndexBinary:
else:
pytest.skip("Skip index")
@pytest.fixture(
scope="function",
params=gen_binary_index()
)
def get_l2_index(self, request, connect):
request.param["metric_type"] = "L2"
return request.param
@pytest.fixture(
scope="function",
params=[
......@@ -567,6 +575,20 @@ class TestIndexBinary:
res = connect.search(binary_collection, query, search_params=search_param)
assert len(res) == nq
@pytest.mark.timeout(BUILD_TIMEOUT)
def test_create_index_invalid_metric_type_binary(self, connect, binary_collection, get_l2_index):
'''
target: test create index interface with invalid metric type
method: add entitys into binary connection, flash, create index with L2 metric type.
expected: return create_index failure
'''
# insert 6000 vectors
ids = connect.insert(binary_collection, binary_entities)
connect.flush([binary_collection])
with pytest.raises(Exception) as e:
res = connect.create_index(binary_collection, binary_field_name, get_l2_index)
"""
******************************************************************
The following cases are used to test `get_index_info` function
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册