Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] meta daemon may stuck #3482

Merged
merged 2 commits into from
Dec 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/daemons/MetaDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static std::unique_ptr<apache::thrift::ThriftServer> gServer;
static std::unique_ptr<nebula::kvstore::KVStore> gKVStore;

static void signalHandler(int sig);
static void waitForStop();
static Status setupSignalHandler();
extern Status setupLogging();
#if defined(__x86_64__)
Expand Down Expand Up @@ -345,6 +346,7 @@ int main(int argc, char* argv[]) {
gServer->setSSLConfig(nebula::sslContextConfig());
}
gServer->serve(); // Will wait until the server shuts down
waitForStop();
} catch (const std::exception& e) {
LOG(ERROR) << "Exception thrown: " << e.what();
return EXIT_FAILURE;
Expand All @@ -368,18 +370,20 @@ void signalHandler(int sig) {
if (gServer) {
gServer->stop();
}
{
auto gJobMgr = nebula::meta::JobManager::getInstance();
if (gJobMgr) {
gJobMgr->shutDown();
}
}
if (gKVStore) {
gKVStore->stop();
gKVStore.reset();
}
break;
default:
FLOG_ERROR("Signal %d(%s) received but ignored", sig, ::strsignal(sig));
}
}

void waitForStop() {
auto jobMan = nebula::meta::JobManager::getInstance();
if (jobMan) {
jobMan->shutDown();
}

if (gKVStore) {
gKVStore->stop();
gKVStore.reset();
}
}