Fix Fail to access WAL storage path (#2196) (#2198)

Signed-off-by: Yhz <yinghao.zou@zilliz.com>
pull/2208/head
BossZou 2020-04-30 17:47:12 +08:00 committed by GitHub
parent 14b3e95960
commit b458034ad5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 10 deletions

View File

@ -14,6 +14,7 @@ Please mark all change in change log and use the issue from GitHub
- \#2128 Check has_partition params
- \#2131 Distance/ID returned is not correct if searching with duplicate ids
- \#2141 Fix server start failed if wal directory exist
- \#2196 Fix server start failed if wal is disabled
## Feature
- \#1751 Add api SearchByID

View File

@ -84,19 +84,27 @@ StorageChecker::CheckStoragePermission() {
}
/* Check wal directory write permission */
std::string wal_path;
status = config.GetWalConfigWalPath(wal_path);
bool wal_enable = false;
status = config.GetWalConfigEnable(wal_enable);
if (!status.ok()) {
return status;
}
ret = access(wal_path.c_str(), F_OK | R_OK | W_OK);
fiu_do_on("StorageChecker.CheckStoragePermission.wal_path_access_fail", ret = -1);
if (0 != ret) {
std::string err_msg = " Access WAL storage path " + wal_path + " fail. " + strerror(errno) +
"(code: " + std::to_string(errno) + ")";
LOG_SERVER_FATAL_ << err_msg;
std::cerr << err_msg << std::endl;
return Status(SERVER_UNEXPECTED_ERROR, err_msg);
if (wal_enable) {
std::string wal_path;
status = config.GetWalConfigWalPath(wal_path);
if (!status.ok()) {
return status;
}
ret = access(wal_path.c_str(), F_OK | R_OK | W_OK);
fiu_do_on("StorageChecker.CheckStoragePermission.wal_path_access_fail", ret = -1);
if (0 != ret) {
std::string err_msg = " Access WAL storage path " + wal_path + " fail. " + strerror(errno) +
"(code: " + std::to_string(errno) + ")";
LOG_SERVER_FATAL_ << err_msg;
std::cerr << err_msg << std::endl;
return Status(SERVER_UNEXPECTED_ERROR, err_msg);
}
}
return Status::OK();