Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
4aee74ea
milvus
项目概览
BaiXuePrincess
/
milvus
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4aee74ea
编写于
8月 28, 2019
作者:
G
groot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MS-427 Describe index error after drop index
Former-commit-id: 1c4f1319ec349f05784d038fa4cbd0c0b8279100
上级
589763ed
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
61 addition
and
29 deletion
+61
-29
cpp/CHANGELOG.md
cpp/CHANGELOG.md
+1
-0
cpp/src/db/DB.h
cpp/src/db/DB.h
+0
-1
cpp/src/db/DBImpl.cpp
cpp/src/db/DBImpl.cpp
+8
-18
cpp/src/db/DBImpl.h
cpp/src/db/DBImpl.h
+0
-2
cpp/src/db/insert/MemTableFile.cpp
cpp/src/db/insert/MemTableFile.cpp
+8
-2
cpp/src/db/meta/MetaTypes.h
cpp/src/db/meta/MetaTypes.h
+1
-1
cpp/src/db/meta/MySQLMetaImpl.cpp
cpp/src/db/meta/MySQLMetaImpl.cpp
+17
-0
cpp/src/db/meta/SqliteMetaImpl.cpp
cpp/src/db/meta/SqliteMetaImpl.cpp
+16
-1
cpp/unittest/db/db_tests.cpp
cpp/unittest/db/db_tests.cpp
+10
-4
未找到文件。
cpp/CHANGELOG.md
浏览文件 @
4aee74ea
...
@@ -10,6 +10,7 @@ Please mark all change in change log and use the ticket from JIRA.
...
@@ -10,6 +10,7 @@ Please mark all change in change log and use the ticket from JIRA.
-
MS-416 - ExecutionEngineImpl::GpuCache has not return value cause crash
-
MS-416 - ExecutionEngineImpl::GpuCache has not return value cause crash
-
MS-417 - YAML sequence load disable cause scheduler startup failed
-
MS-417 - YAML sequence load disable cause scheduler startup failed
-
MS-413 - Create index failed and server exited
-
MS-413 - Create index failed and server exited
-
MS-427 - Describe index error after drop index
## Improvement
## Improvement
-
MS-327 - Clean code for milvus
-
MS-327 - Clean code for milvus
...
...
cpp/src/db/DB.h
浏览文件 @
4aee74ea
...
@@ -46,7 +46,6 @@ public:
...
@@ -46,7 +46,6 @@ public:
virtual
Status
Size
(
uint64_t
&
result
)
=
0
;
virtual
Status
Size
(
uint64_t
&
result
)
=
0
;
virtual
Status
BuildIndex
(
const
std
::
string
&
table_id
)
=
0
;
virtual
Status
CreateIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
=
0
;
virtual
Status
CreateIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
=
0
;
virtual
Status
DescribeIndex
(
const
std
::
string
&
table_id
,
TableIndex
&
index
)
=
0
;
virtual
Status
DescribeIndex
(
const
std
::
string
&
table_id
,
TableIndex
&
index
)
=
0
;
virtual
Status
DropIndex
(
const
std
::
string
&
table_id
)
=
0
;
virtual
Status
DropIndex
(
const
std
::
string
&
table_id
)
=
0
;
...
...
cpp/src/db/DBImpl.cpp
浏览文件 @
4aee74ea
...
@@ -424,7 +424,14 @@ Status DBImpl::MergeFiles(const std::string& table_id, const meta::DateT& date,
...
@@ -424,7 +424,14 @@ Status DBImpl::MergeFiles(const std::string& table_id, const meta::DateT& date,
}
}
//step 4: update table files state
//step 4: update table files state
//if index type isn't IDMAP, set file type to TO_INDEX if file size execeed index_file_size
//else set file type to RAW, no need to build index
if
(
table_file
.
engine_type_
!=
(
int
)
EngineType
::
FAISS_IDMAP
)
{
table_file
.
file_type_
=
(
index
->
PhysicalSize
()
>=
table_file
.
index_file_size_
)
?
meta
::
TableFileSchema
::
TO_INDEX
:
meta
::
TableFileSchema
::
RAW
;
}
else
{
table_file
.
file_type_
=
meta
::
TableFileSchema
::
RAW
;
table_file
.
file_type_
=
meta
::
TableFileSchema
::
RAW
;
}
table_file
.
file_size_
=
index
->
PhysicalSize
();
table_file
.
file_size_
=
index
->
PhysicalSize
();
table_file
.
row_count_
=
index
->
Count
();
table_file
.
row_count_
=
index
->
Count
();
updated
.
push_back
(
table_file
);
updated
.
push_back
(
table_file
);
...
@@ -516,22 +523,6 @@ void DBImpl::StartBuildIndexTask(bool force) {
...
@@ -516,22 +523,6 @@ void DBImpl::StartBuildIndexTask(bool force) {
}
}
}
}
Status
DBImpl
::
BuildIndex
(
const
std
::
string
&
table_id
)
{
bool
has
=
false
;
meta_ptr_
->
HasNonIndexFiles
(
table_id
,
has
);
int
times
=
1
;
while
(
has
)
{
ENGINE_LOG_DEBUG
<<
"Non index files detected in "
<<
table_id
<<
"! Will build index "
<<
times
;
meta_ptr_
->
UpdateTableFilesToIndex
(
table_id
);
/* StartBuildIndexTask(true); */
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
std
::
min
(
10
*
1000
,
times
*
100
)));
meta_ptr_
->
HasNonIndexFiles
(
table_id
,
has
);
times
++
;
}
return
Status
::
OK
();
}
Status
DBImpl
::
CreateIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
{
Status
DBImpl
::
CreateIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
{
{
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
build_index_mutex_
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
build_index_mutex_
);
...
@@ -558,7 +549,6 @@ Status DBImpl::CreateIndex(const std::string& table_id, const TableIndex& index)
...
@@ -558,7 +549,6 @@ Status DBImpl::CreateIndex(const std::string& table_id, const TableIndex& index)
}
}
//step 3: update index info
//step 3: update index info
status
=
meta_ptr_
->
UpdateTableIndexParam
(
table_id
,
index
);
status
=
meta_ptr_
->
UpdateTableIndexParam
(
table_id
,
index
);
if
(
!
status
.
ok
())
{
if
(
!
status
.
ok
())
{
ENGINE_LOG_ERROR
<<
"Failed to update table index info"
;
ENGINE_LOG_ERROR
<<
"Failed to update table index info"
;
...
...
cpp/src/db/DBImpl.h
浏览文件 @
4aee74ea
...
@@ -82,8 +82,6 @@ class DBImpl : public DB {
...
@@ -82,8 +82,6 @@ class DBImpl : public DB {
Status
Size
(
uint64_t
&
result
)
override
;
Status
Size
(
uint64_t
&
result
)
override
;
Status
BuildIndex
(
const
std
::
string
&
table_id
)
override
;
Status
CreateIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
override
;
Status
CreateIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
override
;
Status
DescribeIndex
(
const
std
::
string
&
table_id
,
TableIndex
&
index
)
override
;
Status
DescribeIndex
(
const
std
::
string
&
table_id
,
TableIndex
&
index
)
override
;
...
...
cpp/src/db/insert/MemTableFile.cpp
浏览文件 @
4aee74ea
...
@@ -87,8 +87,14 @@ Status MemTableFile::Serialize() {
...
@@ -87,8 +87,14 @@ Status MemTableFile::Serialize() {
table_file_schema_
.
file_size_
=
execution_engine_
->
PhysicalSize
();
table_file_schema_
.
file_size_
=
execution_engine_
->
PhysicalSize
();
table_file_schema_
.
row_count_
=
execution_engine_
->
Count
();
table_file_schema_
.
row_count_
=
execution_engine_
->
Count
();
//if index type isn't IDMAP, set file type to TO_INDEX if file size execeed index_file_size
//else set file type to RAW, no need to build index
if
(
table_file_schema_
.
engine_type_
!=
(
int
)
EngineType
::
FAISS_IDMAP
)
{
table_file_schema_
.
file_type_
=
(
size
>=
table_file_schema_
.
index_file_size_
)
?
table_file_schema_
.
file_type_
=
(
size
>=
table_file_schema_
.
index_file_size_
)
?
meta
::
TableFileSchema
::
TO_INDEX
:
meta
::
TableFileSchema
::
RAW
;
meta
::
TableFileSchema
::
TO_INDEX
:
meta
::
TableFileSchema
::
RAW
;
}
else
{
table_file_schema_
.
file_type_
=
meta
::
TableFileSchema
::
RAW
;
}
auto
status
=
meta_
->
UpdateTableFile
(
table_file_schema_
);
auto
status
=
meta_
->
UpdateTableFile
(
table_file_schema_
);
...
...
cpp/src/db/meta/MetaTypes.h
浏览文件 @
4aee74ea
...
@@ -19,8 +19,8 @@ namespace meta {
...
@@ -19,8 +19,8 @@ namespace meta {
constexpr
int32_t
DEFAULT_ENGINE_TYPE
=
(
int
)
EngineType
::
FAISS_IDMAP
;
constexpr
int32_t
DEFAULT_ENGINE_TYPE
=
(
int
)
EngineType
::
FAISS_IDMAP
;
constexpr
int32_t
DEFAULT_NLIST
=
16384
;
constexpr
int32_t
DEFAULT_NLIST
=
16384
;
constexpr
int32_t
DEFAULT_INDEX_FILE_SIZE
=
ONE_GB
;
constexpr
int32_t
DEFAULT_METRIC_TYPE
=
(
int
)
MetricType
::
L2
;
constexpr
int32_t
DEFAULT_METRIC_TYPE
=
(
int
)
MetricType
::
L2
;
constexpr
int32_t
DEFAULT_INDEX_FILE_SIZE
=
ONE_GB
;
constexpr
int64_t
FLAG_MASK_USERID
=
1
;
constexpr
int64_t
FLAG_MASK_USERID
=
1
;
...
...
cpp/src/db/meta/MySQLMetaImpl.cpp
浏览文件 @
4aee74ea
...
@@ -536,6 +536,7 @@ Status MySQLMetaImpl::DropTableIndex(const std::string &table_id) {
...
@@ -536,6 +536,7 @@ Status MySQLMetaImpl::DropTableIndex(const std::string &table_id) {
Query
dropTableIndexQuery
=
connectionPtr
->
query
();
Query
dropTableIndexQuery
=
connectionPtr
->
query
();
//soft delete index files
dropTableIndexQuery
<<
"UPDATE TableFiles "
<<
dropTableIndexQuery
<<
"UPDATE TableFiles "
<<
"SET file_type = "
<<
std
::
to_string
(
TableFileSchema
::
TO_DELETE
)
<<
","
<<
"SET file_type = "
<<
std
::
to_string
(
TableFileSchema
::
TO_DELETE
)
<<
","
<<
"updated_time = "
<<
utils
::
GetMicroSecTimeStamp
()
<<
" "
<<
"updated_time = "
<<
utils
::
GetMicroSecTimeStamp
()
<<
" "
<<
...
@@ -550,6 +551,7 @@ Status MySQLMetaImpl::DropTableIndex(const std::string &table_id) {
...
@@ -550,6 +551,7 @@ Status MySQLMetaImpl::DropTableIndex(const std::string &table_id) {
dropTableIndexQuery
.
error
());
dropTableIndexQuery
.
error
());
}
}
//set all backup file to raw
dropTableIndexQuery
<<
"UPDATE TableFiles "
<<
dropTableIndexQuery
<<
"UPDATE TableFiles "
<<
"SET file_type = "
<<
std
::
to_string
(
TableFileSchema
::
RAW
)
<<
","
<<
"SET file_type = "
<<
std
::
to_string
(
TableFileSchema
::
RAW
)
<<
","
<<
"updated_time = "
<<
utils
::
GetMicroSecTimeStamp
()
<<
" "
<<
"updated_time = "
<<
utils
::
GetMicroSecTimeStamp
()
<<
" "
<<
...
@@ -564,6 +566,21 @@ Status MySQLMetaImpl::DropTableIndex(const std::string &table_id) {
...
@@ -564,6 +566,21 @@ Status MySQLMetaImpl::DropTableIndex(const std::string &table_id) {
dropTableIndexQuery
.
error
());
dropTableIndexQuery
.
error
());
}
}
//set table index type to raw
dropTableIndexQuery
<<
"UPDATE Tables "
<<
"SET engine_type = "
<<
std
::
to_string
(
DEFAULT_ENGINE_TYPE
)
<<
","
<<
"nlist = "
<<
std
::
to_string
(
DEFAULT_NLIST
)
<<
" "
<<
"metric_type = "
<<
std
::
to_string
(
DEFAULT_METRIC_TYPE
)
<<
" "
<<
"WHERE table_id = "
<<
quote
<<
table_id
<<
";"
;
ENGINE_LOG_DEBUG
<<
"MySQLMetaImpl::DropTableIndex: "
<<
dropTableIndexQuery
.
str
();
if
(
!
dropTableIndexQuery
.
exec
())
{
ENGINE_LOG_ERROR
<<
"QUERY ERROR WHEN DROP TABLE INDEX"
;
return
Status
::
DBTransactionError
(
"QUERY ERROR WHEN DROP TABLE INDEX"
,
dropTableIndexQuery
.
error
());
}
}
//Scoped Connection
}
//Scoped Connection
}
catch
(
const
BadQuery
&
er
)
{
}
catch
(
const
BadQuery
&
er
)
{
...
...
cpp/src/db/meta/SqliteMetaImpl.cpp
浏览文件 @
4aee74ea
...
@@ -461,6 +461,17 @@ Status SqliteMetaImpl::DropTableIndex(const std::string &table_id) {
...
@@ -461,6 +461,17 @@ Status SqliteMetaImpl::DropTableIndex(const std::string &table_id) {
c
(
&
TableFileSchema
::
file_type_
)
==
(
int
)
TableFileSchema
::
BACKUP
c
(
&
TableFileSchema
::
file_type_
)
==
(
int
)
TableFileSchema
::
BACKUP
));
));
//set table index type to raw
ConnectorPtr
->
update_all
(
set
(
c
(
&
TableSchema
::
engine_type_
)
=
DEFAULT_ENGINE_TYPE
,
c
(
&
TableSchema
::
nlist_
)
=
DEFAULT_NLIST
,
c
(
&
TableSchema
::
metric_type_
)
=
DEFAULT_METRIC_TYPE
),
where
(
c
(
&
TableSchema
::
table_id_
)
==
table_id
));
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
std
::
exception
&
e
)
{
return
HandleException
(
"Encounter exception when delete table index files"
,
e
);
return
HandleException
(
"Encounter exception when delete table index files"
,
e
);
}
}
...
@@ -798,11 +809,15 @@ Status SqliteMetaImpl::FilesToSearch(const std::string &table_id,
...
@@ -798,11 +809,15 @@ Status SqliteMetaImpl::FilesToSearch(const std::string &table_id,
}
}
files
[
table_file
.
date_
].
push_back
(
table_file
);
files
[
table_file
.
date_
].
push_back
(
table_file
);
}
}
if
(
files
.
empty
())
{
std
::
cout
<<
"ERROR"
<<
std
::
endl
;
}
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
std
::
exception
&
e
)
{
return
HandleException
(
"Encounter exception when iterate index files"
,
e
);
return
HandleException
(
"Encounter exception when iterate index files"
,
e
);
}
}
return
Status
::
OK
();
return
Status
::
OK
();
}
}
...
...
cpp/unittest/db/db_tests.cpp
浏览文件 @
4aee74ea
...
@@ -34,7 +34,6 @@ namespace {
...
@@ -34,7 +34,6 @@ namespace {
engine
::
meta
::
TableSchema
table_info
;
engine
::
meta
::
TableSchema
table_info
;
table_info
.
dimension_
=
TABLE_DIM
;
table_info
.
dimension_
=
TABLE_DIM
;
table_info
.
table_id_
=
TABLE_NAME
;
table_info
.
table_id_
=
TABLE_NAME
;
table_info
.
engine_type_
=
(
int
)
engine
::
EngineType
::
FAISS_IDMAP
;
return
table_info
;
return
table_info
;
}
}
...
@@ -263,7 +262,9 @@ TEST_F(DBTest, SEARCH_TEST) {
...
@@ -263,7 +262,9 @@ TEST_F(DBTest, SEARCH_TEST) {
ASSERT_STATS
(
stat
);
ASSERT_STATS
(
stat
);
}
}
db_
->
BuildIndex
(
TABLE_NAME
);
// wait until build index finish
engine
::
TableIndex
index
;
index
.
engine_type_
=
(
int
)
engine
::
EngineType
::
FAISS_IDMAP
;
db_
->
CreateIndex
(
TABLE_NAME
,
index
);
// wait until build index finish
{
{
engine
::
QueryResults
results
;
engine
::
QueryResults
results
;
...
@@ -273,7 +274,7 @@ TEST_F(DBTest, SEARCH_TEST) {
...
@@ -273,7 +274,7 @@ TEST_F(DBTest, SEARCH_TEST) {
{
//search by specify index file
{
//search by specify index file
engine
::
meta
::
DatesT
dates
;
engine
::
meta
::
DatesT
dates
;
std
::
vector
<
std
::
string
>
file_ids
=
{
"4"
,
"5"
,
"6"
};
std
::
vector
<
std
::
string
>
file_ids
=
{
"
1"
,
"2"
,
"3"
,
"
4"
,
"5"
,
"6"
};
engine
::
QueryResults
results
;
engine
::
QueryResults
results
;
stat
=
db_
->
Query
(
TABLE_NAME
,
file_ids
,
k
,
nq
,
10
,
xq
.
data
(),
dates
,
results
);
stat
=
db_
->
Query
(
TABLE_NAME
,
file_ids
,
k
,
nq
,
10
,
xq
.
data
(),
dates
,
results
);
ASSERT_STATS
(
stat
);
ASSERT_STATS
(
stat
);
...
@@ -305,7 +306,12 @@ TEST_F(DBTest, PRELOADTABLE_TEST) {
...
@@ -305,7 +306,12 @@ TEST_F(DBTest, PRELOADTABLE_TEST) {
db_
->
InsertVectors
(
TABLE_NAME
,
nb
,
xb
.
data
(),
target_ids
);
db_
->
InsertVectors
(
TABLE_NAME
,
nb
,
xb
.
data
(),
target_ids
);
ASSERT_EQ
(
target_ids
.
size
(),
nb
);
ASSERT_EQ
(
target_ids
.
size
(),
nb
);
}
}
db_
->
BuildIndex
(
TABLE_NAME
);
sleep
(
2
);
engine
::
TableIndex
index
;
index
.
engine_type_
=
(
int
)
engine
::
EngineType
::
FAISS_IDMAP
;
db_
->
CreateIndex
(
TABLE_NAME
,
index
);
// wait until build index finish
int64_t
prev_cache_usage
=
cache
::
CpuCacheMgr
::
GetInstance
()
->
CacheUsage
();
int64_t
prev_cache_usage
=
cache
::
CpuCacheMgr
::
GetInstance
()
->
CacheUsage
();
stat
=
db_
->
PreloadTable
(
TABLE_NAME
);
stat
=
db_
->
PreloadTable
(
TABLE_NAME
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录