fix server start failed if wal directory exist (#2144)

* fix server start failed if wal directory exist

Signed-off-by: wxyu <xy.wang@zilliz.com>

* add wal_enable check

Signed-off-by: wxyu <xy.wang@zilliz.com>

* fix compile error

Signed-off-by: wxyu <xy.wang@zilliz.com>
This commit is contained in:
Wang XiangYu 2020-04-27 20:05:04 +08:00 committed by GitHub
parent bf42dbd5b6
commit b65f5072f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 9 deletions

View File

@ -10,6 +10,7 @@ Please mark all change in change log and use the issue from GitHub
- \#1997 Index file missed after compact
- \#2073 Fix CheckDBConfigBackendUrl error message
- \#2076 CheckMetricConfigAddress error message
- \#2141 Fix server start failed if wal directory exist
## Feature
- \#1751 Add api SearchByID

View File

@ -205,25 +205,43 @@ Server::Start() {
return s;
}
try {
// True if a new directory was created, otherwise false.
boost::filesystem::create_directories(db_path);
} catch (...) {
return Status(SERVER_UNEXPECTED_ERROR, "Cannot create db directory");
}
s = InstanceLockCheck::Check(db_path);
if (!s.ok()) {
std::cerr << "deploy_mode: " << deploy_mode << " instance lock db path failed." << std::endl;
return s;
}
std::string wal_path;
s = config.GetWalConfigWalPath(wal_path);
bool wal_enable = false;
s = config.GetWalConfigEnable(wal_enable);
if (!s.ok()) {
return s;
}
if (not boost::filesystem::create_directories(wal_path)) {
return Status(SERVER_UNEXPECTED_ERROR, "Cannot create wal dir");
}
s = InstanceLockCheck::Check(wal_path);
if (!s.ok()) {
std::cerr << "deploy_mode: " << deploy_mode << " instance lock wal path failed." << std::endl;
return s;
if (wal_enable) {
std::string wal_path;
s = config.GetWalConfigWalPath(wal_path);
if (!s.ok()) {
return s;
}
try {
// True if a new directory was created, otherwise false.
boost::filesystem::create_directories(wal_path);
} catch (...) {
return Status(SERVER_UNEXPECTED_ERROR, "Cannot create wal directory");
}
s = InstanceLockCheck::Check(wal_path);
if (!s.ok()) {
std::cerr << "deploy_mode: " << deploy_mode << " instance lock wal path failed." << std::endl;
return s;
}
}
}