未验证 提交 b26ce064 编写于 作者: C Cai Yudong 提交者: GitHub

remove secondary path (#2560)

* config code clean
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* remove slave_paths_ from db options
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* fix clang-format
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* update version
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* update changelog
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* enable all db unittest
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* update some comments
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* update comments
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>
上级 7351b978
......@@ -12,6 +12,7 @@ Please mark all change in change log and use the issue from GitHub
- \#2509 Count up query statistics for debug ease
## Improvement
- \#2543 Remove secondary_path related code
## Task
......
此差异已折叠。
......@@ -55,8 +55,6 @@ extern const char* CONFIG_NETWORK_HTTP_PORT_DEFAULT;
/* db config */
extern const char* CONFIG_DB;
// extern const char* CONFIG_DB_BACKEND_URL;
// extern const char* CONFIG_DB_BACKEND_URL_DEFAULT;
extern const char* CONFIG_DB_ARCHIVE_DISK_THRESHOLD;
extern const char* CONFIG_DB_ARCHIVE_DISK_THRESHOLD_DEFAULT;
extern const char* CONFIG_DB_ARCHIVE_DAYS_THRESHOLD;
......@@ -226,8 +224,6 @@ class Config {
CheckNetworkConfigHTTPPort(const std::string& value);
/* db config */
// Status
// CheckDBConfigBackendUrl(const std::string& value);
Status
CheckDBConfigArchiveDiskThreshold(const std::string& value);
Status
......@@ -269,8 +265,8 @@ class Config {
Status
CheckEngineConfigSimdType(const std::string& value);
#ifdef MILVUS_GPU_VERSION
/* gpu resource config */
#ifdef MILVUS_GPU_VERSION
Status
CheckGpuResourceConfigEnable(const std::string& value);
Status
......@@ -346,8 +342,6 @@ class Config {
GetNetworkConfigHTTPPort(std::string& value);
/* db config */
// Status
// GetDBConfigBackendUrl(std::string& value);
Status
GetDBConfigArchiveDiskThreshold(int64_t& value);
Status
......@@ -389,8 +383,8 @@ class Config {
Status
GetEngineConfigSimdType(std::string& value);
#ifdef MILVUS_GPU_VERSION
/* gpu resource config */
#ifdef MILVUS_GPU_VERSION
Status
GetGpuResourceConfigEnable(bool& value);
Status
......@@ -458,8 +452,6 @@ class Config {
SetNetworkConfigHTTPPort(const std::string& value);
/* db config */
// Status
// SetDBConfigBackendUrl(const std::string& value);
Status
SetDBConfigArchiveDiskThreshold(const std::string& value);
Status
......@@ -500,9 +492,9 @@ class Config {
SetEngineConfigOmpThreadNum(const std::string& value);
Status
SetEngineConfigSimdType(const std::string& value);
#ifdef MILVUS_GPU_VERSION
/* gpu resource config */
#ifdef MILVUS_GPU_VERSION
Status
SetGpuResourceConfigEnable(const std::string& value);
Status
......
......@@ -57,7 +57,6 @@ struct ArchiveConf {
struct DBMetaOptions {
std::string path_;
std::vector<std::string> slave_paths_;
std::string backend_uri_;
ArchiveConf archive_conf_ = ArchiveConf("delete");
}; // DBMetaOptions
......
......@@ -35,9 +35,6 @@ namespace {
const char* TABLES_FOLDER = "/tables/";
uint64_t index_file_counter = 0;
std::mutex index_file_counter_mutex;
static std::string
ConstructParentFolder(const std::string& db_path, const meta::SegmentSchema& table_file) {
std::string table_path = db_path + TABLES_FOLDER + table_file.collection_id_;
......@@ -45,32 +42,6 @@ ConstructParentFolder(const std::string& db_path, const meta::SegmentSchema& tab
return partition_path;
}
static std::string
GetCollectionFileParentFolder(const DBMetaOptions& options, const meta::SegmentSchema& table_file) {
uint64_t path_count = options.slave_paths_.size() + 1;
std::string target_path = options.path_;
uint64_t index = 0;
if (meta::SegmentSchema::NEW_INDEX == table_file.file_type_) {
// index file is large file and to be persisted permanently
// we need to distribute index files to each db_path averagely
// round robin according to a file counter
std::lock_guard<std::mutex> lock(index_file_counter_mutex);
index = index_file_counter % path_count;
++index_file_counter;
} else {
// for other type files, they could be merged or deleted
// so we round robin according to their file id
index = table_file.id_ % path_count;
}
if (index > 0) {
target_path = options.slave_paths_[index - 1];
}
return ConstructParentFolder(target_path, table_file);
}
} // namespace
int64_t
......@@ -90,34 +61,18 @@ CreateCollectionPath(const DBMetaOptions& options, const std::string& collection
LOG_ENGINE_ERROR_ << status.message();
return status;
}
for (auto& path : options.slave_paths_) {
table_path = path + TABLES_FOLDER + collection_id;
status = server::CommonUtil::CreateDirectory(table_path);
fiu_do_on("CreateCollectionPath.creat_slave_path", status = Status(DB_INVALID_PATH, ""));
if (!status.ok()) {
LOG_ENGINE_ERROR_ << status.message();
return status;
}
}
return Status::OK();
}
Status
DeleteCollectionPath(const DBMetaOptions& options, const std::string& collection_id, bool force) {
std::vector<std::string> paths = options.slave_paths_;
paths.push_back(options.path_);
for (auto& path : paths) {
std::string table_path = path + TABLES_FOLDER + collection_id;
if (force) {
boost::filesystem::remove_all(table_path);
LOG_ENGINE_DEBUG_ << "Remove collection folder: " << table_path;
} else if (boost::filesystem::exists(table_path) && boost::filesystem::is_empty(table_path)) {
boost::filesystem::remove_all(table_path);
LOG_ENGINE_DEBUG_ << "Remove collection folder: " << table_path;
}
std::string table_path = options.path_ + TABLES_FOLDER + collection_id;
if (force) {
boost::filesystem::remove_all(table_path);
LOG_ENGINE_DEBUG_ << "Remove collection folder: " << table_path;
} else if (boost::filesystem::exists(table_path) && boost::filesystem::is_empty(table_path)) {
boost::filesystem::remove_all(table_path);
LOG_ENGINE_DEBUG_ << "Remove collection folder: " << table_path;
}
// bool s3_enable = false;
......@@ -139,7 +94,7 @@ DeleteCollectionPath(const DBMetaOptions& options, const std::string& collection
Status
CreateCollectionFilePath(const DBMetaOptions& options, meta::SegmentSchema& table_file) {
std::string parent_path = GetCollectionFileParentFolder(options, table_file);
std::string parent_path = ConstructParentFolder(options.path_, table_file);
auto status = server::CommonUtil::CreateDirectory(parent_path);
fiu_do_on("CreateCollectionFilePath.fail_create", status = Status(DB_INVALID_PATH, ""));
......@@ -173,15 +128,6 @@ GetCollectionFilePath(const DBMetaOptions& options, meta::SegmentSchema& table_f
return Status::OK();
}
for (auto& path : options.slave_paths_) {
parent_path = ConstructParentFolder(path, table_file);
file_path = parent_path + "/" + table_file.file_id_;
if (boost::filesystem::exists(parent_path)) {
table_file.location_ = file_path;
return Status::OK();
}
}
std::string msg = "Collection file doesn't exist: " + file_path;
if (table_file.file_size_ > 0) { // no need to pop error for empty file
LOG_ENGINE_ERROR_ << msg << " in path: " << options.path_ << " for collection: " << table_file.collection_id_;
......
......@@ -82,7 +82,6 @@ DBWrapper::StartService() {
}
opt.insert_buffer_size_ = insert_buffer_size;
#if 1
bool cluster_enable = false;
std::string cluster_role;
STATUS_CHECK(config.GetClusterConfigEnable(cluster_enable));
......@@ -98,27 +97,6 @@ DBWrapper::StartService() {
kill(0, SIGUSR1);
}
#else
std::string mode;
s = config.GetServerConfigDeployMode(mode);
if (!s.ok()) {
std::cerr << s.ToString() << std::endl;
return s;
}
if (mode == "single") {
opt.mode_ = engine::DBOptions::MODE::SINGLE;
} else if (mode == "cluster_readonly") {
opt.mode_ = engine::DBOptions::MODE::CLUSTER_READONLY;
} else if (mode == "cluster_writable") {
opt.mode_ = engine::DBOptions::MODE::CLUSTER_WRITABLE;
} else {
std::cerr << "Error: server_config.deploy_mode in server_config.yaml is not one of "
<< "single, cluster_readonly, and cluster_writable." << std::endl;
kill(0, SIGUSR1);
}
#endif
// get wal configurations
s = config.GetWalConfigEnable(opt.wal_enable_);
if (!s.ok()) {
......@@ -214,16 +192,6 @@ DBWrapper::StartService() {
kill(0, SIGUSR1);
}
for (auto& path : opt.meta_.slave_paths_) {
s = CommonUtil::CreateDirectory(path);
if (!s.ok()) {
std::cerr << "Error: Failed to create database secondary path: " << path
<< ". Possible reason: db_config.secondary_path is wrong in server_config.yaml or not available."
<< std::endl;
kill(0, SIGUSR1);
}
}
// create db instance
try {
db_ = engine::DBFactory::Build(opt);
......
......@@ -240,10 +240,6 @@ Server::Start() {
STATUS_CHECK(config.GetClusterConfigEnable(cluster_enable));
STATUS_CHECK(config.GetClusterConfigRole(cluster_role));
// std::string deploy_mode;
// STATUS_CHECK(config.GetServerConfigDeployMode(deploy_mode));
// if (deploy_mode == "single" || deploy_mode == "cluster_writable") {
if ((not cluster_enable) || cluster_role == "rw") {
std::string db_path;
STATUS_CHECK(config.GetStorageConfigPath(db_path));
......
......@@ -37,7 +37,6 @@ Status
ReLoadSegmentsRequest::OnExecute() {
auto& config = Config::GetInstance();
#if 1
bool cluster_enable = false;
std::string cluster_role;
STATUS_CHECK(config.GetClusterConfigEnable(cluster_enable));
......@@ -47,19 +46,6 @@ ReLoadSegmentsRequest::OnExecute() {
// TODO: No need to reload segment files
return Status(SERVER_SUCCESS, "");
}
#else
std::string deploy_mode;
auto status = config.GetServerConfigDeployMode(deploy_mode);
if (!status.ok()) {
return status;
}
fiu_do_on("ReLoadSegmentsRequest.OnExecute.readonly", deploy_mode = "cluster_readonly");
if (deploy_mode == "single" || deploy_mode == "cluster_writable") {
// TODO: No need to reload segment files
return Status(SERVER_SUCCESS, "");
}
#endif
try {
std::string hdr = "ReloadSegmentsRequest(collection=" + collection_name_ + ")";
......
......@@ -44,7 +44,6 @@ StorageChecker::CheckStoragePermission() {
return Status(SERVER_UNEXPECTED_ERROR, err_msg);
}
#if 1
bool cluster_enable = false;
std::string cluster_role;
STATUS_CHECK(config.GetClusterConfigEnable(cluster_enable));
......@@ -53,17 +52,6 @@ StorageChecker::CheckStoragePermission() {
if (cluster_enable && cluster_role == "ro") {
return Status::OK();
}
#else
std::string deploy_mode;
status = config.GetServerConfigDeployMode(deploy_mode);
if (!status.ok()) {
return status;
}
if (deploy_mode == "cluster_readonly") {
return Status::OK();
}
#endif
/* Check db directory write permission */
std::string primary_path;
......
......@@ -86,8 +86,6 @@ TEST(DBMiscTest, META_TEST) {
TEST(DBMiscTest, UTILS_TEST) {
milvus::engine::DBMetaOptions options;
options.path_ = "/tmp/milvus_test/main";
options.slave_paths_.push_back("/tmp/milvus_test/slave_1");
options.slave_paths_.push_back("/tmp/milvus_test/slave_2");
const std::string COLLECTION_NAME = "test_tbl";
......@@ -98,25 +96,9 @@ TEST(DBMiscTest, UTILS_TEST) {
ASSERT_FALSE(status.ok());
fiu_disable("CommonUtil.CreateDirectory.create_parent_fail");
FIU_ENABLE_FIU("CreateCollectionPath.creat_slave_path");
status = milvus::engine::utils::CreateCollectionPath(options, COLLECTION_NAME);
ASSERT_FALSE(status.ok());
fiu_disable("CreateCollectionPath.creat_slave_path");
status = milvus::engine::utils::CreateCollectionPath(options, COLLECTION_NAME);
ASSERT_TRUE(status.ok());
ASSERT_TRUE(boost::filesystem::exists(options.path_));
for (auto& path : options.slave_paths_) {
ASSERT_TRUE(boost::filesystem::exists(path));
}
// options.slave_paths.push_back("/");
// status = engine::utils::CreateCollectionPath(options, COLLECTION_NAME);
// ASSERT_FALSE(status.ok());
//
// options.path = "/";
// status = engine::utils::CreateCollectionPath(options, COLLECTION_NAME);
// ASSERT_FALSE(status.ok());
milvus::engine::meta::SegmentSchema file;
file.id_ = 50;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册