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

simplify graph signal handler #3542

Merged
merged 14 commits into from
Dec 30, 2021
Merged

Conversation

heroicNeZha
Copy link
Contributor

@heroicNeZha heroicNeZha commented Dec 23, 2021

What type of PR is this?

  • bug
  • feature
  • enhancement

What does this PR do?

closes #3441
simplify graphd signal handler:Set stop condition instead of waiting all workers stop

Which issue(s)/PR(s) this PR relates to?

In #3437 , it simplify storage SIGINT signal handler

Special notes for your reviewer, ex. impact of this fix, etc:

Additional context/ Design document:

Checklist:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the corresponding label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:

                                                            `

@heroicNeZha heroicNeZha added ready-for-testing PR: ready for the CI test ready for review and removed ready-for-testing PR: ready for the CI test labels Dec 23, 2021
serverStatus_.store(STATUS_RUNNING);
FLOG_INFO("Starting nebula-graphd on %s:%d\n", localhost.host.c_str(), localhost.port);
try {
gServer->serve(); // Blocking wait until shut down via gServer->stop()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you just need call serve in this thread.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I call serve(), the deamon will be blocked here, I don’t know how to ensure that the stop call is not a worker thread

@heroicNeZha heroicNeZha added the ready-for-testing PR: ready for the CI test label Dec 27, 2021
enum ServiceStatus { STATUS_UNINITIALIZED = 0, STATUS_RUNNING = 1, STATUS_STOPPED = 2 };
std::atomic<ServiceStatus> serverStatus_{STATUS_UNINITIALIZED};
std::mutex muStop_;
std::condition_variable cvStop_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to provide a class to handle this signal process

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -24,7 +24,7 @@ bool GraphServer::start() {
int numThreads =
FLAGS_num_worker_threads > 0 ? FLAGS_num_worker_threads : gServer_->getNumIOWorkerThreads();
std::shared_ptr<apache::thrift::concurrency::ThreadManager> threadManager(
PriorityThreadManager::newPriorityThreadManager(numThreads, false /*stats*/));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After updating third party 3.0,newPriorityThreadManager remove second argument

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This argument affects the performance a lot, we must know how it behaves now. And make sure if it has another way to set the value. A benchmark must done for this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

facebook/fbthrift@bfb527c?diff=split
Through this commit,thrift removed stats, and the function is the same as setting it to false

Copy link
Contributor

@yixinglu yixinglu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little complicated implementation, could use init and start function to do this. And need not to spawn a new thread for thrift server. you can talk with me offline.

src/graph/service/GraphServer.h Outdated Show resolved Hide resolved
src/graph/service/GraphServer.h Outdated Show resolved Hide resolved
src/graph/service/GraphServer.cpp Outdated Show resolved Hide resolved
src/daemons/GraphDaemon.cpp Outdated Show resolved Hide resolved
src/daemons/GraphDaemon.cpp Show resolved Hide resolved
src/graph/service/GraphServer.cpp Show resolved Hide resolved
CPWstatic
CPWstatic previously approved these changes Dec 28, 2021
@heroicNeZha heroicNeZha linked an issue Dec 28, 2021 that may be closed by this pull request
}

ServiceStatus serverExpected = ServiceStatus::STATUS_RUNNING;
serverStatus_.compare_exchange_strong(serverExpected, STATUS_STOPPED);
Copy link
Contributor

@Shylock-Hg Shylock-Hg Dec 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't wait it to be running?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it wait in thriftServer.stop

@CPWstatic CPWstatic merged commit 321f549 into vesoft-inc:master Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

graphd might block at exit
5 participants