未验证 提交 8046f294 编写于 作者: T Tinkerrr 提交者: GitHub

Hotfix 2487 (#2892)

* update.
Signed-off-by: NTinkerrr <linxiaojun.cn@outlook.com>

* update.
Signed-off-by: NTinkerrr <xiaojun.lin@zilliz.com>

* add fd check
Signed-off-by: NTinkerrr <xiaojun.lin@zilliz.com>

* fix
Signed-off-by: NTinkerrr <xiaojun.lin@zilliz.com>
上级 283e087a
......@@ -23,6 +23,7 @@ Please mark all change in change log and use the issue from GitHub
- \#2774 Server down during loading data
- \#2776 Fix too many data copies during creating IVF index
- \#2813 To implemente RNSG IP
- \#2487 HotFix release lock failed on NAS
## Feature
......
......@@ -23,6 +23,12 @@
namespace milvus {
namespace server {
InstanceLockCheck*
InstanceLockCheck::GetInstance() {
static InstanceLockCheck lk;
return &lk;
}
Status
InstanceLockCheck::Check(const std::string& path) {
std::string lock_path = path + "/lock";
......@@ -37,6 +43,7 @@ InstanceLockCheck::Check(const std::string& path) {
msg += "Could not open file: " + lock_path + ", " + strerror(errno);
return Status(SERVER_UNEXPECTED_ERROR, msg);
}
InstanceLockCheck::GetInstance()->lk_path = lock_path;
// Acquire a write lock
struct flock fl;
......@@ -66,5 +73,21 @@ InstanceLockCheck::Check(const std::string& path) {
return Status::OK();
}
void
InstanceLockCheck::Release() {
auto fd = open(InstanceLockCheck::GetInstance()->lk_path.c_str(), O_RDWR | O_CREAT | O_NOFOLLOW, 0640);
if (fd < 0) {
std::string msg;
if (errno == EROFS) {
// Not using locking for read-only lock file
msg += "Lock file is read-only.";
}
msg += "Could not open file for release: " + InstanceLockCheck::GetInstance()->lk_path + ", " + strerror(errno);
LOG_SERVER_ERROR_ << msg;
return;
}
close(fd);
}
} // namespace server
} // namespace milvus
......@@ -21,6 +21,15 @@ class InstanceLockCheck {
public:
static Status
Check(const std::string& path);
static void
Release();
static InstanceLockCheck*
GetInstance();
public:
std::string lk_path;
}; // InstanceLockCheck
} // namespace server
......
......@@ -11,6 +11,7 @@
#include "utils/SignalUtil.h"
#include "src/server/Server.h"
#include "src/server/init/InstanceLockCheck.h"
#include "utils/Log.h"
#include <execinfo.h>
......@@ -22,6 +23,8 @@ namespace server {
void
SignalUtil::HandleSignal(int signum) {
InstanceLockCheck::Release();
LOG_SERVER_INFO_ << "Release lock!" << signum;
switch (signum) {
case SIGINT:
case SIGUSR2: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册