From 4b5eff367236e0a2259e02ee2c96507babbf1511 Mon Sep 17 00:00:00 2001 From: Jin Hai Date: Fri, 5 Jun 2020 09:58:17 +0800 Subject: [PATCH] Fix 2495: Add more reason of creating lock file failed (#2496) * Fix 2495: Add more reason of creating lock file failed Signed-off-by: jinhai * Fix 2495: Update changelog Signed-off-by: jinhai * Fix lint Signed-off-by: jinhai * Fix lint Signed-off-by: JinHai-CN * Fix compile error Signed-off-by: JinHai-CN --- CHANGELOG.md | 1 + core/src/server/init/InstanceLockCheck.cpp | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75b014b3bf..abd700992f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Please mark all change in change log and use the issue from GitHub - \#2381 Upgrade FAISS to 1.6.3 - \#2441 Improve Knowhere code coverage - \#2466 optimize k-selection implemention of faiss gpu version +- \#2495 Add creating lock file failure reason. ## Task diff --git a/core/src/server/init/InstanceLockCheck.cpp b/core/src/server/init/InstanceLockCheck.cpp index 293bb70ac0..0fca2fd99a 100644 --- a/core/src/server/init/InstanceLockCheck.cpp +++ b/core/src/server/init/InstanceLockCheck.cpp @@ -14,6 +14,7 @@ #include #include +#include #include namespace milvus { @@ -29,7 +30,7 @@ InstanceLockCheck::Check(const std::string& path) { // Not using locking for read-only lock file msg += "Lock file is read-only."; } - msg += "Could not open lock file."; + msg += "Could not open file: " + lock_path + ", " + strerror(errno); return Status(SERVER_UNEXPECTED_ERROR, msg); } @@ -41,15 +42,16 @@ InstanceLockCheck::Check(const std::string& path) { fl.l_start = 0; fl.l_len = 0; if (fcntl(fd, F_SETLK, &fl) == -1) { - std::string msg; + std::string msg = "Can't lock file: " + lock_path + ", due to "; if (errno == EACCES || errno == EAGAIN) { - msg += "Permission denied. "; + msg += "permission denied. "; } else if (errno == ENOLCK) { // Not using locking for nfs mounted lock file - msg += "Using nfs. "; + msg += "using nfs. "; + } else { + msg += std::string(strerror(errno)) + ". "; } close(fd); - msg += "Could not get lock."; return Status(SERVER_UNEXPECTED_ERROR, msg); }